-
galois.FLFSR.step(steps: int =
1
) FieldArray Produces the next
steps
output symbols.Negative values may be passed which reverses the direction of the shift registers and produces outputs in reverse order.
Examples¶
Step the Fibonacci LFSR one output at a time. Notice the first
outputs of a Fibonacci LFSR are its state reversed.In [1]: c = galois.primitive_poly(7, 4) In [2]: lfsr = galois.FLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr Out[2]: <Fibonacci LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 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. Notice the output and ending state are the same from the Scalar output tab.
In [9]: c = galois.primitive_poly(7, 4) In [10]: lfsr = galois.FLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr Out[10]: <Fibonacci LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 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 10 steps forward.
In [14]: c = galois.primitive_poly(7, 4) In [15]: lfsr = galois.FLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr Out[15]: <Fibonacci LFSR: f(x) = 5x^4 + 3x^3 + x^2 + 1 over GF(7)> In [16]: lfsr.state Out[16]: GF([1, 2, 3, 4], order=7) In [17]: lfsr.step(10) Out[17]: GF([4, 3, 2, 1, 4, 6, 4, 5, 0, 2], order=7) In [18]: lfsr.state Out[18]: GF([3, 1, 1, 0], order=7)
Step the Fibonacci LFSR 10 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 [19]: lfsr.step(-10) Out[19]: GF([2, 0, 5, 4, 6, 4, 1, 2, 3, 4], order=7) In [20]: lfsr.state Out[20]: GF([1, 2, 3, 4], order=7)