Return to the Products Page
  homesearchagentssupportask xilinxmap

LFSR Counting Backwards

Sparty's Favorite Recipes 013 Kiss Your ASIC Good-bye!

Ingredients:

  • Spartan-II Device
  • 2.1i Development System
  • Instructions

    Linear Feedback Shift Registers are very efficient and fast counters, provided their non-binary count sequence is acceptable. The counter consists of an n-bit shift register shifting left-to-right. The rightmost bit and certain other bits are combined in an XNOR gate and drive the D input of the leftmost bit.

    The proper taps for dividing by 2n-1 are listed in the app note : XAPP052: Efficient Shift Registers, LFSR Counters and Long Pseudo-Random Sequence Generators.

    It is easy to reverse the direction of such an LFSR counter:

    • Reverse the direction of the shift register to right-to-left.
    • Feed the D input of the right-most bit with the output of a new XNOR gate.

    The inputs to this new XNOR gate are similar to the XNOR gate for the left-to-right case, but they are all rotated one position to the right, and the leftmost bit takes the place of the rightmost bit.

    Use the example of a 15-bit up counter. If the bit positions are counted as 1 through 15, left to right, then the XNOR of bits 14 and 15 feeds D input of position 1. The same counter running backwards, shifting right-to-left: XNOR of positions 15 and 1 feeds D input of position 15.

    Advantages of LFSR counters: No carry logic, no carry delay, easy to change direction, very easy to detect or decode previous or next state.

    Disadvantages of LFSR counters: Non-binary count sequence. The sequence is one code short, and the counter would lock up if it ever accidentally got into this illegal state (all Ones in the case of the XNOR feedback). There are ways to avoid this problem, but they involve additional logic and get rather complicated beyond six bits.

     

    Related Information