Last active
August 29, 2015 14:20
-
-
Save hgomersall/350a007980972a75859c to your computer and use it in GitHub Desktop.
myhdl working multiple sim instances
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 myhdl import * | |
a = Signal(intbv(0)[5:]) | |
clock = Signal(False) | |
reset = ResetSignal(False, active=True, async=False) | |
def clockgen(clock): | |
@instance | |
def clkgen(): | |
while True: | |
yield delay(10) | |
clock.next = not clock | |
return clkgen | |
def stimulus(a, clock, reset): | |
data = [0] | |
@always(clock.posedge, reset) | |
def stimulus_inst(): | |
a.next = data[0] | |
data[0] += 1 | |
return stimulus_inst | |
def printer(a, clock, reset): | |
@always_seq(clock.posedge, reset) | |
def printer_inst(): | |
print now(), a | |
return printer_inst | |
sim1 = Simulation([clockgen(clock), stimulus(a, clock, reset), | |
printer(a, clock, reset)]) | |
sim1.run(100) | |
sim2 = Simulation([clockgen(clock), stimulus(a, clock, reset), | |
printer(a, clock, reset)]) | |
sim2.run(200) | |
sim1.run(200) | |
sim2.run(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For reference, myhdl 0.9 will output: