> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/ehs-cpu-block.md).

# eHS CPU Block

## Description

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-5cbbadf30d22bd1e82fa01a9bf375adcdb654b5d%2Fehs-cpu-block.png?alt=media" alt="" width="235"><figcaption></figcaption></figure>

The **eHS\_CPU** block, located in the **eFPGAsim/External circuit editor workflow** library, is used to configure and control an **eHS Gen4** solver for calculating the outputs of a power electronic circuit in real time. The eHS Gen4 core runs on an FPGA-based platform and operates at a higher sampling rate than the RT-LAB system, enabling high-fidelity simulation of power electronic systems.

The netlist file must be generated from an **SPS Software** (Smart Power Simulation Software *SPS*) model.

The block provides real-time control of voltage and current sources, as well as switch gate signals. It also supports scenario management, allowing users to define and execute different operating conditions during simulation.

## Mask parameters

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-d425ed42a418739196c06da5e8766717786b4c93%2Fehs-cpu-block-circuit-tab.png?alt=media" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="Circuit" %}

<table data-search="false"><thead><tr><th>Parameter / Button</th><th>Description</th></tr></thead><tbody><tr><td><strong>eHS Solver License Class</strong></td><td><p>Defines the eHS solver class used for real-time simulation.</p><ul><li>In <strong>Auto</strong> mode, the solver size defined in the firmware is used.</li><li>Otherwise, you can select a solver size that is <strong>equal to or smaller</strong> than the firmware-defined size.</li><li>The selected solver size is used for license validation and may limit the available eHS performance.</li></ul><p>More information about eHS licensing.</p></td></tr><tr><td><strong>Generate Configuration</strong></td><td>Imports the circuit file and updates the block with the latest circuit information.</td></tr><tr><td><strong>Circuit file name</strong></td><td>Specifies the eHS circuit file to simulate. The circuit must be created using the SPS Software add-on</td></tr><tr><td><strong>[...]</strong></td><td>Opens a file explorer window to browse the circuit file.</td></tr><tr><td><strong>Edit</strong></td><td>Opens the circuit file in Matlab.</td></tr><tr><td><strong>Use Explicit Time-Step (Otherwise Use Minimum)</strong></td><td><p>If selected, the <strong>eHS Time-Step</strong> field becomes available, allowing you to specify the solver sample time. The minimum supported sample time depends on the circuit complexity and is typically in the hundreds of nanoseconds range.</p><p>This may be helpful for:</p><ul><li>Testing different sample times</li><li>Reducing the quantization error for systems that contain very large time constants (>> 10 sec)</li><li>Synchronizing the eHS with another FPGA solver core</li></ul></td></tr><tr><td><strong>Use Explicit Gs Values (Otherwise Use 1)</strong></td><td>If this option is selected, the <strong>Switch conductances</strong> field is displayed to set conductance of the switches of the circuit.<br>If it is a scalar, this value is applied to all switches in the circuit.<br>If it is a vector, each element is applied to the switch with the corresponding index in the circuit to be solved.<br>Valid values of Gs are positive or null. However, while null values are allowed, they may lead to incorrect simulation results and using them will trigger a warning display.<br>To open the eHS Optimization Tool to get additional information on this parameter, type <strong>GsGui2</strong> into the MATLAB Command Window.</td></tr></tbody></table>
{% endtab %}

{% tab title="Inputs" %}

| Parameter / Button               | Description                                                     |
| -------------------------------- | --------------------------------------------------------------- |
| **Configure Inputs**             | Enables the user to open the **eHS Input Configuration** panelI |
| **Add Reset Input to the block** | If checked, adds the input                                      |

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-ef6eef5e3a444fd067c4c5cc9c94f016cd6ec804%2Fehs-cpu-block-inputs-config.png?alt=media" alt=""><figcaption></figcaption></figure>

This table allows you to connect any source of the circuit to the available sources (CPU Model, Sine Wave Generator, Analog Input). The index specifies the channel of the associated source to use.

If **Automatic channel assignment** is enabled, this channels of “Sine Wave Generator” and “CPU Model” will be automatically assigned (in the order of the Input Name list) based on the number of connexion made to the associated source. If disabled, the user can use the index of his choice in the acceptable range.
{% endtab %}

{% tab title="Gates" %}

| Parameter / Button         | Description                                                                                                                                                                    |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Configure Switch Gates** | Enables the user to open the **eHS** **Gate Configuration** panel.                                                                                                             |
| **Use RT-EVENT**           | If this option is selected, the **Number of Events** field is displayed to configure the number of events of the internal Time Stamped digital pulse generator (by default 4). |

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-ee1c9913afdcf391ca56b0e0c0aece194f55c022%2Fehs-cpu-block-gates.png?alt=media" alt=""><figcaption></figcaption></figure>

The **eHS Gate Configuration** table allows you to connect any source of the circuit to the available sources (CPU Model, Internal PWM generator, Simulator Digital Input). The index specifies the channel of the associated source to use. The polarity field is to set the gate signal polarity (High => if eHS reads a digital state of 1, the gate applied to the switch will be ON; Low => Digital state of 0 means gate applied is ON)
{% endtab %}

