Main Content


Class: hdlcoder.ReferenceDesign
Namespace: hdlcoder

Function handle for callback function that executes after IP core generation runs

Since R2024a




PostGenerateIPCoreFcn registers a function handle for the callback function that executes after the Generate IP Core task runs. For example, suppose that hRD is a reference design object of the hdlcoder.ReferenceDesign class. Use this syntax to register the function handle:

hRD.PostGenerateIPCoreFcn = @my_reference_design.callback_PostGenerateIPCoreFcn;

To define a callback function, create a file that defines a MATLAB® function and add it to the MATLAB path. You can use any name for the callback function. In this example, the function name is callback_PostGenerateIPCoreFcn, and it is in the reference design package folder +my_reference_design.

With this callback function, you can specify custom tasks to run after HDL Coder™ runs the IP core generation process. This example code shows how to create the callback function. The function creates an output text file that contains the first entry in the target interface table.

function callback_PostGenerateIPCoreFcn(infoStruct)
% Reference design callback run at the end of the task Generate IP Core
% 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
% infoStruct.IPCoreFolder: the path to IP core folder
% infoStruct.IPCoreName: the IP core name
% infoStruct.IPCoreVersion: the IP core version

mdlName = bdroot(infoStruct.HDLModelDutPath);
hRD = infoStruct.ReferenceDesignObject;
refDesignName = hRD.ReferenceDesignName;
fileID = fopen('PostGenerateIPCoreInfo.txt','w');
fprintf(fileID,'\n%s','Exporting Interface Mapping Content');
tmp = struct2cell(infoStruct.InterfaceStructCell{1});


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.

Version History

Introduced in R2024a