mirror of
https://github.com/romanz/amodem.git
synced 2026-02-25 00:31:08 +08:00
dsp: pre-compute polynome bit_length
since Python 2.6 has no .bit_length() method
This commit is contained in:
@@ -114,9 +114,13 @@ class MODEM(object):
|
||||
def prbs(reg, poly, bits):
|
||||
''' Simple pseudo-random number generator. '''
|
||||
mask = (1 << bits) - 1
|
||||
|
||||
size = 0 # effective register size (in bits)
|
||||
while (poly >> size) > 1:
|
||||
size += 1
|
||||
|
||||
while True:
|
||||
yield reg & mask
|
||||
reg = reg << 1
|
||||
size = poly.bit_length() - 1
|
||||
if reg >> size:
|
||||
reg = reg ^ poly
|
||||
|
||||
Reference in New Issue
Block a user