Last active
August 29, 2015 13:57
-
-
Save debugger22/9531898 to your computer and use it in GitHub Desktop.
N Bit Ripple Counter Example
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
from __future__ import print_function | |
from BinPy.tools import Clock | |
from BinPy.Sequential.counters import NBitRippleCounter | |
from BinPy.Gates import Connector | |
toggle = Connector(1) | |
# Initialize the clock with leading edge = 1 and frequency = 1000Hz | |
clock = Clock(init_state=1, frequency=1000) | |
clock.start() #Start the clock | |
clk_conn = clock.A #Clock.A provides the connector of the clock | |
enable = Connector(1) | |
# Initialize the counter | |
counter = NBitRippleCounter(4, clk_conn) | |
print ("INITIAL STATE") | |
print (counter.state()) | |
print ("TRIGGERING THE COUNTER SEQUENTIALLY 2^4 + 1 times") | |
for i in range(1, 2 ** 4 + 1): | |
print (counter.state()) | |
counter.trigger() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment