tff.setOutputs(A=p, B=q) # <codecell> # Initialize the oscilloscope o = Oscilloscope((clk_conn, 'CLK'), (toggle, 'TOGGLE'), ( p, 'OUT'), (q, 'OUT!'), (enable, 'ENABLE')) o.start() o.setScale(0.01) # Set scale by trial and error. o.setWidth(100) o.unhold() # <codecell> print ("Toggle is 1") toggle.state = 1 while True: if clk_conn.state == 0: # Falling edge will trigger the FF tff.trigger() break print (tff.state()) # Sending a positive edge to ff while True: if clk_conn.state == 1: # Falling edge will trigger the FF tff.trigger() break # <codecell>
tff.setOutputs(A=p, B=q) # <codecell> # Initialize the oscilloscope o = Oscilloscope((clk_conn, 'CLK'), (toggle, 'TOGGLE'), (p, 'OUT'), (q, 'OUT!'), (enable, 'ENABLE')) o.start() o.setScale(0.01) # Set scale by trial and error. o.setWidth(100) o.unhold() # <codecell> print("Toggle is 1") toggle.state = 1 while True: if clk_conn.state == 0: # Falling edge will trigger the FF tff.trigger() break print(tff.state()) # Sending a positive edge to ff while True: if clk_conn.state == 1: # Falling edge will trigger the FF tff.trigger() break # <codecell>
# 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) while True: if clk_conn.state == 0: # Falling edge will trigger the FF jkff.trigger() break print(jkff.state()) # Sending a positive edge to jkff while True: if clk_conn.state == 1: # Falling edge will trigger the FF jkff.trigger() break
dff.setOutputs(A=p, B=q) # <codecell> # Initiating the oscilloscope o = Oscilloscope((clk_conn, 'CLK'), (data, 'DATA'), (p, 'OUT'), (q, 'OUT!'), (enable, 'ENABLE')) o.start() o.setScale(0.01) # Set scale by trial and error. o.setWidth(100) o.unhold() # <codecell> print("Data is 1") data.state = 1 while True: if clk_conn.state == 0: # Falling edge will trigger the FF dff.trigger() break print(dff.state()) # Sending a positive edge to dff while True: if clk_conn.state == 1: # Falling edge will trigger the FF dff.trigger() break # <codecell>
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: # Falling edge will trigger the FF dff.trigger() break print (dff.state()) # Sending a positive edge to dff while True: if clk_conn.state == 1: # Falling edge will trigger the FF dff.trigger() break print ("Data is 0")
# <codecell> # Initialize the oscilloscope o = Oscilloscope((clk_conn, 'CLK'), (s, 'S'), (r, 'R'), (p, 'OUT'), (q, 'OUT!'), (enable, 'ENABLE')) o.start() o.setScale(0.015) # Set scale by trial and error. o.setWidth(100) o.unhold() # <codecell> print("SET STATE - S = 1, R = 0") # Set State s.state = 1 r.state = 0 # The same thing can also be done by --> srff.setInputs(s = 1, r = 0) while True: if clk_conn.state == 0: # Falling edge will trigger the FF srff.trigger() break print(srff.state()) # Sending a positive edge to srff while True: if clk_conn.state == 1: # Falling edge will trigger the FF srff.trigger() break
# Initiating the oscilloscope o = Oscilloscope((clk_conn, 'CLK'), (j, 'J'), ( k, 'k'), (p, 'OUT'), (q, 'OUT!'), (enable, 'ENABLE')) o.start() o.setScale(0.02) # Set scale by trial and error. o.setWidth(100) o.unhold() # <codecell> 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) while True: if clk_conn.state == 0: # Falling edge will trigger the FF jkff.trigger() break print (jkff.state()) # Sending a positive edge to jkff while True: if clk_conn.state == 1: # Falling edge will trigger the FF jkff.trigger()
# 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() o.setScale(0.01) # Set scale by trial and error. o.unhold() print ("SET STATE - S = 1, R = 0") # Set State s.state = 1 r.state = 0 # The same thing can also be done by --> srff.setInputs(s = 1, r = 0) while True: if clk_conn.state == 0: # Falling edge will trigger the FF srff.trigger() break print (srff.state()) # Sending a positive edge to srff while True: if clk_conn.state == 1: # Falling edge will trigger the FF srff.trigger() break