{% tab title="Scenarios" %}

<table data-search="false"><thead><tr><th>Parameter / Button</th><th></th></tr></thead><tbody><tr><td><strong>Use scenarios</strong></td><td>If checked, enables scenario management, allowing you to define multiple sets of netlist RLC component values. Each scenario can have its own component values to represent different operating conditions.</td></tr><tr><td><strong>Generate a scenario file template</strong></td><td>Generates an empty scenario file based on the user's circuit file. This requires Microsoft Excel to be installed on the host computer in order to produce a file.</td></tr><tr><td><strong>[...]</strong></td><td>Opens a file explorer window to browse the scenario file (xls or xlsx file).</td></tr><tr><td><strong>Edit</strong></td><td>Opens the circuit file in Matlab.</td></tr><tr><td><strong>XLS File name</strong></td><td>The file contains the table of RLC components values depending on the scenario number. This parameter gives the path of the file that will be used to perform the scenario declaration.</td></tr><tr><td><strong>Number of scenario used</strong></td><td>number scenarion default values</td></tr><tr><td><strong>Maximum number of Scenarios</strong></td><td>Number of scenarios available for the current netlist. This number takes into account the scenario of default values that cannot be modified.</td></tr></tbody></table>
{% endtab %}

{% tab title="Thermal Loss" %}
**Enables thermal loss calculation for 2-level bridges.** Each bridge can be associated with one of four lookup tables defining the switching and conduction losses of the switches and their antiparallel diodes. The calculated losses are for monitoring purposes only and do not affect the simulation results.

| Parameter / Button | Description                                                          |
| ------------------ | -------------------------------------------------------------------- |
| **enable**         | If checked, the thermal loss feature will be enabled.                |
| **Configuration**  | Enables the user to open the eHS Thermal losses Configuration panel. |

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-b91d178e9e4d1a9749a39cce7bbbc5e5fbde4d24%2Fehs-cpu-block-thermal-loss.png?alt=media" alt="" width="320"><figcaption></figcaption></figure>

**eHS Thermal losses Configuration:** This table shows every Inverter leg in detected in the circuit. The eHS will automatically populate the list of legs form the Universal bridge blocks found in the circuit model.

* The first column shows their names.
* The Enable column allows to choose which inverters leg are monitored. A maximum of 30 two-level inverters leg, or 120 devices, can be monitored during a simulation.
* The DC Voltage and AC Current columns show the measuremt used to compute the thermal losses.
* If the Automatically find measurements is checked, those two columns are filled automatically. If they are Unassigned, it indicated that they are either missing, or not connected properly. DC Voltage measurement positve point should be connected to the positive DC-side of the two-level inverter. DC Voltage measurement negative point should be connected to the negative DC-side of the two-level inverter. AC Current measurement positive point should be connected to the AC-side (A B or C node) of the two-level inverter (positive current is defined exiting the inverter).
* The thermal model column lets the user assigned one of the four lookup table.
* T° port indices column indicates where the component temperature should send on the devices T° port vector.

