From: Luke Kenneth Casson Leighton Date: Mon, 22 Apr 2019 20:54:47 +0000 (+0100) Subject: derive LFSR from LFSRPolynomial - cut even more code X-Git-Tag: div_pipeline~2152 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0177d3ea7c482036c4879a7f4217aa693536ef2e;p=soc.git derive LFSR from LFSRPolynomial - cut even more code --- diff --git a/TLB/src/LFSR2.py b/TLB/src/LFSR2.py index 4a44dfdf..e0c3d972 100644 --- a/TLB/src/LFSR2.py +++ b/TLB/src/LFSR2.py @@ -58,7 +58,7 @@ LFSR_POLY_23 = LFSRPolynomial([23, 18, 0]) LFSR_POLY_24 = LFSRPolynomial([24, 23, 22, 17, 0]) -class LFSR: +class LFSR(LFSRPolynomial): """ implements a Linear Feedback Shift Register """ def __init__(self, polynomial): @@ -76,14 +76,11 @@ class LFSR: LFSRPolynomial is derived from set() it's ok: LFSRPolynomial(LFSRPolynomial(p)) == LFSRPolynomial(p) """ - self.polynomial = LFSRPolynomial(polynomial) + LFSRPolynomial.__init__(self, polynomial) + self.width = self.max_exponent self.state = Signal(self.width, reset=1) self.enable = Signal(reset=1) - @property - def width(self): - return self.polynomial.max_exponent - def elaborate(self, platform): m = Module() # do absolutely nothing if the polynomial is empty (always has a zero) @@ -92,7 +89,7 @@ class LFSR: # create XOR-bunch, select bits from state based on exponent feedback = Const(0) # doesn't do any harm starting from 0b0 (xor chain) - for exponent in self.polynomial: + for exponent in self: if exponent > 0: # don't have to skip, saves CPU cycles though feedback ^= self.state[exponent - 1]