Simple Selector - 2022.1 English

Vitis Model Composer User Guide (UG1483)

Document ID
Release Date
2022.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;
    z = y;

The xlmax.m file should be either saved in the same directory of the model file or should be in the MATLAB path. Once the xlmax.m has been saved to the appropriate place, you should drag a MCode block into your model, open the block parameter dialog box, and enter xlmax into the MATLAB Function field. After clicking the OK button, 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 is compiled. You can see that the block calculates and sets the necessary fixed-point data type to the output port.

Figure 1. Simple Selector Design