Skip to content

Commit

Permalink
Merge pull request #3 from Thomasb81/fix
Browse files Browse the repository at this point in the history
AHBBus improvement - Included an option to map bus signals to a custom dict
  • Loading branch information
aignacio committed Nov 12, 2023
2 parents 2dbf993 + c80f5df commit 5908129
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,46 @@ class AHBBus(Bus):

* hexokay

##### Signal customization for your design
To customize signals name to your design `signals` and `optional_signals` dictionnary can be provide.
```python
AHBBus.from_prefix(
dut,
prefix = "slave_driver",
signals = {
"haddr" : "haddr",
"hsize" : "hsize",
"htrans" : "htrans",
"hwdata" : "hwdata",
"hrdata" : "hrdata",
"hwrite" : "hwrite",
"hready" : "hreadyout",
"hresp" : "hresp"
}
,
optional_signals = {
"hsel" : "hsel",
"hready_in" : "hready"
}
)
```

#### Mandatory vs optional AHB signals

1. AHB Master signals

##### Mandatory

* haddr - Indicates AHB txn address
* hsize - Indicates AHB txn size
* htrans - Indicates AHB txn type
* hwdata - Indicates AHB data to be written
* hwrite - Indicates type of AHB txn

##### Optional

* hburst

### AHB Master

Both AHB Master [WIP] and AHB Lite Master classes have the same constructor arguments. Within the arguments, it is required to pass the AHB Bus object, the clock and reset DUT pins. As optional args, a timeout value in clock cycles (per AHB txn), the default value of the master driven IOs and the name of the object.
Expand Down
20 changes: 17 additions & 3 deletions cocotbext/ahb/ahb_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ class AHBBus(Bus):

def __init__(self, entity: SimHandleBase = None,
prefix: str = None, **kwargs: Any) -> None:
super().__init__(entity, prefix, self._signals,
optional_signals=self._optional_signals, **kwargs)

name = prefix if prefix is not None else entity._name + '_ahb_bus'

#Handle default signals or signals overrided at an upper level
if "signals" not in kwargs:
kwargs["signals"] = self._signals
else:
entity._log.info(f"AHB ({name}) master use provided signals mapping")

#Handle default optional_signals or optional_signals overrided at an upper level
if "optional_signals" not in kwargs:
kwargs["optional_signals"] = self._signals
else:
entity._log.info(f"AHB ({name}) master use provided optional_signals mapping")

super().__init__(entity, prefix, **kwargs)
self.entity = entity
self.name = prefix if prefix is not None else entity._name + '_ahb_bus'
self.name = name
self._data_width = len(self.hwdata)
self._addr_width = len(self.haddr)

Expand Down

0 comments on commit 5908129

Please sign in to comment.