- galois.GLFSR.to_fibonacci_lfsr() FLFSR
Converts the Galois LFSR to a Fibonacci LFSR that produces the same output.
- Returns:¶
An equivalent Fibonacci LFSR.
Examples¶
Create a Galois LFSR with a given initial state.
In [1]: c = galois.primitive_poly(7, 4); c Out[1]: Poly(x^4 + x^2 + 3x + 5, GF(7)) In [2]: galois_lfsr = galois.GLFSR(c.reverse(), state=[1, 2, 3, 4]) In [3]: print(galois_lfsr) Galois LFSR: field: GF(7) feedback_poly: 5x^4 + 3x^3 + x^2 + 1 characteristic_poly: x^4 + x^2 + 3x + 5 taps: [2 4 6 0] order: 4 state: [1 2 3 4] initial_state: [1 2 3 4]
Convert the Galois LFSR to an equivalent Fibonacci LFSR. Notice the initial state is different.
In [4]: fibonacci_lfsr = galois_lfsr.to_fibonacci_lfsr() In [5]: print(fibonacci_lfsr) Fibonacci LFSR: field: GF(7) feedback_poly: 5x^4 + 3x^3 + x^2 + 1 characteristic_poly: x^4 + x^2 + 3x + 5 taps: [0 6 4 2] order: 4 state: [0 5 3 4] initial_state: [0 5 3 4]
Step both LFSRs and see that their output sequences are identical.
In [6]: galois_lfsr.step(10) Out[6]: GF([4, 3, 5, 0, 1, 5, 2, 6, 6, 5], order=7) In [7]: fibonacci_lfsr.step(10) Out[7]: GF([4, 3, 5, 0, 1, 5, 2, 6, 6, 5], order=7)