> 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/rt-lab-library/opmuxdemux.md).

# OpMuxDemux

## Description

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

The **OpMuxDemux** block, located in the **RT-LAB/Miscellaneous** library, multiplexes or demultiplexes data elements based on parameters defined in its mask.

When configured as a demux, the block splits the raw data vector into element pieces according to the element definitions provided in the mask. When configured as a mux, it concatenates the element data pieces into a single raw data vector based on the same definitions.

An element’s start position in the data stream is defined by a start bit number and a data word number. For example, if the element start bit equals 2 and the element start word equals 0, the element starts at the third bit of the first word of the data stream. The raw length defines the element length in bits. An element can span multiple words. The total number of bits in the data stream is determined by the position of the last element and its length.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-c83e7f499f724c9f501c09cd5db21193d159007b%2FRTL_opmuxdemux_concept.png?alt=media" alt="" width="503"><figcaption><p>Example of an element in the data raw</p></figcaption></figure>

## Mask parameters

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

<table><thead><tr><th width="249.800048828125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>Number of elements</td><td>Specifies the number of elements.</td></tr><tr><td>Word size</td><td>Size of one word of data.</td></tr><tr><td>Vector of elements start bits</td><td>Vector of element start bits.</td></tr><tr><td>Vector of elements start word</td><td>Vector of element start word.</td></tr><tr><td>Vector of elements lengths</td><td>Vector of element lengths.</td></tr></tbody></table>

## Inputs

<table><thead><tr><th width="249.79998779296875">Input</th><th>Description</th></tr></thead><tbody><tr><td>Demux</td><td>1 input: raw data vector.</td></tr><tr><td>Mux</td><td>Multiple inputs: element data pieces.</td></tr></tbody></table>

## Outputs

<table><thead><tr><th width="249.79998779296875">Output</th><th>Description</th></tr></thead><tbody><tr><td>Demux</td><td>Multiple outputs: element data pieces.</td></tr><tr><td>Mux</td><td>1 output: raw data vector.</td></tr></tbody></table>


---

# 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/rt-lab-library/opmuxdemux.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.
