Search code examples
parallel-processingblackfin

Zero-overhead loop in DSP


Blackfin does zero overhead looping in circular buffer.How does it realize that the number of iterations has been completed without a comparison or decrementation of a counter?


Solution

  • From blackfin documentation:

    The sequencer supports a mechanism of zero-overhead looping. The sequencer contains two loop units, each containing three registers. Each loop unit has a Loop Top register ( LT0 , LT1 ), a Loop Bottom register (LB0 , LB1), and a Loop Count register (LC0, LC1).
    Two sets of zero-overhead loop registers implement loops, using hardware counters instead of software instructions to evaluate loop conditions. After evaluation, processing branches to a new target address. Both sets of regis- ters include the Loop Counter ( LC), Loop Top (LT ), and Loop Bottom (LB ) registers.

    This works if Loop Counter is decremented every time that the loop is entered.
    Then when the program counter reaches Loop Bottom, it is sufficient to test the value of this counter to branch

    • to the next instruction and leave the loop if Loop Counter == 0
    • to Loop Top to continue iterations if Loop Counter != 0. It is also required to decrement Loop Counter simultaneously.

    This ensures zero-overhead looping.