Passing Parameters into the MCode Block - 2022.1 English

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2022-05-26
Version
2022.1 English

This example shows how to pass parameters into the MCode block. An input argument to an M-function can be interpreted either as an input port on the MCode block, or as a parameter internal to the block.

The following M-code defines an M-function xl_sconvert that is contained in file xl_sconvert.m:

function dout = xl_sconvert(din, nbits, binpt)
  proto = {xlSigned, nbits, binpt};
  dout = xfix(proto, din);

The following diagram shows a Subsystem containing two MCode blocks that use M-function xl_sconvert. The arguments nbits and binpt of the M-function are specified differently for each block by passing different parameters to the MCode blocks. The parameters passed to the MCode block labeled signed convert 1 cause it to convert the input data from type Fix_16_8 to Fix_10_5 at its output. The parameters passed to the MCode block labeled signed convert 2 causes it to convert the input data from type Fix_16_8 to Fix_8_4 at its output.

Figure 1. Subsystem with Two MCode Blocks

To pass parameters to each MCode block in the diagram above, you can click the Edit M-File button on the block GUI then set the values for the M-function arguments. The mask for MCode block signed convert 1 is shown below:

Figure 2. Masking MCode Block

The above interface window sets the M-function argument nbits to be 10 and binpt to be 5. The mask for the MCode block signed convert 2 is shown below:

Figure 3. Mask for MCode Block Signed Convert 2