> 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/ehs/3.7/model-in-schematic-editor/connect-ehs-circuits-to-cpu-based-electrical-models.md).

# Connect eHS Circuits to CPU-Based Electrical Models

## Overview

In some applications, it is desirable to simulate only part of an electrical network on the FPGA while the remainder executes on the CPU. This approach allows computationally intensive components, such as power electronic converters, to benefit from the very small time steps of eHS, while larger or less time-critical portions of the network remain in the main CPU-based model.

Typical applications include:

* Simulating a converter in eHS and the surrounding power network in Artemis or HYPERSIM.
* Connecting an FPGA-based inverter to a CPU-based machine model.
* Moving part of a network from the FPGA to the CPU to reduce FPGA resource utilization.
* Partitioning large electrical systems to achieve smaller FPGA time steps.

The resulting simulation behaves as a single electrical network distributed across two execution domains.

This workflow is supported in both:

* **RT-LAB**, where the CPU portion is typically simulated using **Artemis**
* **HYPERSIM**, where the CPU portion is simulated by the network solver

Electrical quantities are exchanged between the FPGA and CPU through a decoupling interface that represents the electrical connection between the two portions of the network.

## How the decoupling works

The FPGA and CPU solvers execute independently. To connect an eHS circuit running on the FPGA to a CPU-based electrical model, a decoupling interface must be introduced at the boundary between the two domains.

Half Line blocks in the eHS circuit and CPU model exchange electrical quantities through a transmission-line equivalent that introduces a configurable latency. The line parameters and latency determine how electrical information propagates between the FPGA and CPU portions of the network.

In the Schematic Editor, use the [Half Line FPGA to CPU](https://www.opal-rt.com/docs/ehs/3.7/model-in-schematic-editor/library-blocks-reference/line-blocks/half-line-fpga-to-cpu.md) block from the **Lines** library. Each **Half Line FPGA to CPU** block must be paired with a corresponding **Half Line** block in the CPU model, and both blocks must be configured with identical parameters.

The corresponding CPU-side block can be found in:

* **RT-LAB:** **eFPGASIM Library > External Circuit Editor Workflow > Lines and Loads**
* **HYPERSIM:** **Network Tools**

## Selecting the decoupling latency

The decoupling latency represents the communication delay between FPGA and CPU.

When the parameter is set to **Auto**, eHS attempts to determine an appropriate value based on the circuit configuration.

If needed, the value can be adjusted manually to improve stability or accuracy.

## Visual example

The following example illustrates three approaches for connecting a rectifier to the same three-phase source. It demonstrates how an electrical circuit can be progressively partitioned between the CPU and FPGA while preserving comparable simulation results.

1. **Reference circuit (bottom)**\
   The rectifier is modeled in HYPERSIM and runs on the CPU. This circuit serves as the reference for comparing the effects of decoupling and FPGA execution.
2. **CPU-only decoupled circuit (middle)**\
   The rectifier is also modeled in HYPERSIM, but the connection between the source and the rectifier is split using CPU **Half Line** blocks. This configuration demonstrates the impact of decoupling alone, without involving eHS or the FPGA. The results remain comparable to the reference circuit, showing that the Half Line interface accurately preserves the electrical behavior of the system.
3. **FPGA-CPU partitioned circuit (top)**\
   The rectifier is modeled in **Schematic Editor** and executed on the FPGA using **eHS**, while the source remains in the CPU model. The circuit is connected through matching **Half Line FPGA to CPU** (in Schematic Editor) and **Half Line** (in HYPERSIM) blocks. This configuration demonstrates how an electrical network can be partitioned between the FPGA and CPU domains while producing results comparable to the fully CPU-based reference model.

The figure also shows the required placement of the Half Line blocks on both sides of the interface:

* **CPU side:** Standard **Half Line** blocks.
* **FPGA side:** **Half Line FPGA to CPU** blocks inside the eHS circuit.
* Both sides must be configured with identical line parameters and latency settings.

The progression from the bottom circuit to the top circuit demonstrates that a portion of an electrical network can be moved from the CPU to the FPGA while maintaining the expected electrical behavior.

HYPERSIM CPU model:

<figure><img src="https://521571437-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo99Izmvvw5eHT4ldzI4g%2Fuploads%2Fgit-blob-89a316ec42e92cb73e5bc86802e6fe7bbf283507%2Fse-cpu-based-hypersim.png?alt=media" alt=""><figcaption></figcaption></figure>

Schematic Editor eHS circuit model:

<figure><img src="https://521571437-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo99Izmvvw5eHT4ldzI4g%2Fuploads%2Fgit-blob-7c93670ddb2bdbef5afc3fc22e2a0b581bd37908%2Fse-cpu-based-schematic-editor.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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/ehs/3.7/model-in-schematic-editor/connect-ehs-circuits-to-cpu-based-electrical-models.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.
