> 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/model-in-sps-rt-lab-only/configure-the-ehs-circuit-interfaces/configure-gate-signal-inputs/configure-internal-fpga-pwm-generators.md).

# Configure Internal FPGA PWM Generators

Some FPGA firmware configurations include **built-in PWM generators** that can be used to directly drive eHS switch gates. Because the PWM signals are generated inside the FPGA, they are produced at FPGA timing resolution and do not rely on the CPU simulation timestep. This approach is useful when high-resolution PWM generation is required for power electronics applications.

## Prerequisites

Before configuring PWM generators, verify that the selected FPGA firmware supports this feature.

1. Open the firmware `.conf` file in a text editor.
2. Locate the **PWMO** subsections under **Slot 5** in the firmware `.conf` file. Their presence indicates that internal FPGA PWM generators are supported. If no **PWMO** subsection is found, the firmware does not support this feature.
3. Note the associated **DataIn** port numbers.

<figure><img src="https://3212678799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABuoXNYgvaoO7wIe3bfO%2Fuploads%2Fgit-blob-84c98d12dc9ec2014abc282c6c965cec169c53f4%2Fimage%20(13).png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Slot 5 is reserved for internal FPGA resources such as PWM generators and does not correspond to a physical I/O channels.
{% endhint %}

## Procedure

{% stepper %}
{% step %}

### Add a PWM Out block

1. Open the CPU model in Simulink.
2. Add a **PWM Out** block to the same subsystem as the **eHS CPU Block**.

<figure><img src="https://3212678799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABuoXNYgvaoO7wIe3bfO%2Fuploads%2Fgit-blob-158afaa0808b0f5a73422aa0b8c0c8a0f9853979%2Fimage%20(14).png?alt=media" alt=""><figcaption></figcaption></figure>

3. Double-click the block to open its parameters. Set **DataIn Port Number** to one of the DataIn ports identified in the firmware `.conf` file and set **Number of PWM Signals** to the required number of PWM generators.

<figure><img src="https://3212678799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABuoXNYgvaoO7wIe3bfO%2Fuploads%2Fgit-blob-cb894b1f799e8bd0ef02e1ca6dafc1e768b195a0%2Fimage%20(15).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure frequency and duty cycle Inputs

Connect the signals that define the PWM frequency and duty cycle to the PWM Out block.

* The signal dimensions must match the configured number of PWM signals.
* For example, if two PWM generators are configured, both the frequency and duty-cycle inputs must contain two elements.
  {% endstep %}

{% step %}

### Assign PWM generators to eHS circuit switches

1. Double-click the **eHS CPU Block**.
2. Open the **Gates Settings** tab.
3. Click the **Configure Switch Gates** button.
4. For each switch driven by an internal PWM generator:
   * Set **Gate Signal Source** to **PWM**.
   * Set **Index** to the desired PWM generator number.

Multiple switches can be driven by the same PWM generator by assigning them the same PWM index.
{% endstep %}
{% endstepper %}

Once configured, the internal FPGA PWM generators drive the eHS switch gates directly, providing high-resolution FPGA-based PWM control for the simulated circuit.


---

# 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/model-in-sps-rt-lab-only/configure-the-ehs-circuit-interfaces/configure-gate-signal-inputs/configure-internal-fpga-pwm-generators.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.
