-
galois.GLFSR.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 Galois LFSR one output at a time.
In [1]: c = galois.primitive_poly(7, 4) In [2]: lfsr = galois.GLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr Out[2]: <Galois 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([1, 3, 5, 3], order=7), GF(3, order=7)) In [5]: lfsr.state, lfsr.step() Out[5]: (GF([6, 6, 0, 5], order=7), GF(5, order=7)) In [6]: lfsr.state, lfsr.step() Out[6]: (GF([3, 5, 1, 0], order=7), GF(0, order=7)) In [7]: lfsr.state, lfsr.step() Out[7]: (GF([0, 3, 5, 1], order=7), GF(1, order=7)) # Ending state In [8]: lfsr.state Out[8]: GF([2, 4, 2, 5], order=7)
Step the Galois 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.GLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr Out[10]: <Galois 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, 5, 0, 1], order=7) # Ending state In [13]: lfsr.state Out[13]: GF([2, 4, 2, 5], order=7)
Step the Galois LFSR 10 steps forward.
In [14]: c = galois.primitive_poly(7, 4) In [15]: lfsr = galois.GLFSR(c.reverse(), state=[1, 2, 3, 4]); lfsr Out[15]: <Galois 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, 5, 0, 1, 5, 2, 6, 6, 5], order=7) In [18]: lfsr.state Out[18]: GF([3, 4, 3, 1], order=7)
Step the Galois 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([5, 6, 6, 2, 5, 1, 0, 5, 3, 4], order=7) In [20]: lfsr.state Out[20]: GF([1, 2, 3, 4], order=7)