Main Content


Class: hdlcoder.ReferenceDesign
Namespace: hdlcoder

Function handle for callback function that gets executed after the build FPGA bitstream task runs




PostBuildBitstreamFcn registers a function handle for the callback function that gets called at the end of the Build FPGA Bitstream task in the HDL Workflow Advisor. When this function is called, you cannot run the build process externally. Before you run the Build FPGA Bitstream task, clear the Run build process externally check box to build the FPGA bitstream within 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.PostBuildBitstreamFcn = ... 

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_PostBuildBitstream, located in the reference design package folder +my_reference_design.

With this callback function, you can specify custom settings when HDL Coder™ runs the build process and generates the bitstream. This example code shows how to create the callback function. The function displays the status after running the task, and the board and reference design information.

function [status, log] = callback_PostBuildBitstream(infoStruct)
% Reference design callback run at the end of the task Build FPGA Bitstream
% 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.BitstreamPath: the path to generated FPGA bitstream file
% status: process run status
%         status == true means process run successfully
%         status == false means process run failed
% log:    output log string

status = false;
log = sprintf('Run post build bitstream callback\n%s\n%s\n', infoStruct.HDLModelDutPath, infoStruct.BitstreamPath);

% Exporting the InfoStruct Contents
% ...
% ...


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 specify custom settings for the build process and bitstream generation.

Version History

Introduced in R2016b