Skip to content
Snoopy87 edited this page Nov 14, 2017 · 3 revisions

There are two type of Linear-feedback-shift-register (LFSR) :

  • Fibonacci
  • Galois

Fibonacci

LFSR Fibonacci

Examples

import spinal.crypto.misc.LFSR

// LFSR with XOR and period (2^n-1)
val reg = Reg(Bits(8 bits)) init(10)
reg := LFSR.Fibonacci(reg, p"x^8 + x^6 + x^5 + x^4 + 1") // feedback polynomial 
reg := LFSR.Fibonacci(reg, Seq(8, 6, 5, 4))              // taps


// LFSR with XNOR and the periods extended (2^n)
val reg1 = Reg(Bits(8 bits)) init(10)
reg1 := LFSR.Fibonacci(reg1, p"x^8 + x^6 + x^5 + x^4 + 1", LFSR.XNOR, extendsPeriod = true)

Galois

LFSR Galois

Examples

import spinal.crypto.misc.LFSR

// LFSR with XOR and period (2^n-1)
val reg = Reg(Bits(8 bits)) init(10)
reg := LFSR.Galois(reg, p"x^8 + x^6 + x^5 + x^4 + 1") // feedback polynomial 
reg := LFSR.Galois(reg, Seq(8, 6, 5, 4))              // taps

// LFSR with XNOR and the periods extended (2^n)
val reg1 = Reg(Bits(8 bits)) init(10)
reg1 := LFSR.Galois(reg1, p"x^8 + x^6 + x^5 + x^4 + 1", LFSR.XNOR, extendsPeriod = true)
Clone this wiki locally