-
Notifications
You must be signed in to change notification settings - Fork 72
/
test_dff_custom_sim.py
71 lines (56 loc) · 1.9 KB
/
test_dff_custom_sim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from cocotb_test.simulator import Icarus, Ius, run
import pytest
import os
import cocotb
hdl_dir = os.path.dirname(__file__)
class IcarusCustom(Icarus):
def __init__(self, logfile, *argv, **kwargs):
self.logfile = logfile
super().__init__(*argv, **kwargs)
def run_command(self):
return (
["vvp", "-v", "-l", self.logfile, "-M", self.lib_dir, "-m", cocotb.config.lib_name("vpi", "icarus")]
+ self.simulation_args
+ [self.sim_file]
+ self.plus_args
)
@pytest.fixture(scope="module", autouse=True)
def module_run_at_beginning(request):
print("\n\nIn module_run_at_beginning()\n\n")
def module_run_at_end():
print("\n\nIn module_run_at_end()\n\n")
request.addfinalizer(module_run_at_end)
@pytest.mark.skipif(os.getenv("SIM") != "icarus", reason="Custom for Icarus")
def test_dff_custom_icarus():
IcarusCustom(
verilog_sources=[os.path.join(hdl_dir, "dff.sv")],
toplevel="dff_test",
python_search=[hdl_dir],
module="dff_cocotb",
logfile="custom_log.log", # extra custom argument
).run()
class IusCustom(Ius):
def __init__(self, defsfile, *argv, **kwargs):
self.defsfile = defsfile
super().__init__(*argv, **kwargs)
def build_command(self):
cmd = [
"xrun",
"-loadvpi",
os.path.join(self.lib_dir, "libvpi." + self.lib_ext) + ":vlog_startup_routines_bootstrap",
"-plinowarn",
"-access",
"+rwc",
"-f",
self.defsfile,
]
return [cmd]
@pytest.mark.skipif(os.getenv("SIM") != "ius", reason="Custom for IUS")
def test_dff_custom_ius():
IusCustom(
verilog_sources=[os.path.join(hdl_dir, "dff.sv")],
toplevel="dff_test",
python_search=[hdl_dir],
module="dff_cocotb",
defsfile="ius_defines.f"
)