-
Notifications
You must be signed in to change notification settings - Fork 488
/
benchmark.py
58 lines (43 loc) · 1.45 KB
/
benchmark.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
# Copyright cocotb contributors
# Licensed under the Revised BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-3-Clause
import sys
from pathlib import Path
from cocotb_tools.runner import get_runner
def build_and_run_matrix_multiplier(benchmark, sim):
hdl_toplevel_lang = "verilog"
build_args = []
test_args = []
if sim == "nvc":
build_args = ["--std=08"]
hdl_toplevel_lang = "vhdl"
proj_path = (
Path(__file__).resolve().parent.parent / "examples" / "matrix_multiplier"
)
sys.path.append(str(proj_path / "tests"))
if hdl_toplevel_lang == "verilog":
sources = [proj_path / "hdl" / "matrix_multiplier.sv"]
else:
sources = [
proj_path / "hdl" / "matrix_multiplier_pkg.vhd",
proj_path / "hdl" / "matrix_multiplier.vhd",
]
runner = get_runner(sim)
runner.build(
hdl_toplevel="matrix_multiplier",
sources=sources,
build_args=build_args,
)
@benchmark
def run_test():
runner.test(
hdl_toplevel="matrix_multiplier",
hdl_toplevel_lang=hdl_toplevel_lang,
test_module="test_matrix_multiplier",
test_args=test_args,
seed=123456789,
)
def test_matrix_multiplier_icarus(benchmark):
build_and_run_matrix_multiplier(benchmark, "icarus")
def test_matrix_multiplier_nvc(benchmark):
build_and_run_matrix_multiplier(benchmark, "nvc")