Exemplo n.º 1
0
from __future__ import print_function
from BinPy.tools.digital import Clock
from BinPy.Sequential.counters import NBitRippleCounter
from BinPy.Gates import Connector

toggle = Connector(1)

# Initialize the clock
clock = Clock(1, 100)
clock.start()
# A clock of 100 hertz frequency
clk_conn = clock.A

enable = Connector(1)

print("Setting No of Bits to 8")
print("Clock frequency is 100 Hz")

# Initializing the counter
b = NBitRippleCounter(8, clk_conn)

print("INITIAL STATE")
print(b.state())

print("TRIGGERING THE COUNTER SEQUENTIALLY 2^8 + 1 times")

for i in range(1, 2**8 + 1):
    b.trigger()
    print(b.state())
Exemplo n.º 2
0
print("clk_conn = clock.A")
clk_conn = clock.A
print("\n")

print("Initialize enable")
print("enable = Connector(1)")
enable = Connector(1)

print ("Setting No of Bits to 4")
print ("Clock frequency is 10 Hz")

# Initializing the counter
print("\n")
print("Initializing Ripple Counter with 4 bits and clock_conn")
print("b = NBitRippleCounter(4, clk_conn)")
b = NBitRippleCounter(4, clk_conn)

# Initiating the oscilloscope
print("\n")
print("Initializing the Oscillioscope")
print(
    "o = Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'BIT3'), (b.out[1], 'BIT2'), (\
    b.out[2], 'BIT1'), (b.out[3], 'BIT0'), (enable, 'EN1'))")
print("o.start() # starting the oscillioscope")
print("o.setScale(0.05) # setting the scale")
o = Oscilloscope((clk_conn, 'CLK'), (b.out[0], 'BIT3'), (b.out[1], 'BIT2'), (
    b.out[2], 'BIT1'), (b.out[3], 'BIT0'), (enable, 'EN1'))
o.start()
o.setScale(0.0005)  # Set scale by trial and error.
o.unhold()
Exemplo n.º 3
0
from __future__ import print_function
from BinPy.tools.digital import Clock
from BinPy.Sequential.counters import NBitRippleCounter
from BinPy.Gates import Connector

toggle = Connector(1)

# Initialize the clock
clock = Clock(1, 100)
clock.start()
# A clock of 100 hertz frequency
clk_conn = clock.A

enable = Connector(1)

print ("Setting No of Bits to 8")
print ("Clock frequency is 100 Hz")

# Initializing the counter
b = NBitRippleCounter(8,clk_conn)

print ("INITIAL STATE")
print (b.state())

print ("TRIGGERING THE COUNTER SEQUENTIALLY 2^8 + 1 times")

for i in range(1,2**8 + 1):
    b.trigger()
    print (b.state())