1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00

35 lines
716 B
Python
Raw Normal View History

2003-05-25 12:21:36 +00:00
from __future__ import generators
2015-03-04 22:11:50 +01:00
from __future__ import print_function
2003-05-25 12:21:36 +00:00
from myhdl import Signal, Simulation, Cosimulation
from myhdl import delay, intbv, now
2003-05-25 12:27:09 +00:00
import os
2005-10-03 15:49:36 +00:00
cmd = "iverilog -o tb_test.o ./tb_test.v "
2003-05-25 12:27:09 +00:00
os.system(cmd)
2003-05-25 12:21:36 +00:00
a = Signal(intbv(1))
b = Signal(intbv(2))
c = Signal(intbv(3))
2005-10-03 15:49:36 +00:00
cosim = Cosimulation("vvp -v -m ../myhdl.vpi tb_test.o", a=a, b=b, c=c)
2003-05-25 12:21:36 +00:00
def stimulus(a, b):
for i in range(10):
yield delay(10)
# print "Python a=%s b=%s" % (a, b)
a.next = a + 1
b.next = b + 2
def response(c):
while 1:
yield c
2015-03-04 22:11:50 +01:00
print("Python: %s %s %s %s" % (now(), c, a, b))
2003-05-25 12:21:36 +00:00
sim = Simulation(stimulus(a=a, b=b), response(c=c), cosim)
sim.run()