Add support for using non-compat Elaboratable instances with compat.fhdl.verilog.convert and compat.run_simulation
Fixes #344
This commit is contained in:
parent
6e1145e2e7
commit
995f3a147b
3 changed files with 36 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ from ...hdl.ir import Fragment
|
|||
from ...hdl.cd import ClockDomain
|
||||
from ...back import verilog
|
||||
from .conv_output import ConvOutput
|
||||
from .module import Module
|
||||
|
||||
|
||||
def convert(fi, ios=None, name="top", special_overrides=dict(),
|
||||
|
|
@ -17,11 +18,14 @@ def convert(fi, ios=None, name="top", special_overrides=dict(),
|
|||
DeprecationWarning, stacklevel=1)
|
||||
# TODO: attr_translate
|
||||
|
||||
if isinstance(fi, Module):
|
||||
fi = fi.get_fragment()
|
||||
|
||||
def missing_domain(name):
|
||||
if create_clock_domains:
|
||||
return ClockDomain(name)
|
||||
v_output = verilog.convert(
|
||||
elaboratable=fi.get_fragment(),
|
||||
elaboratable=fi,
|
||||
name=name,
|
||||
ports=ios or (),
|
||||
missing_domain=missing_domain
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import inspect
|
|||
from collections.abc import Iterable
|
||||
from ...hdl.cd import ClockDomain
|
||||
from ...back.pysim import *
|
||||
from ...hdl.ir import Fragment
|
||||
|
||||
|
||||
__all__ = ["run_simulation", "passive"]
|
||||
|
|
@ -17,9 +18,12 @@ def run_simulation(fragment_or_module, generators, clocks={"sync": 10}, vcd_name
|
|||
else:
|
||||
fragment = fragment_or_module
|
||||
|
||||
fragment = Fragment.get(fragment, platform=None)
|
||||
|
||||
if not isinstance(generators, dict):
|
||||
generators = {"sync": generators}
|
||||
fragment.domains += ClockDomain("sync")
|
||||
if "sync" not in fragment.domains:
|
||||
fragment.add_domains(ClockDomain("sync"))
|
||||
|
||||
sim = Simulator(fragment)
|
||||
for domain, period in clocks.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue