hololink::emulation::HSBEmulator
hololink::emulation::HSBEmulator
The HSBEmulator class represents the interface that a host application has to an HSB and acts as the emulation device’s controller.
It manages the DataPlane objects and the I2CController and all communication with the internal memory model; see AddressMemory for more details.
Constructors
HSBEmulator
Copy
Default
python:
hemu.HSBEmulator(config: hemu.HSBConfiguration = hemu.HSB_EMULATOR_CONFIG)
Construct a new HSBEmulator object with the specified configuration.
HSB_EMULATOR_CONFIG is roughly equivalent to a Lattice board.
HSB_LEOPARD_EAGLE_CONFIG is roughly equivalent to a Leopard Eagle board.
Parameters
The configuration of the emulator. Two fully populated options are provided in hsb_config.hpp: HSB_EMULATOR_CONFIG or HSB_LEOPARD_EAGLE_CONFIG.
Destructor
~HSBEmulator
Methods
start
Start the emulator.
This will start the BootP broadcasting via the DataPlane objects as well as the control thread to listen for control messages from the host.
It is safe to call this function multiple times and after a subsequent call to stop()
stop
Stop the emulator.
This will shut down the control message thread, all BootP broadcasts in DataPlane objects. Data transmission is still possible until HSBEmulator object is destroyed
It is safe to call this function multiple times
reset
Reset the platform-invariant emulator state and (re-)register the control-plane callbacks that are identical on every target (HSB IP version, RESET_REG_CTRL, PTP, APB RAM, async events, I2C register block).
Called from each platform’s constructor after the ctxt_ and i2c_controller_ are wired up. Platform-specific callback registrations (GPIO/SPI on STM32; Linux peripheral attach) remain in the platform constructor.
Future: a default reset callback is applied that will call this, but that callback can be overridden
is_running
Check if the emulator is running.
Returns: true if the emulator is running, false otherwise.
write
python:
def write(self: hemu.HSBEmulator, address: int, value: int)
Write a value to a register.
Returns: 0 on success, 1 on address error.
Parameters
The address of the register to write.
The value to write.
read
python:
def read(self: hemu.HSBEmulator, address: int) -> int
Read a value from a register.
Returns: 0 on success, 1 on address error.
Parameters
The address of the register to read.
The value read will be stored here.
register_read_callback
Set a read callback for a range of addresses.
See ControlPlaneCallback_f for more details.
This method is not yet implemented for linux targets
Returns: 0 on success, else error code.
Parameters
The start address of the range.
The end address of the range (exclusive).
The callback to set.
The context to pass to the callback.
register_write_callback
Register a write callback for a range of addresses.
See ControlPlaneCallback_f for more details.
This method is not yet implemented for linux targets
Returns: 0 on success, else error code.
Parameters
The start address of the range.
The end address of the range (exclusive).
The callback to set.
The context to pass to the callback.
handle_msgs
method to explicitly handle pending control messages to the HSBEmulator client.
This method is required for MCU targets, but optional for linux targets
get_i2c
python:
def get_i2c(self: hemu.HSBEmulator, controller_address: int = hololink.I2C_CTRL) -> hemu.I2CController
Get a reference to the I2C controller.
Returns: A reference to the I2C controller.
get_config
add_data_plane
Add a data plane to the emulator for start()/stop()/is_running() management.
Returns: 0 on success, 1 on failure.
Parameters
The data plane to add.
get_memory
Returns: The register map of the emulated fpga