Skip to content

Commit

Permalink
Added verbose switch for the read/write AHB
Browse files Browse the repository at this point in the history
Signed-off-by: Anderson Ignacio da Silva <anderson@aignacio.com>
  • Loading branch information
aignacio committed Oct 1, 2024
1 parent 5ded336 commit ff34ac1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
28 changes: 16 additions & 12 deletions cocotbext/ahb/ahb_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# License : MIT license <Check LICENSE>
# Author : Anderson I. da Silva (aignacio) <anderson@aignacio.com>
# Date : 08.10.2023
# Last Modified Date: 01.10.2024

# Last Modified Date: 02.10.2024
import logging
import cocotb
import copy
Expand Down Expand Up @@ -152,6 +151,7 @@ async def _send_txn(
mode: Sequence[AHBWrite],
trans: Sequence[AHBTrans],
pip: bool = False,
verbose: bool = False,
sync: bool = False,
) -> Sequence[dict]:
"""Drives the AHB transaction into the bus."""
Expand Down Expand Up @@ -192,13 +192,14 @@ async def _send_txn(
if txn_id != "BUBBLE":
if not isinstance(txn_addr, LogicArray):
op = "write" if txn_mode == 1 else "read"
self.log.info(
f"AHB {op} txn:\n"
f"\tID = {txn_id}\n"
f"\tADDR = 0x{txn_addr:x}\n"
f"\tDATA = 0x{value[index + 1]:x}\n"
f"\tSIZE = {txn_size} bytes"
)
if verbose is True:
self.log.info(
f"AHB {op} txn:\n"
f"\tID = {txn_id}\n"
f"\tADDR = 0x{txn_addr:x}\n"
f"\tDATA = 0x{value[index + 1]:x}\n"
f"\tSIZE = {txn_size} bytes"
)
self.bus.hwdata.value = txn_data
if self.bus.hready_in_exist:
self.bus.hready_in.value = 1
Expand Down Expand Up @@ -272,6 +273,7 @@ async def write(
value: Union[int, Sequence[int]],
size: Optional[Union[int, Sequence[int]]] = None,
pip: Optional[bool] = False,
verbose: Optional[bool] = False,
sync: Optional[bool] = False,
) -> Sequence[dict]:
"""Write data in the AHB bus."""
Expand Down Expand Up @@ -327,14 +329,15 @@ async def write(
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, sync
t_address, t_value, t_size, t_mode, t_trans, pip, verbose, sync
)

async def read(
self,
address: Union[int, Sequence[int]],
size: Optional[Union[int, Sequence[int]]] = None,
pip: Optional[bool] = False,
verbose: Optional[bool] = False,
sync: Optional[bool] = False,
) -> Sequence[dict]:
"""Read data from the AHB bus."""
Expand Down Expand Up @@ -379,7 +382,7 @@ async def read(
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, sync
t_address, t_value, t_size, t_mode, t_trans, pip, verbose, sync
)

async def custom(
Expand All @@ -389,6 +392,7 @@ async def custom(
mode: Union[int, Sequence[int]],
size: Optional[Union[int, Sequence[int]]] = None,
pip: Optional[bool] = True,
verbose: Optional[bool] = False,
sync: Optional[bool] = False,
) -> Sequence[dict]:
"""Back-to-Back operation"""
Expand Down Expand Up @@ -440,7 +444,7 @@ async def custom(
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, sync
t_address, t_value, t_size, t_mode, t_trans, pip, verbose, sync
)


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.4.2"
__version__ = "0.4.3"
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
keywords=["soc", "vip", "hdl", "verilog", "systemverilog", "ahb"],
classifiers=[
"Development Status :: 1 - Planning",
"Development Status :: 3 - Alpha",
"Framework :: cocotb"
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit ff34ac1

Please sign in to comment.