Dynamic Output Ports - 2025.2 English - UG1483

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2025-11-20
Version
2025.2 English

A useful feature of the black box is its ability to support dynamic output port types and rates. For example, it is often necessary to set an output port width based on the width of an input port. SysgenPortDescriptor provides member variables that allow you to determine the configuration of a port. You can set the type or rate of an output port by examining these member variables on the block's input ports.

For example, you can obtain the width and rate of a port (in this case din) as follows:

input_width = this_block.port('din').width; 
input_rate  = this_block.port('din').rate; 
Note: A black box's configuration M-function runs at several points during model compilation. You can invoke the configuration function before the data types and rates propagate to the black box.

The SysgenBlockDescriptor object provides Boolean member variables inputTypesKnown and inputRatesKnown. These tell whether the port types and rates have propagated to the block. If you are setting dynamic output port types or rates based on input port configurations, nest the configuration calls inside conditional statements that check the values of inputTypesKnown and inputRatesKnown.

The following code shows how to set the width of a dynamic output port dout to have the same width as input port din:

if (this_block.inputTypesKnown) 
  dout.setWidth(this_block.port('din').width); 
end 

Setting dynamic rates works in a similar manner. The code below sets the sample rate of output port dout to be twice as slow as the sample rate of input port din:

if (this_block.inputRatesKnown) 
  dout.setRate(this_block.port('din').rate*2); 
end