Skip to content

Commit

Permalink
consider preadyout for apb monitor and driver
Browse files Browse the repository at this point in the history
  • Loading branch information
M0stafaRady committed Oct 1, 2024
1 parent 2cbae20 commit 13c8338
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bus_env/bus_agent/bus_apb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ async def read(self, addr):
self.vif.PSEL.value = 1
await self.drive_delay()
self.vif.PENABLE.value = 1
await self.drive_delay()
await self.wait_ready()
# await self.drive_delay()
try:
data = self.vif.PRDATA.value.integer
except TypeError or ValueError:
Expand All @@ -79,13 +80,16 @@ async def write(self, addr, data):
self.vif.PSEL.value = 1
await self.drive_delay()
self.vif.PENABLE.value = 1
await self.drive_delay()
await self.wait_ready()
# await self.drive_delay()
self.end_of_trans()
uvm_info(self.tag, "Finished APB write to addr " + hex(addr), UVM_HIGH)

def end_of_trans(self):
self.vif.PSEL.value = 0
self.vif.PENABLE.value = 0


async def wait_ready(self):
while self.vif.PREADY == 0:
await self.drive_delay()
uvm_component_utils(bus_apb_driver)
9 changes: 9 additions & 0 deletions bus_env/bus_agent/bus_apb_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class bus_apb_monitor(bus_base_monitor):
def __init__(self, name="bus_apb_monitor", parent=None):
super().__init__(name, parent)
self.counter = 0

async def run_phase(self, phase):
await cocotb.start(self.watch_reset())
Expand All @@ -34,6 +35,7 @@ async def run_phase(self, phase):
self.tag,
f"APB protocol violation: SETUP cycle not followed by ENABLE cycle PENABLE={self.vif.PENABLE.value.binstr}",
)
await self.wait_ready()
if tr.kind == bus_item.WRITE:
tr.data = self.vif.PWDATA.value.integer
else:
Expand All @@ -46,6 +48,9 @@ async def run_phase(self, phase):
)
tr.data = self.vif.PRDATA.value.binstr
self.monitor_port.write(tr)
self.counter += 1
# if self.counter > 40:
# uvm_fatal(self.tag, "sampled too many transactions")
# update reg value #TODO: move this to the ref_model later
# self.regs.write_reg_value(tr.addr, tr.data)
uvm_info(
Expand All @@ -68,5 +73,9 @@ async def sample_delay(self):
await RisingEdge(self.vif.CLK)
# await Timer(1, "NS")

async def wait_ready(self):
while self.vif.PREADY == 0:
await self.sample_delay()


uvm_component_utils(bus_apb_monitor)

0 comments on commit 13c8338

Please sign in to comment.