Exemplo n.º 1
0
from __future__ import print_function
from BinPy.tools.digital import Clock
from BinPy.Gates import Connector
from BinPy.tools.multivibrator import Multivibrator
from BinPy.tools.oscilloscope import Oscilloscope
import time

# MODE selects the mode of operation of the multivibrator.

# Mode No. :  Description
#   1          Monostable
#   2          Astable
#   3          Bistable

out = Connector(0)

# MODE 3

m = Multivibrator(0, mode=3)

m.start()
m.setOutput(out)

o = Oscilloscope((m.A, 'OUT'))
o.start()
o.setScale(0.05)
o.unhold()

time.sleep(0.1)
m.trigger()
print(m.A())
Exemplo n.º 2
0
# <headingcell level=2>

# Example for TFlipFlop

# <codecell>

from __future__ import print_function
from BinPy.Sequential.sequential import TFlipFlop
from BinPy.tools.clock import Clock
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

# <codecell>

toggle = Connector(1)

p = Connector(0)
q = Connector(1)

# <codecell>

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

enable = Connector(1)

# <codecell>
Exemplo n.º 3
0
# Example for JKFlipFlop

from __future__ import print_function
from BinPy.Sequential.sequential import JKFlipFlop
from BinPy.tools.digital import Clock
from BinPy.Gates import Connector

j = Connector(1)
k = Connector(0)

p = Connector(0)
q = Connector(1)

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

enable = Connector(1)

jkff = JKFlipFlop(j, k, enable, clk_conn, enable)

# To connect outputs use s.setOutputs(op1,op2)
jkff.setOutputs(A=p, B=q)

print("SET STATE - J = 1, K = 0")
# Set State
j.state = 1
k.state = 0
# The same thing can also be done by --> jkff.setInputs(j = 1, k = 0)
Exemplo n.º 4
0
# Example for N Bit Binary Ripple Counter.

from __future__ import print_function
from BinPy.tools.digital import Clock
from BinPy.Sequential.counters import NBitRippleCounter
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

print("Initialize a toggle connectr for inpput in TFlipFlop")
print("toggle = Connector(1)")
toggle = Connector(1)

print("Initializing the Clock")
print("clock = Clock(1, 50)")
print("clock.start()")
clock = Clock(1, 50)
clock.start()
# A clock of 100 hertz frequency
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")
Exemplo n.º 5
0
from BinPy.Sequential.counters import RingCounter
from BinPy.Gates import Connector

print("Initializing the Clock")
print("clock = Clock(1, 50)")
print("clock.start()")
clock = Clock(1, 50)
clock.start()
# A clock of 100 hertz frequency
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 RingCounter with 8 bits and clock_conn")
print("b = RingCounter(8, clk_conn)")
b = RingCounter(8, clk_conn)

print("Initial State")
print(b.state())

print("Triggering the counter 8 times")
print("for i in range(8):\nb.trigger()\nprint (b.state())")
Exemplo n.º 6
0
# <headingcell level=2>

# Example for TFlipFlop

# <codecell>

from __future__ import print_function
from BinPy.Sequential.sequential import TFlipFlop
from BinPy.tools.clock import Clock
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

# <codecell>

toggle = Connector(1)

p = Connector(0)
q = Connector(1)

# <codecell>

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

enable = Connector(1)

# <codecell>
Exemplo n.º 7
0
# <headingcell level=2>

# Example for DFlipFlop

# <codecell>

from __future__ import print_function
from BinPy.Sequential.sequential import DFlipFlop
from BinPy.tools.clock import Clock
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

# <codecell>

data = Connector(1)

p = Connector(0)
q = Connector(1)

# <codecell>

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

enable = Connector(1)

# <codecell>
Exemplo n.º 8
0
# Example for DFlipFlop

from __future__ import print_function
from BinPy.Sequential.sequential import DFlipFlop
from BinPy.tools.digital import Clock
from BinPy.Gates import Connector

data = Connector(1)

p = Connector(0)
q = Connector(1)

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

enable = Connector(1)

# Initialize the D-FlipFlop
dff = DFlipFlop(data, enable, clk_conn, p, q)
# To connect different set of connectors use :
# dff.setInputs(conn1,enab,clk)
# To connect different outputs use s.setOutputs(op1,op2)
dff.setOutputs(A=p, B=q)

print ("Data is 1")
data.state = 1
while True:
    if clk_conn.state == 0:
Exemplo n.º 9
0
# <headingcell level=2>

# Example for SRLatch

# <codecell>

from __future__ import print_function
from BinPy.Sequential.sequential import SRLatch
from BinPy.tools.clock import Clock
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

# <codecell>

s = Connector(1)
r = Connector(0)

p = Connector(0)
q = Connector(1)

# <codecell>

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

enable = Connector(1)
Exemplo n.º 10
0
# <headingcell level=2>

# Example for JKFlipFlop

# <codecell>

from __future__ import print_function
from BinPy.Sequential.sequential import JKFlipFlop
from BinPy.tools.clock import Clock
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

# <codecell>

j = Connector(1)
k = Connector(0)

p = Connector(0)
q = Connector(1)

# <codecell>

# Initialize the clock
clock = Clock(1, 4)
clock.start()

# A clock of 4 hertz frequency initialized to 1
clk_conn = clock.A

enable = Connector(1)
Exemplo n.º 11
0
# Example for SRLatch

from __future__ import print_function
from BinPy.Sequential.sequential import SRLatch
from BinPy.tools.digital import Clock
from BinPy.Gates import Connector
from BinPy.tools.oscilloscope import Oscilloscope

s = Connector(1)
r = Connector(0)

p = Connector(0)
q = Connector(1)

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

enable = Connector(1)

# Initialize the sr latch
srff = SRLatch(s, r, enable, clk_conn)

# To connect outputs use s.setOutputs(op1,op2)
srff.setOutputs(A=p, B=q)

o = Oscilloscope((clk_conn, 'CLK'), (s, 'S'), (
    r, 'R'), (p, 'OUT'), (q, 'OUT!'), (enable, 'ENABLE'))
o.start()