comment about max_exponent, remove its use: use python slice [:-1]
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 22 Apr 2019 20:58:26 +0000 (21:58 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 23 Apr 2019 08:30:13 +0000 (09:30 +0100)
slice [:-1] is the python way to not need explicit length
it is already in self.state, so no need to do self.max_exponent-1
just use -1

TLB/src/LFSR.py

index c850d5fb9501166cc9c347c207bc4d978a21b6fd..d0c6322775fdfb049dc0242afbacc1f731ca0352 100644 (file)
@@ -70,7 +70,8 @@ class LFSR(LFSRPolynomial):
 
             Outputs:
             -------
-            :state: the LFSR state.  length is taken from the polynomial
+            :state: the LFSR state.  bitwidth is taken from the polynomial
+                    maximum exponent.
 
             Note: if an LFSRPolynomial is passed in as the input, because
             LFSRPolynomial is derived from set() it's ok:
@@ -95,7 +96,7 @@ class LFSR(LFSRPolynomial):
         # if enabled, shift-and-feedback
         with m.If(self.enable):
             # shift up lower bits by Cat'ing in a new bit zero (feedback)
-            newstate = Cat(feedback, self.state[0:self.max_exponent - 1])
+            newstate = Cat(feedback, self.state[:-1])
             m.d.sync += self.state.eq(newstate)
 
         return m