Source code for FIREQ_LL_API.axi_stream_switch_driver
"""Low-level driver for the FIREQ trigger generator IP."""
import logging
from pynq import DefaultIP
__all__ = ["AXIStreamSwitchDriver"]
[docs]
class AXIStreamSwitchDriver(DefaultIP):
"""Driver class for the switch IP.
Provides methods to set the direction of the switch.
"""
bindto = ["xilinx.com:ip:axis_switch:1.1"]
# register offsets
_ctrl = 0x00
_mi_mux = 0x40
# mask to commit changes
_commit_mask = 0x00000002
def __init__(self, description: dict[str, object]) -> None:
"""Initialize the AXIStreamSwitchDriver.
:param description: Dictionary containing IP parameters and configuration
:type description: dict
"""
super().__init__(description=description)
self.log = logging.getLogger(__name__)
self.number_of_slaves = int(description["parameters"]["NUM_SI"])
self.number_of_masters = int(description["parameters"]["NUM_MI"])
if self.number_of_masters > 1:
raise NotImplementedError("only one master is supported for data switches")
[docs]
def set_logger(self, new_logger: logging.Logger) -> None:
"""Set the logger for this object.
:param new_logger: Logger object to use
:type new_logger: logging.Logger
"""
self.log = new_logger
@property
def slave_number_to_interface_map(self) -> dict:
"""The map between the slave number sand the slave interface name."""
slave_map = {}
for i in range(self.number_of_slaves):
# the slave interface is S00_AXIS, S01_AXIS, S02_AXIS, etc.
slave_map[i] = f"S{i:02d}_AXIS"
return slave_map