1 from migen
.fhdl
.structure
import *
2 from migen
.sim
.generic
import Simulator
, TopLevel
3 from migen
.sim
.icarus
import Runner
8 self
.count
= Signal(BV(4))
10 def do_simulation(self
, s
, cycle
):
15 print("Cycle: " + str(cycle
) + " Count: " + str(s
.rd(self
.count
)))
17 def get_fragment(self
):
18 sync
= [If(self
.ce
, self
.count
.eq(self
.count
+ 1))]
19 sim
= [self
.do_simulation
]
20 return Fragment(sync
=sync
, sim
=sim
)
24 sim
= Simulator(dut
.get_fragment(), Runner(), TopLevel("my.vcd"))