# How to add (all zero state) to the states of linear feedback shift register (LFSR)

I need to add the state of all zeros to the states of an linear feedback shift register.

How can I do this?

• Master reset or flush through with zero – Andy aka Dec 21 '15 at 21:27
• Why? What problem are you actually trying to solve? Do you need to have all $2^n$ states present in the output sequence, or do you just need the all-0's state to not get the FSM stuck? – The Photon Dec 21 '15 at 21:27
• its an question in my college report What if we want to add the all zero state to the states to LFSR?! – A_S Dec 21 '15 at 21:40
• if you do, you get the Galois Field of that length. It doesn't necessarily help you, just sayin'. – Neil_UK Dec 21 '15 at 21:58

The standard LSFR with XOR feedback has two stable 'orbits', stuck at zeroes, and the 'm-sequence' consisting of all remaining 2^n-1 states, where the shift register has n binary flip-flops.

A modified LSFR with XNOR feedback, also has two stable orbits, stuck at ones, and a sequence of the 2^n-1 remaining states. This sequence will contain the 00000 state, but will not now contain 11111.

What state occurs before you would like the all 0s state? What state would occur after the all 0s?

For instance, in a 5 bit, 00001 becomes 10000, it might be handy to have 00000 between those.

Normally, the XOR next state logic of a LSFR turns one into the other.

You have to detect 00001 and override the logic to force 00000.

With the normal LSFR logic, the 00000 state would be persistent, so you have to override it one more time to force 10000 after 00000. You could either detect 00000, or remember that you forced one cycle ago, so you have to do the other force this cycle.

If you have a state of all zeroes in an LFSR, it will stay in that state forever. That's why it's always missing. You could could artificially force it into and out of that state, but you would then have a modified (and more complicated) LFSR and the resulting sequence might be unsatisfactory for its intended application.

One way to get all zeroes would be to invert one or all of the state bits so whatever reading it would see an all zero state even though the state inside the LFSR never goes there. Naturally, there will be one other state in its place that is now missing.

Which is to say, if there were an easy solution, it would already be part of the established design.