5-14
SC140 DSP Core Reference Manual
Program Control
Table 5-6 illustrates the location of these markers and their functionality in both short and long loops.
Refer to
Appendix A, “SC140 DSP Core Instruction Set,“
for further details.
Table 5-6. LPMARKA and LPMARKB in Short and Long Loops
5.2.3 Hardware Loop Initiation and Execution
The following steps are required to initiate a hardware loop:
1.
Execute a DOSETUPn instruction at some stage before the loop starts (except in the case of
a short loop). This instruction writes the start address of the loop to the corresponding SAn
register.
2.
Execute a DOENn or DOENSHn instruction to load the corresponding LCn register with the
number of iterations for the loop. The corresponding loop flag bit is implicitly set when LCn
is loaded with the loop iteration value. The SLF is set if the loop is initialized by a
DOENSHn instruction.
3.
Whenever a SKIPLS instruction is executed before entering the loop, the value of LCn is
checked. If the value of LCn is less than or equal to zero, then the loop is skipped and the
program counter (PC) is loaded with the address specified in the SKIPLS instruction. If it is
guaranteed that LCn is greater than zero (for example, if the loop is initialized by an
immediate value), the SKIPLS instruction can be omitted. The SKIPLS instruction provides
the additional flexibility of skipping the steps in the loop completely if the loop count is zero
initially.
After the LCn is loaded and the LFn bit is set with the DOENn or DOENSHn instruction, the loop machine
is ready for operation. In long loops, whenever the program reaches the execution set marked by
LPMARKB [which appears two execution sets before the last execution set of the loop (LA-2)], LCn is
compared to the value one in order to detect loop termination. If the value of LCn is greater than one, the
program effectively jumps to the start address and executes the last two instructions in the delay slots. The
LCn is decremented by one and the loop is repeated. If the value of LCn is equal or less than one, the loop
terminates and the loop flag bit is cleared. Execution of instructions continues in sequence.
In short loops, one or two execution sets are stored in internal buffers and repeated the appropriate number
of times according to the value stored in LCn. No program fetches are required for short loops.
Loop Type
LPMARKA
LPMARKB
Location
Functionality
Location
Functionality
Short loop
SA
Identifies a single-execution
set loop. Causes no timing
overhead.
SA
Identifies a two-execution
set loop. Causes no timing
overhead.
Long loop
LA
Identifies a jump to SA after
executing the set at LA, if the
loop is repeated. Causes a
timing overhead.
LA-2
Identifies a jump to SA
after executing the sets at
LA-2, LA-1, and LA, if the
loop is repeated. Causes
no timing overhead.