From 335175e6ee70719f8e81a772f24f71054e698f13 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 3 Jul 2022 23:16:29 -0700 Subject: [PATCH] add sync domain if it isn't already there, making it much easier to write tests --- src/nmutil/sim_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) -- 2.30.2