Skip to content

Commit

Permalink
send response to the bus sequence from driver
Browse files Browse the repository at this point in the history
  • Loading branch information
M0stafaRady committed Apr 17, 2024
1 parent 1a869fe commit c7523fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bus_env/bus_agent/bus_ahb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ async def data_phase(self, tr):
await self.drive_delay()
while self.vif.HREADYOUT == 0:
await self.drive_delay()
tr.data = self.vif.HRDATA.value.integer
self.seq_item_port.put_response(tr)

def end_of_trans(self):
self.vif.HSEL.value = 0b00
Expand Down
13 changes: 8 additions & 5 deletions bus_env/bus_agent/bus_apb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,35 @@ async def run_phase(self, phase):
# uvm_do_callbacks(apb_master,apb_master_cbs,trans_received(self,tr))

if tr.kind == bus_item.READ:
data = []
await self.read(tr.addr, data)
tr.data = data[0]
tr.data = await self.read(tr.addr)
elif tr.kind == bus_item.WRITE:
await self.write(tr.addr, tr.data)

await self.trans_executed(tr)
# uvm_do_callbacks(apb_master,apb_master_cbs,trans_executed(self,tr))
self.seq_item_port.item_done()
self.seq_item_port.put_response(tr)

async def trans_received(self, tr):
await Timer(1, "NS")

async def trans_executed(self, tr):
await Timer(1, "NS")

async def read(self, addr, data):
async def read(self, addr):
uvm_info(self.tag, "Doing APB read to addr " + hex(addr), UVM_HIGH)
self.vif.PADDR.value = addr
self.vif.PWRITE.value = 0
self.vif.PSEL.value = 1
await self.drive_delay()
self.vif.PENABLE.value = 1
await self.drive_delay()
data.append(self.vif.PRDATA)
try:
data = self.vif.PRDATA.value.integer
except TypeError or ValueError:
data = self.vif.PRDATA.value
self.end_of_trans()
return data

async def write(self, addr, data):
uvm_info(self.tag, "Doing APB write to addr " + hex(addr), UVM_HIGH)
Expand Down
7 changes: 6 additions & 1 deletion bus_env/bus_agent/bus_wb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ async def run_phase(self, phase):
await self.drive_delay()
self.seq_item_port.item_done()
continue
await self.send_trans(tr)
tr.data = await self.send_trans(tr)
self.seq_item_port.item_done()
self.seq_item_port.put_response(tr)

async def send_trans(self, tr):
if tr.kind == bus_item.READ:
Expand All @@ -49,6 +50,10 @@ async def send_trans(self, tr):
while self.vif.ack_o.value == 0:
await self.drive_delay()
self.end_of_trans()
if tr.kind == bus_item.READ:
return self.vif.dat_o.value.integer
else:
return tr.data

def end_of_trans(self):
self.vif.sel_i.value = 0b0000
Expand Down

0 comments on commit c7523fd

Please sign in to comment.