Simple Selector - Simple Selector - 2026.1 English - UG1483

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2026-06-23
Version
2026.1 English

This example is a simple controller for a data path, which assigns the maximum value of two inputs to the output. The M-function is specified as the following and is saved in an M-file xlmax.m:

function z = xlmax(x, y)
  if x > y
    z = x;
  else
    z = y;
  end 

You must save the xlmax.m file to either the same directory as the model file or in the MATLAB path. After saving the xlmax.m to the appropriate place, drag an MCode block into your model, open the block parameter dialog box, and enter xlmax into the MATLAB Function field. After clicking OK, the block has two input ports x and y, and one output port z.

The following figure shows what the block looks like after the model compiles. You can see that the block calculates and sets the necessary fixed-point data type to the output port.

Figure 1. Simple Selector Design Generated by Your Tool