Digital Signal Processing Reference
In-Depth Information
from PC
Return Address
Stack
N
write_en
1
write_lifo_addr
current
2
call
sub
return
to
incremented
next_address_mux
Stack Pointer logic
read_lifo_addr
clk
rst_n
Figure 10.16 Subroutine return address stack
A representative instruction for a loop can be written as in Figure 10.17. The instruction provides
the loop end-address and the count for the number of times the loop needs to be repeated. As counter
runs down to zero therefore while specifying the loop count one must be subtracted from the actual
count the loop needs to run. In the cycle in which the state machine executes the loop instruction, the
PC stores the address of the next instruction that also is the start-address of the loop. In the example,
the loop instruction is at address 80, PC contains the next address 81, and the loop instruction
specifies the loop end-address and the loop counter as 100 and 20, respectively. The loop machine
stores these three values in loop_start_addr_reg , loop_end_addr_reg and loop_
count_reg , respectively. The value in the PC is continuously compared with the loop end-
address. If the PC is equal to the loop end-address, the value in loop_count_reg is decremented
by 1 and is checked whether the down count is equal to zero. If it is not, the next-address logic selects
address of
instructions
Loop count
79
80
81
82
Loop end
address
repeat
20,
100
Loop start addr
Loop
body
100
Figure 10.17 Representative instruction for a loop
Search WWH ::




Custom Search