> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sensor-bridge/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sensor-bridge/_mcp/server.

# 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.

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`](dataplane) objects and the [`I2CController`](i2ccontroller) and all communication with the internal memory model; see [`AddressMemory`](addressmemory) for more details.

```cpp showLineNumbers={false}
#include <hololink/emulation/hsb_emulator.hpp>
```

***

## Constructors

### HSBEmulator \[#hsbemulator]

#### Copy

```cpp showLineNumbers={false}
hololink::emulation::HSBEmulator::HSBEmulator(
    const HSBConfiguration &config
)
```

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.

#### Default

```cpp showLineNumbers={false}
hololink::emulation::HSBEmulator::HSBEmulator()
```

Construct a new `HSBEmulator` object.

Defaults to HSB\_EMULATOR\_CONFIG, which is roughly equivalent to a Lattice board.

### Destructor \[#destructor]

### \~HSBEmulator

```cpp showLineNumbers={false}
hololink::emulation::HSBEmulator::~HSBEmulator()
```

***

## Methods

### start \[#start]

```cpp showLineNumbers={false}
void hololink::emulation::HSBEmulator::start()
```

Start the emulator.

This will start the BootP broadcasting via the [DataPlane](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]

```cpp showLineNumbers={false}
void hololink::emulation::HSBEmulator::stop()
```

Stop the emulator.

This will shut down the control message thread, all BootP broadcasts in [DataPlane](dataplane) objects. Data transmission is still possible until `HSBEmulator` object is destroyed

It is safe to call this function multiple times

### reset \[#reset]

```cpp showLineNumbers={false}
void hololink::emulation::HSBEmulator::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 \[#isrunning]

```cpp showLineNumbers={false}
bool hololink::emulation::HSBEmulator::is_running()
```

Check if the emulator is running.

**Returns:** true if the emulator is running, false otherwise.

### write \[#write]

```cpp showLineNumbers={false}
int hololink::emulation::HSBEmulator::write(
    uint32_t address,
    uint32_t value
)
```

python:

`def `[`write`](#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 \[#read]

```cpp showLineNumbers={false}
int hololink::emulation::HSBEmulator::read(
    uint32_t address,
    uint32_t &value
)
```

python:

`def `[`read`](#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 \[#registerreadcallback]

```cpp showLineNumbers={false}
int hololink::emulation::HSBEmulator::register_read_callback(
    uint32_t start_address,
    uint32_t end_address,
    ControlPlaneCallback_f callback,
    void *ctxt = nullptr
)
```

Set a read callback for a range of addresses.

See [ControlPlaneCallback\_f](../typedefs/controlplanecallbackf) 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 \[#registerwritecallback]

```cpp showLineNumbers={false}
int hololink::emulation::HSBEmulator::register_write_callback(
    uint32_t start_address,
    uint32_t end_address,
    ControlPlaneCallback_f callback,
    void *ctxt = nullptr
)
```

Register a write callback for a range of addresses.

See [ControlPlaneCallback\_f](../typedefs/controlplanecallbackf) 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 \[#handlemsgs]

```cpp showLineNumbers={false}
int hololink::emulation::HSBEmulator::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 \[#geti2c]

```cpp showLineNumbers={false}
I2CController & hololink::emulation::HSBEmulator::get_i2c(
    uint32_t controller_address = hololink::0x03000200u
)
```

python:

`def `[`get_i2c`](#geti2c)`(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 \[#getconfig]

```cpp showLineNumbers={false}
const HSBConfiguration & hololink::emulation::HSBEmulator::get_config()
```

### add\_data\_plane \[#adddataplane]

```cpp showLineNumbers={false}
int hololink::emulation::HSBEmulator::add_data_plane(
    DataPlane &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 \[#getmemory]

```cpp showLineNumbers={false}
AddressMemory & hololink::emulation::HSBEmulator::get_memory()
```

**Returns:** The register map of the emulated fpga

***

## Member variables

| Name              | Type                           | Description |
| ----------------- | ------------------------------ | ----------- |
| `ctxt_`           | `UniqueDel< HSBEmulatorCtxt >` |             |
| `configuration_`  | `HSBConfiguration`             |             |
| `i2c_controller_` | `I2CController`                |             |