Skip to content

Commit

Permalink
Split init/reset bus methods
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 15, 2023
1 parent d394b13 commit 4288070
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions cocotbext/ahb/ahb_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
clock: str,
reset: str,
timeout: int = 100,
def_val: Union[int, str] = "Z",
def_val: Union[int, str] = 0, # Can be set to "Z",
name: str = "ahb_lite",
**kwargs,
):
Expand All @@ -51,11 +51,17 @@ def _init_bus(self) -> None:
if signal not in ["hready", "hresp", "hrdata"]:
sig = getattr(self.bus, signal)
try:
default_value = self._get_def(len(sig))
sig.value = default_value
# setimmediatevalue seems to not work with some designs
# decided to move to normal assign
# sig.setimmediatevalue(default_value)
sig.setimmediatevalue(self._get_def(len(sig)))
except AttributeError:
pass

def _reset_bus(self) -> None:
"""Initialize the bus with default value."""
for signal in self.bus._signals:
if signal not in ["hready", "hresp", "hrdata"]:
sig = getattr(self.bus, signal)
try:
sig.value = self._get_def(len(sig))
except AttributeError:
pass

Expand Down Expand Up @@ -167,7 +173,7 @@ async def _send_txn(
trans[index],
)
if index == len(address) - 1:
self._init_bus()
self._reset_bus()
else:
self._addr_phase(txn_addr, txn_size, txn_mode, txn_trans)
if txn_addr != self.def_val:
Expand Down Expand Up @@ -243,7 +249,7 @@ async def _send_txn(
first_txn = True
restart = False

self._init_bus()
self._reset_bus()
return response

async def write(
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.3"
__version__ = "0.2.4"

0 comments on commit 4288070

Please sign in to comment.