Creates a generator using the Galois linear feedback shift register
algorithm. The *size* corresponds to the entries in
:py:class:`hotmic.polynomials.all_polys`, which represents the bitspace of the
shift register. The *seed* is the initial value to pass to the algorithm.

def lfsr(size, seed=None):
    '''Creates a generator using the Galois linear feedback shift register
algorithm. The *size* corresponds to the entries in
:py:class:`hotmic.polynomials.all_polys`, which represents the bitspace of the
shift register. The *seed* is the initial value to pass to the algorithm.'''
    
    if not size in polynomials.all_polys:
        raise ValueError('bitsize not found in polynomial map')
    
    poly = polynomials.all_polys[size]

    if seed is None:
        seed = 0xACE1 & (2 ** size - 1)
        
    register = seed

    while 1:
        lsb = register & 1
        register >>= 1

        if lsb:
            register ^= poly

        yield register