PostTargetReferenceDesignFcn
Class: hdlcoder.ReferenceDesign
Namespace: hdlcoder
Function handle for callback function that gets executed after the target reference design is set
Syntax
PostTargetReferenceDesignFcn
Description
PostTargetReferenceDesignFcn
registers
a function handle for the callback function that gets called at the
end of the Set Target Reference Design task in
the HDL Workflow Advisor. If hRD
is the reference
design object that you construct with the hdlcoder.ReferenceDesign
class,
use this syntax to register the function handle:
hRD.PostTargetReferenceDesignFcn = @my_reference_design.callback_PostTargetReferenceDesign
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_PostTargetReferenceDesign
, and
is located in the reference design package folder +my_reference_design
.
With the callback function, you can enable custom validations for your design. This example code shows how to create the callback function and validate that the reset type is synchronous.
function callback_PostTargetReferenceDesign(infoStruct) % Reference design callback run at the end of the task Set Target Reference Design % % 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 mdlName = bdroot(infoStruct.HDLModelDutPath); hRD = infoStruct.ReferenceDesignObject; refDesignName = hRD.ReferenceDesignName; isResetSync = strcmpi(hdlget_param(mdlName, 'ResetType'), 'Synchronous'); % Reset must be synchronous if ~isResetSync error('Invalid Reset type. Reset type must be synchronous'); end end
In the HDL Workflow Advisor, when HDL Coder™ runs the Set Target Reference Design task, it executes the callback function. If the reset type is not synchronous, 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