PostTargetInterfaceFcn
Class: hdlcoder.ReferenceDesign
Namespace: hdlcoder
Function handle for callback function that gets executed after the set target interface task runs
Syntax
PostTargetInterfaceFcn
Description
PostTargetInterfaceFcn
registers a function
handle for the callback function that gets called at the end of the Set
Target Interface task in the HDL Workflow Advisor. If hRD
is
the reference design object that you construct with the hdlcoder.ReferenceDesign
class,
then use this syntax to register the function handle.
hRD.PostTargetInterfaceFcn = @my_reference_design.callback_PostTargetInterface;
To define your callback function, create a file that defines
a MATLAB® function and add it to your MATLAB path. You can
use any name for the callback function. In this example, the function
name is callback_PostTargetInterface
, and is located
in the reference design package folder +my_reference_design
.
With this callback function, you can enable custom validations.
This example code shows how to create the callback function. If the
custom parameter DUTPath
is set to Rx
,
the function validates that the reference design does not support
the LEDs General Purpose [0:7]
interface.
function callback_PostTargetInterface(infoStruct) % Reference design callback run at the end of the task Set Target Interface % % infoStruct: information in structure format % infoStruct.ReferenceDesignObject: current reference design registration object % infoStruct.BoardObject: current board registration object % infoStruct.ParameterStruct: custom parameters of the current reference design, in struct format % infoStruct.HDLModelDutPath: the block path to the HDL DUT subsystem % infoStruct.ProcessorFPGASynchronization: Processor/FPGA synchronization mode % infoStruct.InterfaceStructCell: target interface table information % a cell array of structure, for example: % infoStruct.InterfaceStructCell{1}.PortName % infoStruct.InterfaceStructCell{1}.PortType % infoStruct.InterfaceStructCell{1}.DataType % infoStruct.InterfaceStructCell{1}.IOInterface % infoStruct.InterfaceStructCell{1}.IOInterfaceMapping hRD = infoStruct.ReferenceDesignObject; refDesignName = hRD.ReferenceDesignName; % validate that when specific parameter is set to specific value, reference % design does not support specific interface paramStruct = infoStruct.ParameterStruct; interfaceStructCell = infoStruct.InterfaceStructCell; for ii = 1:length(interfaceStructCell) interfaceStruct = interfaceStructCell{ii}; if strcmp(paramStruct.DutPath, 'Rx') && ... strcmp(interfaceStruct.IOInterface, 'LEDs General Purpose [0:7]') error('LEDs General Purpose [0:7] must not be used when the DUT path is Rx'); end end end
In the HDL Workflow Advisor, when HDL Coder™ runs the Set
Target Interface task, it executes the callback function
at the end of the task. If you specify Rx
as
the DUT Path and use the LEDs General
Purpose [0:7]
interface for your DUT port, the coder generates
an error.
When you create the callback function, pass the infoStruct
argument
to the function. The argument contains the reference design and board
information in a structure
format. Use this information
to enable custom validations on the DUT in your Simulink® model.
Version History
Introduced in R2016b