This project includes sample code that shows how to define various types of ports on an MxVMC. This is no longer the preferred method for working with VMCs. For new projects, use Guided Harnessing to define ports.

Click here to download the project:

Applies to:

MxSuite 3.40 or later

Other Requirements:

A supported version of Visual Studio is required to compile or modify the SUT (MxVMC) code.

A licensed and supported version of Matlab Simulink is required to run this project.

The user should have an understanding of MxSuite Scenarios, TestCases, and Transforms.

The Register Port Definitions method is in the AppIF.c file:

void MxVRegisterPortDefinitions(void)


  int y;

  int x;


  MxVRegisterPortU8("ArrayValues", PortDataFlowOutput, arrayValues, 0, 255, 0);

  MxVSetPortDimensions("ArrayValues", PortDataFlowOutput, 5, 1);


  MxVRegisterPortU8("InitializedArrayValues", PortDataFlowOutput, &initializedValues[0][0], 0, 255, 0);

  MxVSetPortDimensions("InitializedArrayValues", PortDataFlowOutput, initializedValuesXCount, initializedValuesYCount);


  for (y = 0; y < initializedValuesYCount; ++y)


     for (x = 0; x < initializedValuesXCount; ++x)


        MxVSetPortInitialValueAtU8("InitializedArrayValues", PortDataFlowOutput, x, y, initializedValues[y][x]);




  MxVRegisterPortDiscrete("FiveBits", PortDataFlowInput, &myUnion.values, 0, 5, mxTrue, -16, 15, 0);

  MxVSetPortHandlerFunction("FiveBits", PortDataFlowInput, checkToSendMessage, &fiveBitsSet);

  MxVRegisterPortI8("FiveBitsOut", PortDataFlowOutput, &fiveBitsSet, -16, 15, 0);

  MxVRegisterPortDiscrete("TenBits", PortDataFlowInput, &myUnion.values, 5, 10, mxTrue, -512, 511, 0);

  MxVSetPortHandlerFunction("TenBits", PortDataFlowInput, checkToSendMessage, &tenBitsSet);

  MxVRegisterPortI16("TenBitsOut", PortDataFlowOutput, &tenBitsSet, -512, 511, 0);

  MxVRegisterPortContinuous("FloatBits", PortDataFlowInput, &myUnion.values, 32, sizeof(myUnion.values.continuous.floatpart) * 8, -1, 1, 0);

  MxVSetPortHandlerFunction("FloatBits", PortDataFlowInput, checkToSendMessage, &floatBitsSet.floatpart);

  MxVRegisterPortF32("FloatBitsOut", PortDataFlowOutput, &floatBitsSet.floatpart, -1, 1, 0);


  MxVRegisterPortMessage("Values", PortDataFlowOutput, myUnion.valuearray, sizeof(myUnion.valuearray), mxFalse, mxFalse);


  MxVRegisterPortU8("PassthroughIn", PortDataFlowInput, &arrayPassthrough[0][0], 0, 255, 0);

  MxVRegisterPortU8("PassthroughOut", PortDataFlowOutput, &arrayPassthrough[0][0], 0, 255, 0);

  MxVSetPortDimensions("PassthroughIn", PortDataFlowInput, arrayPassthroughXCount, arrayPassthroughYCount);

  MxVSetPortDimensions("PassthroughOut", PortDataFlowOutput, arrayPassthroughXCount, arrayPassthroughYCount);

  MxVRegisterPortMessage("PassthroughBytes", PortDataFlowOutput, &arrayPassthrough[0][0], arrayPassthroughXCount * arrayPassthroughYCount, mxFalse, mxTrue);


The syntax and functions of the functions are detailed in Port Registration.

To run the test, run the Default Scenario. The Scenario should pass.