From: Jacob Lifshay Date: Mon, 4 Jul 2022 06:16:29 +0000 (-0700) Subject: add sync domain if it isn't already there, making it much easier to write tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=335175e6ee70719f8e81a772f24f71054e698f13;p=nmutil.git add sync domain if it isn't already there, making it much easier to write tests --- diff --git a/src/nmutil/sim_util.py b/src/nmutil/sim_util.py index 018564c..373f4b9 100644 --- a/src/nmutil/sim_util.py +++ b/src/nmutil/sim_util.py @@ -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)