1 # SPDX-License-Identifier: LGPL-3-or-later
2 # See Notices.txt for copyright information
4 from contextlib
import contextmanager
5 from hashlib
import sha256
6 from nmutil
.get_test_path
import get_test_path
7 from nmigen
.sim
import Simulator
11 return int.from_bytes(
12 sha256(bytes(v
, encoding
='utf-8')).digest(),
18 def do_sim(test_case
, dut
, traces
=()):
20 path
= get_test_path(test_case
, "sim_test_out")
21 path
.parent
.mkdir(parents
=True, exist_ok
=True)
22 vcd_path
= path
.with_suffix(".vcd")
23 gtkw_path
= path
.with_suffix(".gtkw")
24 with sim
.write_vcd(vcd_path
.open("wt", encoding
="utf-8"),
25 gtkw_path
.open("wt", encoding
="utf-8"),