Refer to the [Thermal loss feature example](https://www.opal-rt.com/docs/rt-lab/example-models/ehs-example-models/sps-software-example-models/thermal-loss-feature.md) model for more details
{% endtab %}

{% tab title="Communications" %}

<table data-search="false"><thead><tr><th>Parameter / Button</th><th>Description</th></tr></thead><tbody><tr><td><strong>OpCtrl Controller name</strong></td><td>Links this block to an OpCtrl block by entering the same 'Controller Name' as specified in the OpCtrl block. The OpCtrl block controls initialization of the settings of one specific FPGA-based card in the system.</td></tr><tr><td><strong>Communications Settings Automatic Configuration</strong></td><td>Enable the automatic setting of the communications ports. The *.conf file linked to the *.bin file selected in the OpCtrl Controller will be parsed and the communications settings will be set accordingly. If unchecked, the fields become modifiable for manual user settings.</td></tr><tr><td><strong>Ehs Core</strong></td><td>If Communications Settings Automatic Configuration is enabled, Ehs Core allows the selection of which core defined in the *.conf to use for automatic configuration.</td></tr><tr><td><strong>eHS Form Factor</strong></td><td>This parameter shows the eHS solver size instanciated inside the firmware. It is disabled if the mode “Communications Settings Automatic Configuration” is selected, since the eHS Form Factor value will be read from the *.conf file.</td></tr><tr><td><strong>Cpu Inputs Port Number</strong></td><td>From the Communication Port Numbers array mask, this value will show the effective Cpu Inputs Port Number</td></tr><tr><td><strong>Cpu Gates Port Number</strong></td><td>From the Communication Port Numbers array mask, this value will show the effective Cpu Gates Port Number</td></tr><tr><td><strong>Cpu Outputs Port Number</strong></td><td>From the Communication Port Numbers array mask, this value will show the effective Cpu Ouputs Port Number</td></tr><tr><td><strong>eHS Configuration Port Number</strong></td><td>From the Communication Port Numbers array mask, this value will show the effective eHS Configuration Port Number</td></tr><tr><td><strong>RST/Scenario Port Number</strong></td><td>From the Communication Port Numbers array mask, this value will show the effective RST/Scenario Port Number</td></tr><tr><td><strong>SineWaveGenerator DataIn port</strong></td><td>This value must reflect the Data In port number of the FPGA Internal Sine wave generator that is dedicated to the eHS. It can be found in the *.conf file or in the firmware documentation.</td></tr></tbody></table>
{% endtab %}

{% tab title="Firmware Config" %}

| Parameter / Button                      | Description                                                                                                             |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Use a custom firmware configuration** | If checked, the Custom input and gate source enumeration could be customized for specific firmware.                     |
| **Custom input source enumeratio**      | nAs a reminder, the default field is available for you to get the default value and associated valid format to provide. |
| **Custom gate source enumeration**      | As a reminder, the default field is available for you to get the default value and associated valid format to provide.  |
| {% endtab %}                            |                                                                                                                         |
| {% endtabs %}                           |                                                                                                                         |

## Inputs

This input port should be connected to **vector signal**, each element being one of the controlled inputs of the eHS solver (available when at least one “CPU Model” source type is selected in the eHS Input Configuration table). The required width is indicated on the port. Indices that do not correspond to a controlled voltage or current source are left unused. Please refer to the **eHS Input Configuration** table in the mask to identify the order of the inputs. The unit is Amps or Volts depending if a current or voltage source is driven.

**Sine Wave Frequencies/Amplitudes/Phases/Offsets:** This inport should be connected to vector signals, each element being one of the controlled parameter of the eHS solver's FPGA based Sine wave generators (available when at least one “Sine Wave Generator” source type is selected in the eHS Input Configuration table). Each must be a vector of double signal with the width display on the port. Each sine wave is generated following this equation: Output = Amplitude\*SIN(2\*pi\*Freq\*t + Phase\*2\*pi/360) + Offset\
**Frequencies** are expected in Hz and specify the frequency of each sine wave generator channel.\
**Amplitudes** are exected in Amps or Volts depending if the Sine wave generator is connected to a current or voltage source. They specify the gains applied on each sine wave generator channel.\
**Phases** are exected in Degrees and specify the phase offset applied on each sine wave generator channel.\
**Offsets** are exected in Amps or Volts depending if the Sine wave generator is connected to a current or voltage source. They specify the DC offset apply to each sine wave generator channel.

**Gates:** This inport should be connected to vector signal, each element being one of the controlled gates of the eHS solver (from “CPU Model” in the eHS Gate Configuration table). The required width is indicated on the inport. If you have specified the Use RT-EVENT check box, the input should be RTE signals with the number of event specified in the associated field. Otherwise Double format is required. Indices that do not correspond to a controlled gate are left unused. Please refer to the **eHS Gate Configuration** table in the mask to identify the order of the gates.

**Scenario id:** This input should be a scalar defining the scenario that the solver uses. When changing scenario, the set of component values used will be the one specified in the XLS file at the corresponding scenario lines. The default configuration is **0**. The inputs values to load Scenarios1..N are **1..N**. The input is saturated to the highest number of scenario thus if the maximum number of scenarios is 32, sending 34 to the input will load the scenario 32, and -1 will load 0.

**Devices T:** This input should be a vector containing the temperature for each device when the thermal loss feature is used. The order of this vector should match the Losses output port (First upper diode, first upper switch, first lower diode ...).

**Reset:** This input is a software reset and should be connected to a single signal of that state of the reset, **1** when the solver is in reset mode and **0** when the solver is not in reset mode. The reset input pin resets all states of the eHS block to their default values.

## Outputs

**Ouputs:** This output is a vector, each element being one of the outputs of the solver. The width of the vector is equal to the number of measurements in the circuit. Note that the outputs of the eHS Gen4 block are the average values of the FPGA solver output over a CPU time step.

**Losses:** This output is a vector, each element gives the loss in watt for the different devices (First upper diode, first upper switch, first lower diode ...). Using a bus selector, you can get the name of each device.

## Characteristics and limitations

**Number of elements:** The limitation on the number of elements (i.e. Sources, Gates, and Measurements) depends on the eHS form factor being used. For updated information on the limitations of each eHS Gen4 form factor, refer to the **Specifications** section of the User Guide.

* There is no limitation on the number of resistors.
* The solver time step is limited to approximately 4us.
* As many inductors and capacitors as necessary can be used so long as the timestep does not surpass the limit of approximately 4us.
* The use of Inductors, Capacitors and Switches has a strong impact on the minimum achievable timestep, whereas the use of inputs and outputs has a more limited impact.

\
**Circuit design:** See the product documentation and example models for details on how to design a circuit for use with the eHS.

**Offline simulation:** This block does not enable offline simulation. For offline simulation, use the eHS Offline simulation block in the **eFPGASIM>>eHS and Converter Models>>Tools** library. This block enables the developer to connect the block exactly as it is connected inside the FPGA, e.g. to a plant model, for more accurate results.

| Direct Feed-through  | NO  |
| -------------------- | --- |
| Discrete sample time | YES |
| XHP support          | YES |
| Works off-line       | NO  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/ehs-cpu-block.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
