Skip to content

Commit

Permalink
Added sync options for txns performed by the master
Browse files Browse the repository at this point in the history
Signed-off-by: Anderson Ignacio <anderson@aignacio.com>
  • Loading branch information
aignacio committed Nov 14, 2023
1 parent 0605a0f commit 328d195
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions cocotbext/ahb/ahb_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License : MIT license <Check LICENSE>
# Author : Anderson I. da Silva (aignacio) <anderson@aignacio.com>
# Date : 08.10.2023
# Last Modified Date: 12.11.2023
# Last Modified Date: 14.11.2023

import cocotb
import logging
Expand Down Expand Up @@ -141,6 +141,7 @@ async def _send_txn(
mode: Sequence[AHBWrite],
trans: Sequence[AHBTrans],
pip: bool = False,
sync: bool = True
) -> Sequence[dict]:
"""Drives the AHB transaction into the bus."""
response = []
Expand All @@ -149,6 +150,11 @@ async def _send_txn(
index = 0
restart = False

# If sync, wait for one clock cycle before it starts
# useful when leaving out of reset
if sync:
await RisingEdge(self.clk)

while index < len(address):
txn_addr, txn_data, txn_size, txn_mode, txn_trans = (
address[index],
Expand Down Expand Up @@ -243,6 +249,7 @@ async def write(
value: Union[int, Sequence[int]],
size: Optional[Union[int, Sequence[int]]] = None,
pip: Optional[bool] = False,
sync: Optional[bool] = True
) -> Sequence[dict]:
"""Write data in the AHB bus."""

Expand Down Expand Up @@ -294,13 +301,14 @@ async def write(
width = len(self.bus.htrans)
t_trans = self._create_vector(t_trans, width, "address_ph", pip)

return await self._send_txn(t_address, t_value, t_size, t_mode, t_trans, pip)
return await self._send_txn(t_address, t_value, t_size, t_mode, t_trans, pip, sync)

async def read(
self,
address: Union[int, Sequence[int]],
size: Optional[Union[int, Sequence[int]]] = None,
pip: Optional[bool] = False,
sync: Optional[bool] = True
) -> Sequence[dict]:
"""Read data from the AHB bus."""

Expand Down Expand Up @@ -343,7 +351,7 @@ async def read(
width = len(self.bus.htrans)
t_trans = self._create_vector(t_trans, width, "address_ph", pip)

return await self._send_txn(t_address, t_value, t_size, t_mode, t_trans, pip)
return await self._send_txn(t_address, t_value, t_size, t_mode, t_trans, pip, sync)

async def custom(
self,
Expand All @@ -352,6 +360,7 @@ async def custom(
mode: Union[int, Sequence[int]],
size: Optional[Union[int, Sequence[int]]] = None,
pip: Optional[bool] = True,
sync: Optional[bool] = True
) -> Sequence[dict]:
"""Back-to-Back operation"""

Expand Down Expand Up @@ -401,7 +410,7 @@ async def custom(
width = len(self.bus.htrans)
t_trans = self._create_vector(t_trans, width, "address_ph", pip)

return await self._send_txn(t_address, t_value, t_size, t_mode, t_trans, pip)
return await self._send_txn(t_address, t_value, t_size, t_mode, t_trans, pip, sync)


class AHBMaster(AHBLiteMaster):
Expand Down
2 changes: 1 addition & 1 deletion cocotbext/ahb/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.1"
__version__ = "0.2.2"

0 comments on commit 328d195

Please sign in to comment.