def prbs(reg, poly, bits):
    ''' Simple pseudo-random number generator. '''
    mask = 1 - (1 << bits)

    size = 0  # effective register size (in bits)
    while (poly >> size) > 1:
        size += 1

    while True:
        yield reg & mask
        reg = reg << 1
        if reg >> size:
            reg = reg ^ poly
dataset/ETHPy150Open romanz/amodem/amodem/dsp.py/prbs/swapped operands of `-`