Difference between revisions of "Return Stack"

From Land Boards Wiki
Jump to navigation Jump to search
(Created page with "= IOP-16 Stack = * Sizes ** 0 (none) *** No JSRs or RTSs in code *** Can do JMPs ** 1 deep (does not need SRAM) *** Single deep calls ** Optionally deeper as build option (us...")
 
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= IOP-16 Stack =
 
= IOP-16 Stack =
  
* Sizes
+
* Stack is used to keep track of return addresses for subroutines
** 0 (none)
+
** Stores to stack on JSR instruction
 +
** Loads from stack with RTS instruction
 +
* Last-In, First-Out (LIFO)
 +
** [https://github.com/dominiksalvet/vhdl-collection/blob/master/rtl/lifo.vhdl VHDL code]
 +
* 12-bit width
 +
 
 +
== Configuring Depth ==
 +
 
 +
* Configurable stack depth
 +
** 0 = no stack
 
*** No JSRs or RTSs in code
 
*** No JSRs or RTSs in code
 
*** Can do JMPs
 
*** Can do JMPs
** 1 deep (does not need SRAM)
+
** 1 deep = Single deep calls
*** Single deep calls
+
** Optionally deeper as build option (uses more registers)
** Optionally deeper as build option (uses SRAM)
+
* Set STACK_DEPTH_PASS to the max nesting depth of the subroutines in the top file
 +
* The LIFO capacity is equal to 2 ^ STACK_DEPTH_PASS - 1
 +
 
 +
<pre>
 +
IOP16: ENTITY work.cpu_001
 +
-- Need to pass down instruction RAM and stack sizes
 +
generic map (
 +
INST_ROM_SIZE_PASS => 512, -- Small code size since program is "simple"
 +
STACK_DEPTH_PASS  => 4   -- Subroutine depth (not nested)
 +
)
 +
</pre>
 +
 
 +
== Resources ==
 +
 
 +
* STACK_DEPTH_PASS = 3
 +
** ALMs: 33
 +
** Registers: 86
 +
* STACK_DEPTH_PASS = 4
 +
** ALMs: 54
 +
** Registers: 158

Latest revision as of 15:01, 19 April 2022

IOP-16 Stack

  • Stack is used to keep track of return addresses for subroutines
    • Stores to stack on JSR instruction
    • Loads from stack with RTS instruction
  • Last-In, First-Out (LIFO)
  • 12-bit width

Configuring Depth

  • Configurable stack depth
    • 0 = no stack
      • No JSRs or RTSs in code
      • Can do JMPs
    • 1 deep = Single deep calls
    • Optionally deeper as build option (uses more registers)
  • Set STACK_DEPTH_PASS to the max nesting depth of the subroutines in the top file
  • The LIFO capacity is equal to 2 ^ STACK_DEPTH_PASS - 1
IOP16: ENTITY work.cpu_001
-- Need to pass down instruction RAM and stack sizes
	generic map 	( 
		INST_ROM_SIZE_PASS => 512, -- Small code size since program is "simple"
		STACK_DEPTH_PASS   => 4	   -- Subroutine depth (not nested)
	)

Resources

  • STACK_DEPTH_PASS = 3
    • ALMs: 33
    • Registers: 86
  • STACK_DEPTH_PASS = 4
    • ALMs: 54
    • Registers: 158