-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoxfile.py
400 lines (338 loc) · 11.8 KB
/
noxfile.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# SPDX-License-Identifier: Apache-2.0
import os
import random
import time
import nox
from nox_utils import VerificationTest, isCocotbSimFailure, nox_config
# Common nox configuration
nox = nox_config(nox)
# If you need to override default configuration, you can do it here:
# nox.options.<option> = <value>
# Test configuration
pip_requirements_path = "../../requirements.txt"
# Coverage types to collect
coverage_types = ["all", "branch", "toggle"] if os.getenv("TEST_COVERAGE_ENABLE") else None
simulators = [os.getenv("SIMULATOR", "verilator")]
def _verify(session, test_group, test_type, test_name, coverage=None, simulator=None):
# session.install("-r", pip_requirements_path)
test = VerificationTest(test_group, test_type, test_name, coverage)
# Randomize seed for initialization of undefined signals in the simulation
random.seed(time.time_ns())
seed = random.randint(1, 10000)
with open(test.paths["log_default"], "w") as test_log:
args = [
"make",
"-C",
test.testPath,
"all",
"MODULE=" + test_name,
"COCOTB_RESULTS_FILE=" + test.filenames["xml"],
]
if simulator == "verilator":
args.append(
"PLUSARGS="
+ " ".join(
[
"+verilator+rand+reset+2",
f"+verilator+seed+{seed}",
]
)
)
if coverage:
args.append("COVERAGE_TYPE=" + coverage)
if simulator:
args.append("SIM=" + simulator)
session.run(
*args,
external=True,
stdout=test_log,
stderr=test_log,
)
# Prevent coverage.dat and test log from being overwritten
test.rename_defaults(coverage)
# Add check from results.xml to notify nox that test failed
isTBFailure = isCocotbSimFailure(resultsFile=test.paths["xml"])
if isTBFailure:
raise Exception("SimFailure: cocotb failed. See test logs for more information.")
def verify_block(session, test_group, test_name, coverage=None, simulator=None):
_verify(session, test_group, "block", test_name, coverage, simulator)
def verify_top(session, test_group, test_name, coverage=None, simulator=None):
_verify(session, test_group, "top", test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb"])
@nox.parametrize("test_group", ["ahb_if"])
@nox.parametrize(
"test_name",
[
"test_csr_sw_access",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def ahb_if_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "axi"])
@nox.parametrize("test_group", ["axi_adapter"])
@nox.parametrize(
"test_name",
[
"test_csr_sw_access",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def axi_adapter_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["bus_rx_flow"])
@nox.parametrize(
"test_name",
[
"test_bus_rx_flow",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def bus_rx_flow_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["bus_tx"])
@nox.parametrize(
"test_name",
[
"test_bus_tx",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def bus_tx_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["bus_tx_flow"])
@nox.parametrize(
"test_name",
[
"test_bus_tx_flow",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def bus_tx_flow_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb"])
@nox.parametrize("test_group", ["hci_queues_ahb"])
@nox.parametrize(
"test_name",
[
"test_clear",
"test_empty",
"test_read_write_ports",
"test_threshold",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def hci_queues_ahb_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "axi"])
@nox.parametrize("test_group", ["hci_queues_axi"])
@nox.parametrize(
"test_name",
[
"test_clear",
"test_empty",
"test_read_write_ports",
"test_threshold",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def hci_queues_axi_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
# TODO: reenable test
# @nox.session(tags=["tests"])
# @nox.parametrize("test_group", ["i2c"])
# @nox.parametrize(
# "test_name",
# [
# "test_write",
# ],
# )
# @nox.parametrize("coverage", coverage_types)
# @nox.parametrize("simulator", simulators)
# def i2c_verify(session, test_group, test_name, coverage, simulator):
# verify_block(session, test_group, test_name, coverage, simulator)
# TODO: reenable i2c test after connecting configuration.sv to CSRs
# @nox.session(tags=["tests"])
# @nox.parametrize("test_group", ["i2c_controller_fsm"])
# @nox.parametrize(
# "test_name",
# [
# "test_mem_rw",
# ],
# )
# @nox.parametrize("coverage", coverage_types)
# @nox.parametrize("simulator", simulators)
# def i2c_controller_fsm_verify(session, test_group, test_name, coverage, simulator):
# verify_block(session, test_group, test_name, coverage, simulator)
# TODO: fix tests
# @nox.session(tags=["tests"])
# @nox.parametrize("test_group", ["i2c_standby_controller"])
# @nox.parametrize(
# "test_name",
# ["test_read", "test_wr_restart_rd"],
# )
# @nox.parametrize("coverage", coverage_types)
# @nox.parametrize("simulator", simulators)
# def i2c_standby_controller_verify(session, test_group, test_name, coverage, simulator):
# verify_block(session, test_group, test_name, coverage, simulator)
# TODO: fix tests
# @nox.session(tags=["tests"])
# @nox.parametrize("test_group", ["i2c_target_fsm"])
# @nox.parametrize(
# "test_name",
# ["test_mem_w", "test_mem_r"],
# )
# @nox.parametrize("coverage", coverage_types)
# @nox.parametrize("simulator", simulators)
# def i2c_target_fsm_verify(session, test_group, test_name, coverage, simulator):
# verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb"])
@nox.parametrize("test_group", ["i3c_ahb"])
@nox.parametrize(
"test_name",
[
"test_i3c_target",
"test_recovery",
"test_interrupts",
# "test_enter_exit_hdr_mode",
"test_target_reset",
"test_ccc",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def i3c_ahb_verify(session, test_group, test_name, coverage, simulator):
verify_top(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "axi"])
@nox.parametrize("test_group", ["i3c_axi"])
@nox.parametrize(
"test_name",
[
"test_i3c_target",
"test_recovery",
# "test_enter_exit_hdr_mode",
"test_target_reset",
"test_ccc",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def i3c_axi_verify(session, test_group, test_name, coverage, simulator):
verify_top(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["ctrl_bus_timers"])
@nox.parametrize(
"test_name",
[
"test_bus_timers",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def ctrl_bus_timers_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["ctrl_bus_monitor"])
@nox.parametrize(
"test_name",
[
"test_bus_monitor",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def ctrl_bus_monitor_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["ctrl_edge_detector"])
@nox.parametrize(
"test_name",
[
"test_edge_detector",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def ctrl_edge_detector_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["i3c_phy_io"])
@nox.parametrize("simulator", ["icarus" if s == "verilator" else s for s in simulators])
@nox.parametrize(
"test_name",
[
"test_drivers",
],
)
@nox.parametrize("coverage", coverage_types)
def i3c_phy_io_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(reuse_venv=True)
def lint(session: nox.Session) -> None:
"""Options are defined in pyproject.toml and .flake8 files"""
# session.install("isort")
# session.install("flake8")
# session.install("black")
session.run("isort", ".", "../../tools")
# Specify config for black explicitly since it gets "lost" when calling black with multiple
# paths
session.run("black", "--config=pyproject.toml", ".", "../../tools")
session.run("flake8", ".", "../../tools")
@nox.session()
def test_lint(session: nox.Session) -> None:
# session.install("isort")
# session.install("flake8")
# session.install("black")
session.run("isort", "--check", ".", "../../tools")
# Specify config for black explicitly since it gets "lost" when calling black with multiple
# paths
session.run("black", "--config=pyproject.toml", "--check", ".", "../../tools")
session.run("flake8", ".", "../../tools")
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["width_converter_Nto8"])
@nox.parametrize(
"test_name",
[
"test_converter",
"test_flush",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def width_converter_Nto8_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["width_converter_8toN"])
@nox.parametrize(
"test_name",
[
"test_converter",
"test_flush",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def width_converter_8toN_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)
@nox.session(tags=["tests", "ahb", "axi"])
@nox.parametrize("test_group", ["recovery_pec"])
@nox.parametrize(
"test_name",
[
"test_pec",
],
)
@nox.parametrize("coverage", coverage_types)
@nox.parametrize("simulator", simulators)
def recovery_pec_verify(session, test_group, test_name, coverage, simulator):
verify_block(session, test_group, test_name, coverage, simulator)