compat: add run_simulation shim.
This commit is contained in:
parent
88970ee29f
commit
17d26c8329
|
@ -5,7 +5,7 @@ from .fhdl.bitcontainer import *
|
||||||
# from .fhdl.decorators import *
|
# from .fhdl.decorators import *
|
||||||
# from .fhdl.simplify import *
|
# from .fhdl.simplify import *
|
||||||
|
|
||||||
# from .sim import *
|
from .sim import *
|
||||||
|
|
||||||
# from .genlib.record import *
|
# from .genlib.record import *
|
||||||
from .genlib.fsm import *
|
from .genlib.fsm import *
|
||||||
|
|
24
nmigen/compat/sim/__init__.py
Normal file
24
nmigen/compat/sim/__init__.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from ...back.pysim import *
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["run_simulation"]
|
||||||
|
|
||||||
|
|
||||||
|
def run_simulation(fragment_or_module, generators, clocks={"sync": 10}, vcd_name=None,
|
||||||
|
special_overrides={}):
|
||||||
|
assert not special_overrides
|
||||||
|
|
||||||
|
if hasattr(fragment_or_module, "get_fragment"):
|
||||||
|
fragment = fragment_or_module.get_fragment().get_fragment(platform=None)
|
||||||
|
else:
|
||||||
|
fragment = fragment_or_module
|
||||||
|
|
||||||
|
if not isinstance(generators, dict):
|
||||||
|
generators = {"sync": generators}
|
||||||
|
|
||||||
|
with Simulator(fragment, vcd_file=open(vcd_name, "w") if vcd_name else None) as sim:
|
||||||
|
for domain, period in clocks.items():
|
||||||
|
sim.add_clock(period, domain)
|
||||||
|
for domain, process in generators.items():
|
||||||
|
sim.add_sync_process(process, domain)
|
||||||
|
sim.run()
|
Loading…
Reference in a new issue