test.compat: import tests from Migen as appropriate.
test_signed and test_coding are adjusted slightly to account for differences in comb propagation between the simulators; we might want to revert that eventually.
This commit is contained in:
parent
f71e0fffbb
commit
4922a73c5d
11 changed files with 403 additions and 5 deletions
|
|
@ -1,7 +1,10 @@
|
|||
import functools
|
||||
import collections
|
||||
import inspect
|
||||
from ...back.pysim import *
|
||||
|
||||
|
||||
__all__ = ["run_simulation"]
|
||||
__all__ = ["run_simulation", "passive"]
|
||||
|
||||
|
||||
def run_simulation(fragment_or_module, generators, clocks={"sync": 10}, vcd_name=None,
|
||||
|
|
@ -19,6 +22,18 @@ def run_simulation(fragment_or_module, generators, clocks={"sync": 10}, vcd_name
|
|||
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 / 1e9, domain=domain)
|
||||
for domain, process in generators.items():
|
||||
sim.add_sync_process(process, domain=domain)
|
||||
for domain, processes in generators.items():
|
||||
if isinstance(processes, collections.Iterable) and not inspect.isgenerator(processes):
|
||||
for process in processes:
|
||||
sim.add_sync_process(process, domain=domain)
|
||||
else:
|
||||
sim.add_sync_process(processes, domain=domain)
|
||||
sim.run()
|
||||
|
||||
|
||||
def passive(generator):
|
||||
@functools.wraps(generator)
|
||||
def wrapper(*args, **kwargs):
|
||||
yield Passive()
|
||||
yield from generator(*args, **kwargs)
|
||||
return wrapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue