Skip to content

Commit

Permalink
fix reset in ahbl monitor and add scoreboard minimum number of checking
Browse files Browse the repository at this point in the history
M0stafaRady committed May 9, 2024

Verified

This commit was signed with the committer’s verified signature.
asoto-iov Angel Soto
1 parent 3597450 commit 87c544a
Showing 3 changed files with 38 additions and 3 deletions.
7 changes: 7 additions & 0 deletions base_test.py
Original file line number Diff line number Diff line change
@@ -82,6 +82,13 @@ def end_of_elaboration_phase(self, phase):
UVM_LOW,
)

def update_min_checkers(self, num_checkers):
"""update min number of checker the scoreboard should have done for the tests
the default is 50
"""
self.top_env.scoreboard.update_min_checkers(num_checkers)
# TODO: try this again not working

def start_of_simulation_phase(self, phase):
self.bus_sqr = self.top_env.bus_env.bus_agent.bus_sequencer
self.ip_sqr = self.top_env.ip_env.ip_agent.ip_sequencer
12 changes: 9 additions & 3 deletions bus_env/bus_agent/bus_ahb_monitor.py
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ async def run_phase(self, phase):
await self.assert_reset()
start_thread.kill()
self.active_reset = True
await self.deassert_reset()
self.active_reset = False
if self.data_phase_lock.locked:
self.data_phase_lock.release()

async def start(self):
while True:
@@ -32,8 +32,11 @@ async def start(self):
await NextTimeStep()
tr = bus_item.type_id.create("tr", self)
tr = await self.address_phase(tr)
uvm_info(self.tag, f"address_phase", UVM_LOW)
await self.data_phase_lock.acquire()
uvm_info(self.tag, f"acquired lock", UVM_LOW)
await cocotb.start(self.data_phase(tr))
uvm_info(self.tag, f"data_phase", UVM_LOW)

async def assert_reset(self):
await FallingEdge(self.vif.RESETn)
@@ -56,6 +59,8 @@ async def sample_delay(self):
async def address_phase(self, tr):
while True:
await self.sample_delay()
if self.vif.RESETn.value.binstr == "1":
self.active_reset = False
if self.vif.HSEL.value.binstr == "1":
if self.vif.HTRANS.value.binstr[0] == "1":
break
@@ -81,11 +86,12 @@ async def data_phase(self, tr):
self.tag, f"HRDATA is not an integer {self.vif.HRDATA.value.binstr}"
)
tr.data = self.vif.HRDATA.value.binstr
if self.data_phase_lock.locked:
self.data_phase_lock.release()
if self.active_reset:
return
self.monitor_port.write(tr)
uvm_info(self.tag, "sampled AHB transaction: " + tr.convert2string(), UVM_LOW)
self.data_phase_lock.release()
return tr


22 changes: 22 additions & 0 deletions scoreboard.py
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ def __init__(self, name="scoreboard", parent=None):
cocotb.scheduler.add(self.checker_bus())
cocotb.scheduler.add(self.checker_irq())
cocotb.scheduler.add(self.checker_ip())
self.compare_counter = 0

def build_phase(self, phase):
super().build_phase(phase)
@@ -83,6 +84,8 @@ async def checker_bus(self):
+ exp.convert2string(),
UVM_HIGH,
)
self.compare_counter += 1
self.min_compare_num = 50

def write_irq(self, tr):
uvm_info(self.tag, "write_irq: " + tr.convert2string(), UVM_HIGH)
@@ -107,6 +110,7 @@ async def checker_irq(self):
+ " != "
+ exp.convert2string(),
)
self.compare_counter += 1

def write_ip(self, tr):
uvm_info(self.tag, "write_ip: " + tr.convert2string(), UVM_HIGH)
@@ -137,6 +141,7 @@ async def checker_ip(self):
"IP match: " + val.convert2string() + " == " + exp.convert2string(),
UVM_HIGH,
)
self.compare_counter += 1

def extract_phase(self, phase):
super().extract_phase(phase)
@@ -156,6 +161,23 @@ def extract_phase(self, phase):
self.tag,
f"IP queue still have unchecked items queue ip {self.q_ip._queue} size {self.q_ip.qsize()} ip_ref_model {self.q_ip_ref_model._queue} size {self.q_ip_ref_model.qsize()}",
)
if self.compare_counter < self.min_compare_num:
uvm_error(
self.tag,
f"Not enough compares happened in scoreboard actual compares {self.compare_counter} minimum compares {self.min_compare_num}",
)
else:
uvm_info(
self.tag,
f"Scoreboard compare passed actual compares {self.compare_counter} minimum compares {self.min_compare_num}",
UVM_LOW,
)

def update_min_checkers(self, num_checkers):
"""update min number of checker the scoreboard should have done for the tests
the default is 50
"""
self.min_compare_num = num_checkers


uvm_component_utils(scoreboard)

0 comments on commit 87c544a

Please sign in to comment.