import numpy as np
from numpy import *
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
from matplotlib import animation


# 8 bit lfsr
# taps at 2, 3, 4 and 8

# taps = [2, 3, 4, 8]
order = 11
taps = [0,10] #subtract 1
repeat = np.power(2,order)-2
x = 1
nums = []
nums.append(x)
for i in range(repeat*10):	
	# bit = (((x >> (taps[0]-1)) ^ (x >> (taps[1]-1)) ^ (x >> (taps[2]-1)) ^ (x >> (taps[3]-1))) & 1)
	bit = (((x >> (taps[0])) ^ (x >> (taps[1]))) & 1)
	x = (x>>1) | (bit << order-1)

	print(bin(x))
	number = int(x)
	nums.append(number)
	# print(x)

fig = plt.figure()
# plt.plot(arange(1024),nums,'o')
plt.hist(nums,10)
plt.show()