-
sdr.FLFSR.step(steps: int =
1
) FieldArray Produces the next
steps
output symbols.Examples¶
Step the Fibonacci LFSR one output at a time. Notice the first \(n\) outputs of a Fibonacci LFSR are its state reversed.
In [1]: c = galois.primitive_poly(7, 4) In [2]: lfsr = sdr.FLFSR(c, state=[1, 2, 3, 4]); lfsr Out[2]: <Fibonacci LFSR: c(x) = x^4 + x^2 + 3x + 5 over GF(7)> In [3]: lfsr.state, lfsr.step() Out[3]: (GF([1, 2, 3, 4], order=7), GF(4, order=7)) In [4]: lfsr.state, lfsr.step() Out[4]: (GF([4, 1, 2, 3], order=7), GF(3, order=7)) In [5]: lfsr.state, lfsr.step() Out[5]: (GF([6, 4, 1, 2], order=7), GF(2, order=7)) In [6]: lfsr.state, lfsr.step() Out[6]: (GF([4, 6, 4, 1], order=7), GF(1, order=7)) In [7]: lfsr.state, lfsr.step() Out[7]: (GF([5, 4, 6, 4], order=7), GF(4, order=7)) # Ending state In [8]: lfsr.state Out[8]: GF([0, 5, 4, 6], order=7)
Step the Fibonacci LFSR 5 steps in one call. This is more efficient than iterating one output at a time.
In [9]: c = galois.primitive_poly(7, 4) In [10]: lfsr = sdr.FLFSR(c, state=[1, 2, 3, 4]); lfsr Out[10]: <Fibonacci LFSR: c(x) = x^4 + x^2 + 3x + 5 over GF(7)> In [11]: lfsr.state Out[11]: GF([1, 2, 3, 4], order=7) In [12]: lfsr.step(5) Out[12]: GF([4, 3, 2, 1, 4], order=7) # Ending state In [13]: lfsr.state Out[13]: GF([0, 5, 4, 6], order=7)
Step the Fibonacci LFSR 5 steps backward. Notice the output sequence is the reverse of the original sequence. Also notice the ending state is the same as the initial state.
In [14]: lfsr.step(-5) Out[14]: GF([4, 1, 2, 3, 4], order=7) In [15]: lfsr.state Out[15]: GF([1, 2, 3, 4], order=7)