Dynamic Output Ports - 2024.1 English

Vitis Model Composer User Guide (UG1483)

Document ID
Release Date
2024.1 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 is invoked at several different times when a model is compiled. The configuration function can be invoked before the data types and rates have been propagated to the black box.

The SysgenBlockDescriptor object provides Boolean member variables inputTypesKnown and inputRatesKnown that tell whether the port types and rates have been propagated to the block. If you are setting dynamic output port types or rates based on input port configurations, the configuration calls should be nested inside conditional statements that check that 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) 

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)