Freescale Semiconductor SC140 Loop Initiation and Execution, Loop Type, Location Functionality

Models: SC140

1 760
Download 760 pages 48.94 Kb
Page 207
Image 207

Hardware Loops

Table 5-9 illustrates the location of these marker bits and their functionality in both short and long loops. Refer to Appendix A, “SC140 DSP Core Instruction Set,” for further details.

Table 5-9. LPMARKA and LPMARKB Bits in Short and Long Loops

Loop Type

 

LPMARKA

 

LPMARKB

 

 

 

 

 

 

 

 

 

Location

Functionality

Location

Functionality

 

 

 

 

 

 

 

 

 

 

Short loop

SA

Identifies a single-execution

SA

Identifies a two-execution

 

 

set loop. Causes no timing

 

set loop. Causes no timing

 

 

overhead.

 

overhead.

 

 

 

 

 

Long loop

LA

Identifies a jump to SA after

LA-2

Identifies a jump to SA

 

 

executing the set at LA, if the

 

after executing the sets at

 

 

loop is repeated. Causes a

 

LA-2, LA-1, and LA, if the

 

 

timing overhead.

 

loop is repeated. Causes

 

 

 

 

no timing overhead.

 

 

 

 

 

5.4.3 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.Execute a SKIPLS instruction before entering the loop to check the value of LCn. 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 hardware loop 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 while executing the two execution sets at LA-1 and LA. 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.

SC140 DSP Core Reference Manual

5-27

Page 207
Image 207
Freescale Semiconductor SC140 Loop Initiation and Execution, Lpmarka and Lpmarkb Bits in Short and Long Loops, Loop Type