1 # SPDX-License-Identifier: LGPL-3-or-later
2 # Copyright 2021 Jacob Lifshay
4 # Funded by NLnet Assure Programme 2021-02-052, https://nlnet.nl/assure part
5 # of Horizon 2020 EU Programme 957073.
7 from contextlib
import contextmanager
8 from hashlib
import sha256
9 from nmutil
.get_test_path
import get_test_path
10 from nmigen
.sim
import Simulator
14 return int.from_bytes(
15 sha256(bytes(v
, encoding
='utf-8')).digest(),
21 def do_sim(test_case
, dut
, traces
=()):
23 path
= get_test_path(test_case
, "sim_test_out")
24 path
.parent
.mkdir(parents
=True, exist_ok
=True)
25 vcd_path
= path
.with_suffix(".vcd")
26 gtkw_path
= path
.with_suffix(".gtkw")
27 with sim
.write_vcd(vcd_path
.open("wt", encoding
="utf-8"),
28 gtkw_path
.open("wt", encoding
="utf-8"),