add sync domain if it isn't already there, making it much easier to write tests
authorJacob Lifshay <programmerjake@gmail.com>
Mon, 4 Jul 2022 06:16:29 +0000 (23:16 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Mon, 4 Jul 2022 06:16:29 +0000 (23:16 -0700)
src/nmutil/sim_util.py

index 018564c18b44930f0d1004429da3600a9d6450ea..373f4b9ca656d27de32bd2d9abf87d3db6d5b6e5 100644 (file)
@@ -7,7 +7,7 @@
 from contextlib import contextmanager
 from hashlib import sha256
 
-from nmigen.hdl.ir import Fragment
+from nmigen.hdl.ir import Fragment, ClockDomain
 from nmutil.get_test_path import get_test_path
 from nmigen.sim import Simulator
 from nmigen.back.rtlil import convert
@@ -24,6 +24,8 @@ def hash_256(v):
 def do_sim(test_case, dut, traces=(), ports=None):
     # only elaborate once, cuz users' stupid code breaks if elaborating twice
     dut = Fragment.get(dut, platform=None)
+    if "sync" not in dut.domains:
+        dut.add_domains(ClockDomain("sync"))
     sim = Simulator(dut)
     path = get_test_path(test_case, "sim_test_out")
     path.parent.mkdir(parents=True, exist_ok=True)