The constructor of the ``Simulator`` object takes the following parameters:
#. The fragment to simulate. The fragment can (and generally does) contain both synthesizable code and a non-synthesizable list of simulation functions.
-#. A simulator runner object (see :ref:`simrunner`).
#. A top-level object (see :ref:`toplevel`). With the default value of ``None``, the simulator creates a default top-level object itself.
+#. A simulator runner object (see :ref:`simrunner`). With the default value of ``None``, Icarus Verilog is used with the default parameters.
#. The name of the UNIX domain socket used to communicate with the external simulator through the VPI plug-in (default: "simsocket").
#. Additional keyword arguments (if any) are passed to the Verilog conversion function.
from migen.actorlib.sim import *
from migen.bus import wishbone, asmibus
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
class MyModel:
def read(self, address):
+ tap.get_fragment() \
+ interconnect.get_fragment() \
+ Fragment(sim=[_end_simulation])
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run()
def asmi_sim(efragment, hub, end_simulation):
+ peripheral.get_fragment() \
+ tap.get_fragment() \
+ Fragment(sim=[_end_simulation])
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run()
def test_wb_reader():
from migen.actorlib import misc
from migen.actorlib.sim import *
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
def source_gen():
for i in range(10):
g.add_connection(loop, sink)
comp = CompositeActor(g)
fragment = comp.get_fragment()
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run(500)
main()
from migen.actorlib import structuring
from migen.actorlib.sim import *
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
from migen.flow import perftools
pack_factor = 5
reporter = perftools.DFGReporter(g)
fragment = comp.get_fragment() + reporter.get_fragment()
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run(1000)
g_layout = nx.spectral_layout(g)
from migen.actorlib.sim import *
from migen.pytholite.compiler import make_pytholite
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
from migen.fhdl import verilog
layout = [("r", 32)]
c = CompositeActor(g)
fragment = c.get_fragment()
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run(30)
del sim
from migen.pytholite.transel import Register
from migen.pytholite.compiler import make_pytholite
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
from migen.fhdl import verilog
layout = [("r", 32)]
c = CompositeActor(g)
fragment = slave.get_fragment() + intercon.get_fragment() + c.get_fragment()
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run(50)
del sim
from migen.bus.transactions import *
from migen.bus import wishbone, asmibus
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
# Our bus master.
# Python generators let us program bus transactions in an elegant sequential style.
def end_simulation(s):
s.interrupt = master.done
fragment = autofragment.from_local() + Fragment(sim=[end_simulation])
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run()
def test_asmi():
def end_simulation(s):
s.interrupt = master.done
fragment = autofragment.from_local() + Fragment(sim=[end_simulation])
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run()
test_wishbone()
from migen.fhdl.structure import *
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
# Our simple counter, which increments at every cycle
# and prints its current value in simulation.
def main():
dut = Counter()
- # Use the Icarus Verilog runner.
- # We do not specify a top-level object, and use the default.
- sim = Simulator(dut.get_fragment(), Runner())
+ # We do not specify a top-level nor runner object, and use the defaults.
+ sim = Simulator(dut.get_fragment())
# Since we do not use sim.interrupt, limit the simulation
# to some number of cycles.
sim.run(20)
from migen.fhdl.structure import *
from migen.sim.generic import Simulator, TopLevel
-from migen.sim.icarus import Runner
# A slightly improved counter.
# Has a clock enable (CE) signal, counts on more bits
dut = Counter()
# Instantiating the generic top-level ourselves lets us
# specify a VCD output file.
- sim = Simulator(dut.get_fragment(), Runner(), TopLevel("my.vcd"))
+ sim = Simulator(dut.get_fragment(), TopLevel("my.vcd"))
sim.run(20)
main()
from migen.flow.network import *
from migen.actorlib.sim import *
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
def source_gen():
for i in range(10):
def end_simulation(s):
s.interrupt = source.token_exchanger.done
fragment = comp.get_fragment() + Fragment(sim=[end_simulation])
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run()
main()
from migen.corelogic.misc import optree
from migen.fhdl import autofragment
from migen.sim.generic import Simulator, PureSimulable
-from migen.sim.icarus import Runner
# A synthesizable FIR filter.
class FIR:
for frequency in [0.05, 0.07, 0.1, 0.15, 0.2]:
tb = TB(fir, frequency)
fragment = autofragment.from_local()
- sim = Simulator(fragment, Runner())
+ sim = Simulator(fragment)
sim.run(100)
del sim
in_signals += tb.inputs
from migen.fhdl.structure import *
from migen.sim.generic import Simulator
-from migen.sim.icarus import Runner
class Mem:
def __init__(self):
def main():
dut = Mem()
- sim = Simulator(dut.get_fragment(), Runner())
+ sim = Simulator(dut.get_fragment())
# No need for a cycle limit here, we use sim.interrupt instead.
sim.run()
from migen.fhdl.structure import *
from migen.fhdl import verilog
from migen.sim.ipc import *
+from migen.sim import icarus
class TopLevel:
def __init__(self, vcd_name=None, vcd_level=1,
return r
class Simulator:
- def __init__(self, fragment, sim_runner, top_level=None, sockaddr="simsocket", **vopts):
- self.fragment = fragment
+ def __init__(self, fragment, top_level=None, sim_runner=None, sockaddr="simsocket", **vopts):
if top_level is None:
- self.top_level = TopLevel()
- else:
- self.top_level = top_level
+ top_level = TopLevel()
+ if sim_runner is None:
+ sim_runner = icarus.Runner()
+ self.fragment = fragment
+ self.top_level = top_level
self.ipc = Initiator(sockaddr)
+ self.sim_runner = sim_runner
c_top = self.top_level.get(sockaddr)