Created
March 13, 2014 17:02
-
-
Save debugger22/9532439 to your computer and use it in GitHub Desktop.
NBitRippleCounter Code
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
class NBitRippleCounter(Counter): | |
""" | |
An N-Bit Ripple Counter | |
""" | |
def __init__( | |
self, | |
bits, | |
clock_connector, | |
set=Connector(0), | |
reset=Connector(0), | |
data=0): | |
# All the output bits are initialized to this data bit | |
Counter.__init__(self, bits, clock_connector, set, reset, data) | |
# Calling the super class constructor | |
self.ff[ | |
self.bits - | |
1] = TFlipFlop( | |
self.t, | |
self.enable, | |
self.clk, | |
self.out[ | |
self.bits - | |
1], | |
self.outinv[ | |
self.bits - | |
1], | |
self.set, | |
self.reset) | |
for i in range(self.bits - 1): | |
self.ff[i] = TFlipFlop( | |
self.t, | |
self.enable, | |
self.out[ | |
i + 1], | |
self.out[i], | |
self.outinv[i], | |
self.set, | |
self.reset) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment