Main Content

Merge Block with Unequal Input Widths Example

This example shows how to use the Merge block with inputs ports that have different widths. If you select Allow unequal port widths, the block accepts scalar and vector inputs having differing numbers of elements. You can specify an offset for each input signal relative to the beginning of the output signal. The width of the output signal is:

$max(w1+o1, w2+o2, ... wn+on)$

where $wn$ are the widths of the input signals, and $on$ are the offsets.

The Merge block has the following output width.

$max(2+0,2+1)=3$

In this example, the offset of $v1$ is 0 and the offset of $v2$ is 1. The Merge block maps the elements of $v1$ to the first two elements of $v3$ and the elements of $v2$ to the last two elements of $v3$. Only the second element of $v3$ is effectively merged, as show in the scope output.

If you use Simplified Initialization Mode, you must clear the Allow unequal port widths check box. The input port offsets for all signals must be zero.