Last active
August 29, 2015 13:58
-
-
Save offlinemark/10041138 to your computer and use it in GitHub Desktop.
Generates the necessary flip flop inputs for a finite state machine with 3 bit state encodings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def ff(a, b): | |
if a == 0 and b == 0: | |
print '0 X', | |
elif a == 0 and b == 1: | |
print '1 X', | |
elif a == 1 and b == 0: | |
print 'X 1', | |
elif a == 1 and b == 1: | |
print 'X 0', | |
present = [(0, 0, 0), (0, 0, 0), (0, 0, 1), | |
(0, 0, 1), (0, 1, 0), (0, 1, 0), | |
(0, 1, 1), (0, 1, 1), (1, 0, 0), (1, 0, 0) | |
] | |
next = [(0, 1, 1), (1, 0, 0), (0, 0, 1), | |
(1, 0, 0), (0, 1, 0), (0, 0, 0), | |
(0, 0, 1), (0, 1, 0), (0, 1, 0), (0, 1, 1) | |
] | |
bag = zip(present, next) | |
for each in bag: | |
for i in range(3): | |
ff(each[0][i], each[1][i]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment