1 / 18

Return Stack

Return Stack. Lecture 8.4 A VHDL Forth Core for FPGAs: Sect. 5. A 32 x 16 Stack. Same as used in the Data Stack. A 32 x 16 Stack Module. The Return Stack. The WC16C WHYP Core. FC16 Return Stack Instructions. when tor => tload <= '1'; nload <= '1';

mikaia
Download Presentation

Return Stack

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Return Stack Lecture 8.4 A VHDL Forth Core for FPGAs: Sect. 5

  2. A 32 x 16 Stack Same as used in the Data Stack

  3. A 32 x 16 Stack Module

  4. The Return Stack

  5. The WC16C WHYP Core

  6. FC16 Return Stack Instructions

  7. when tor => tload <= '1'; nload <= '1'; tsel <= "111"; nsel <= "01"; dpop <= '1'; rload <= '1'; rpush <= '1'; rinsel <= '1'; >R “To-R” Pop T and push it on return stack.

  8. when rfrom => tload <= '1'; nload <= '1'; tsel <= "011"; dpush <= '1'; rsel <= '1'; rload <= '1'; rpop <= '1'; R> “R-from” Pop return stack R and push it into T.

  9. R@ when rfetch => tload <= '1'; nload <= '1'; tsel <= "011"; dpush <= '1'; “R-fetch” Copy R to T and push data stack

  10. R>DROP when rfromdrop => rsel <= '1'; rload <= '1'; rpop <= '1'; “R-from-drop” Pop return stack R and throw it away

  11. FC16 Return Stack Instructions

  12. FOR…NEXT Loop n FOR <WHYP statements> NEXT >R drjne <WHYP statements> Decrement top of return stack and branch back to <WHYP statements> if not equal to zero. Therefore, <WHYP statements> are executed n times.

  13. DRJNE Decrement R and jump if R is not zero -- r1 <= '1' if R-1 is all zeros r1 := '0'; for i in width-1 downto 1 loop r1 := r1 or R(i); end loop; r1 := (not r1) and R(0); when drjne => rdec <= not r1; pload <= not r1; psel <= '0'; pinc <= r1; rsel <= r1; rload <= r1; rpop <= r1;

  14. The Return Stack

  15. CALL Call subroutine Jump to address M and push address of next instruction (P + 1) on return stack when call => pload <= '1'; rload <= '1'; rpush <= '1'; In ROM: call, X”1234”, --12 --14

  16. RET Subroutine return Jump to address on top of the return stack, and pop the return stack when ret => psel <= '1'; pload <= '1'; rsel <= '1'; rload <= '1'; rpop <= '1';

  17. \ led8.whp HEX : 1ms_Delay ( -- ) 30D1 FOR NEXT ; : .5sec_Delay ( -- ) 1F4 FOR 1ms_Delay NEXT ; : MAIN ( -- ) BEGIN 8000 8 FOR DUP LD! DUP DIG! .5sec_Delay 2/ NEXT 8 FOR U2/ DUP LD! DUP DIG! .5sec_Delay NEXT DROP AGAIN ;

  18. constant rom: rom_array := ( JMP, --0 X"0010", --1 LIT, --2 X"30D1", --3 tor, --4 drjne, --5 X"0005", --6 RET, --7 LIT, --8 X"03E8", --9 tor, --a CALL, --b X"0002", --c drjne, --d X"000b", --e RET, --f LIT, --10 X"8000", --11 LIT, --12 X"0008", --13 tor, --14 ROM Listing HEX : 1ms_Delay ( -- ) 30D1 FOR NEXT ; : .5sec_Delay ( -- ) 1F4 FOR 1ms_Delay NEXT ; : MAIN ( -- ) BEGIN 8000 8 FOR

More Related