0

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?

xinta
  • 9
  • 8

1 Answers1

2

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.

Alain Merigot
  • 10,667
  • 3
  • 18
  • 31
  • There is a time gain if i compare this method with the loop method in 8086 that works with CX buffer decrementation? – xinta Jul 03 '19 at 20:35
  • In terms of HW implementation, it is easier to implement loops with special purpose registers than with a GP register like CX. So, in blackfin, the hardware will be simpler and the power reduced (that is one of the purpose of the proc). And the loops are quite different. For blackfin, it is a `for` loop with, at loop setup, fixed start and end addresses and iteration count: **no** branch instruction needs to be executed. For x86, loop is a branch instruction and the gain (vs standard loops à la RISC) is that the loop instruction branches *and* modifies CX. So there is a gain with blackfin. – Alain Merigot Jul 03 '19 at 21:06