Skip to content

Instantly share code, notes, and snippets.

@debugger22
Created March 13, 2014 17:02
Show Gist options
  • Save debugger22/9532439 to your computer and use it in GitHub Desktop.
Save debugger22/9532439 to your computer and use it in GitHub Desktop.
NBitRippleCounter Code
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