When defining a black box port interface, it is necessary to add input and output
ports to the block descriptor. These ports correspond to the ports on the module you are importing.
The port names declared in the block descriptor object determine the Black Box block’s port
interface in your model. SysgenBlockDescriptor provides methods for
adding input and output ports:
Adding an input port:
this_block.addSimulinkInport('din');
Adding an output port:
this_block.addSimulinkOutport('dout');
The string parameter passed to methods addSimulinkInport and addSimulinkOutport
specifies the port name. These names need to match the corresponding port names in the
imported module.
Adding a bidirectional port:
config_phase = this_block.getConfigPhaseString;
if (strcmpi(config_phase,'config_netlist_interface'))
this_block.addInoutport('bidi');
% Rate and type info should be added here as well
end
Bidirectional ports appear only in the generated HDL. Model Composer supports them during netlisting, but they do not appear in the diagram. As such, it is important to only add the bi-directional ports when Model Composer is generating the HDL. The if-end conditional statement is guarding the execution of the code to add-in the bi-directional port.
It is also possible to define both the input and output ports using a single
method call. The setSimulinkPorts method accepts two parameters. The first
parameter is a cell array of strings that define the input port names for the block. The
second parameter is a cell array of strings that define the output port names for the
block.