Skip to content

Commit

Permalink
tests: pmp: Fix monitor logic for checking channels' values
Browse files Browse the repository at this point in the history
Internal-Tag: [#52259]
Signed-off-by: Robert Szczepanski <rszczepanski@antmicro.com>
  • Loading branch information
robertszczepanski committed Dec 6, 2023
1 parent ef54246 commit 3710b16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
5 changes: 3 additions & 2 deletions verification/block/pmp/test_address_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, name):
super().__init__(name)

async def body(self):
test_iterations = ConfigDB().get(None, "", "TEST_ITERATIONS")
pmp_entries = ConfigDB().get(None, "", "PMP_ENTRIES")

# Ensure to not use more configurations than PMP entries
Expand Down Expand Up @@ -119,8 +120,8 @@ async def body(self):

await self.checkRangeBoundary(end_addr)

# In the end check 1000 accesses at random memory locations
for _ in range(1000):
# In the end check accesses at random memory locations
for _ in range(test_iterations):
await self.randomAccessInAddrRange(0x00000000, 0xFFFFFFFF)


Expand Down
3 changes: 2 additions & 1 deletion verification/block/pmp/test_multiple_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, name):
super().__init__(name)

async def body(self):
test_iterations = ConfigDB().get(None, "", "TEST_ITERATIONS")
pmp_entries = ConfigDB().get(None, "", "PMP_ENTRIES")

# Ensure to not use more configurations than PMP entries
Expand All @@ -82,7 +83,7 @@ async def body(self):
await self.pmp_seqr.finish_item(item)

self.checkRangeBoundary(LOWER_BOUNDARY)
for _ in range(1000):
for _ in range(test_iterations):
await self.randomAccessInAddrRange(LOWER_BOUNDARY, UPPER_BOUNDARY)
self.checkRangeBoundary(UPPER_BOUNDARY)

Expand Down
39 changes: 6 additions & 33 deletions verification/block/pmp/testbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ def __init__(self, *args, **kwargs):

self.pmp_channels = ConfigDB().get(None, "", "PMP_CHANNELS")
self.pmp_entries = ConfigDB().get(None, "", "PMP_ENTRIES")
self.prev_addr = [None for _ in range(self.pmp_channels)]
self.prev_type = [None for _ in range(self.pmp_channels)]
self.prev_err = [None for _ in range(self.pmp_channels)]
self.prev_pmpcfg = [None for _ in range(self.pmp_entries)]
self.prev_pmpaddr = [None for _ in range(self.pmp_entries)]

def build_phase(self):
self.ap = uvm_analysis_port("ap", self)
Expand All @@ -206,35 +201,13 @@ async def run_phase(self):
while True:
await RisingEdge(self.clk)

# Sample signals
# Check all PMP channels
for i in range(self.pmp_channels):
curr_addr = int(self.pmp_chan_addr[i].value)
curr_type = int(self.pmp_chan_type[i].value)
curr_err = int(self.pmp_chan_err.value[i])
access_addr = int(self.pmp_chan_addr[i].value)
access_type = int(self.pmp_chan_type[i].value)
access_err = int(self.pmp_chan_err.value[i])

# Send an item in case of a change
if (
self.prev_err[i] != curr_err
or self.prev_addr[i] != curr_addr
or self.prev_type[i] != curr_type
):
self.ap.write(PMPCheckItem(i, curr_addr, curr_type, curr_err))

self.prev_err[i] = curr_err
self.prev_addr[i] = curr_addr
self.prev_type[i] = curr_type

# If any PMP entry has changed, check all PMP channels
for i in range(self.pmp_entries):
curr_pmpcfg = int(self.pmp_pmpcfg[i].value)
curr_pmpaddr = int(self.pmp_pmpaddr[i].value)

if (curr_pmpcfg != self.prev_pmpcfg[i]) or (curr_pmpaddr != self.prev_pmpaddr[i]):
for j in range(self.pmp_channels):
self.ap.write(PMPCheckItem(j, curr_addr, curr_type, curr_err))

self.prev_pmpcfg[i] = curr_pmpcfg
self.prev_pmpaddr[i] = curr_pmpaddr
self.ap.write(PMPCheckItem(i, access_addr, access_type, access_err))


# ==============================================================================
Expand Down Expand Up @@ -323,7 +296,7 @@ def build_phase(self):
ConfigDB().set(None, "*", "PMP_GRANULARITY", 0)

ConfigDB().set(None, "*", "TEST_CLK_PERIOD", 1)
ConfigDB().set(None, "*", "TEST_ITERATIONS", 50)
ConfigDB().set(None, "*", "TEST_ITERATIONS", 100)

# PMP Registers
self.regs = RegisterMap(pmp_entries)
Expand Down

0 comments on commit 3710b16

Please sign in to comment.