Beautify LFSR implementation

This commit is contained in:
andynoack
2020-03-23 16:46:09 +01:00
parent f0d50b3f8d
commit 36553b09e6

View File

@@ -332,14 +332,11 @@ class Encoding(object):
for i in range(0, clock):
# Determine first bit with polynomial
first_bit = -1
for j in range(len_pol - 1, 0, -1):
for j in range(len_pol - 1, -1, -1):
if poly[j] and self.lfsr_state[j]:
if first_bit == -1:
first_bit = True
else:
first_bit = not first_bit
if first_bit == -1:
first_bit = False
first_bit = True if first_bit == -1 else not first_bit
first_bit = False if first_bit == -1 else first_bit
# Clock
for j in range(len_pol - 1, 0, -1):
self.lfsr_state[j] = self.lfsr_state[j - 1]