Skip to content

Commit

Permalink
Merge pull request #11 from andreaskuster/add_verilator_support
Browse files Browse the repository at this point in the history
Add verilator support
  • Loading branch information
andreaskuster authored Mar 4, 2022
2 parents c88f0d4 + 0225f5a commit b439dcc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
wheel==0.37.1
cocotb==1.6.1
cocotb-bus==0.1.1
git+https://github.com/andreaskuster/cocotb-test@4beff202c36313957e2e558888bff92d0818c79b # fixes coverage support, PR pending (https://github.com/themperek/cocotb-test/pull/172)
cocotbext-axi==0.1.18
gprof2dot==2021.2.21
Expand Down
4 changes: 2 additions & 2 deletions src/axi_io_pmp.sv
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ module axi_io_pmp #(
) i_axi_demux (
.clk_i,
.rst_ni,
.test_i (testmode_i),
.test_i (devmode_i),
.slv_aw_select_i(allow_w),
.slv_ar_select_i(allow_r),
.slv_req_i (slv_req_i),
Expand All @@ -345,7 +345,7 @@ module axi_io_pmp #(
) i_axi_err_slv (
.clk_i,
.rst_ni,
.test_i (testmode_i),
.test_i (devmode_i),
.slv_req_i (error_req),
.slv_resp_o(error_rsp)
);
Expand Down
13 changes: 6 additions & 7 deletions tests/test_axi_io_pmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ async def set_pmp_napot(tb, base: int, length: int, access: bitarray, pmp_no: in
conf: bitarray = locked + reserved + mode + access
tb.log.info("PMP cfg: %s", conf.to01())
# address
PMP_LEN = tb.dut.i_axi_io_pmp.PMP_LEN.value
napot_addr = int(base + (length / 2 - 1)) >> 2
tb.log.info("PMP NAPOT addr: %s", int2ba(napot_addr, PMP_LEN).to01())

Expand Down Expand Up @@ -255,7 +254,7 @@ async def run_test_bounds(dut, base: int = 0, length: int = 2 ** 12):



async def run_test_prio(dut, base: int = 0, length: int = 64):
async def run_test_prio(dut, base: int = 0, length: int = 64, PMP_NUM: int = 16):
"""
Test the PMP priority scheme (i.e. port 0 (max) to port 15 (min)) by stacking a fixed memory region on top of each
other, once locked and once unlocked
Expand All @@ -269,7 +268,6 @@ async def run_test_prio(dut, base: int = 0, length: int = 64):
access_none = PMPAccess.ACCESS_NONE.value

# loop over all slots
PMP_NUM = tb.dut.i_axi_io_pmp.NR_ENTRIES.value
lock = False
for i in reversed(range(PMP_NUM)):
# write config
Expand Down Expand Up @@ -360,7 +358,7 @@ def cycle_pause():

@pytest.mark.parametrize("data_width", [64]) # [8, 16, 32, 64, 128]
@pytest.mark.parametrize("addr_width", [64]) # [32, 64]
@pytest.mark.parametrize("simulator", ["icarus"]) # ["icarus", "verilator", "questa"]
@pytest.mark.parametrize("simulator", ["icarus", "verilator"]) # ["icarus", "verilator", "questa"]
def test_axi_io_pmp(request, simulator, addr_width, data_width):
"""
TODO
Expand Down Expand Up @@ -430,7 +428,7 @@ def test_axi_io_pmp(request, simulator, addr_width, data_width):

# toplevel
"axi_io_pmp.sv",
f"{dut}.sv",
f"../tb/{dut}.sv",
]
verilog_sources = list(map(lambda x: os.path.join(src_dir, x), verilog_sources))

Expand Down Expand Up @@ -471,7 +469,8 @@ def test_axi_io_pmp(request, simulator, addr_width, data_width):
sim.compile_args += ["-Wno-UNOPT", "-Wno-TIMESCALEMOD", "-Wno-CASEINCOMPLETE", "-Wno-WIDTH", "-Wno-SELRANGE",
"-Wno-CMPCONST", "-Wno-UNSIGNED"]
sim.verilog_sources = verilog_sources

sim.compile_args += ["--trace", "--coverage"]
sim.simulation_args += ["--timescale 1ns/1ns"]
elif simulator == "questa":
sim = cocotb_test.simulator.Questa(
toplevel=toplevel,
Expand Down Expand Up @@ -522,7 +521,7 @@ def test_axi_io_pmp(request, simulator, addr_width, data_width):
raise NotImplementedError(f"Simulator {simulator} not implemented")

# add wave generation
parameters["WAVES"] = 1
parameters["WAVES"] = 0

sim.python_search = [tests_dir]
sim.toplevel = toplevel
Expand Down

0 comments on commit b439dcc

Please sign in to comment.