When you define your custom reference design, you can optionally
use the properties in the hdlcoder.ReferenceDesign
object to define
custom parameters and callback functions.
This MATLAB® code shows how to define custom parameters and register the function handle of the custom callback functions in the reference design definition function.
function hRD = plugin_rd() % Reference design definition % Construct reference design object hRD = hdlcoder.ReferenceDesign('SynthesisTool', 'Xilinx Vivado'); hRD.ReferenceDesignName = 'My Reference Design'; hRD.BoardName = 'ZedBoard'; % Tool information hRD.SupportedToolVersion = {'2015.4'}; %% Add custom design files % ... % ... %% Add custom parameters by using addParameter property. These are optional. % Specify custom 'DUT path' and 'Channel Mapping' parameters. The parameters get % populated in the 'Set Target Reference Design' task in the HDL Workflow Advisor. hRD.addParameter( ... 'ParameterID', 'DutPath', ... 'DisplayName', 'Dut Path', ... 'DefaultValue', 'Rx', ... 'ParameterType', hdlcoder.ParameterType.Dropdown, ... 'Choice', {'Rx', 'Tx'}); hRD.addParameter( ... 'ParameterID', 'ChannelMapping', ... 'DisplayName', 'Channel Mapping', ... 'DefaultValue', '1'); %% Add custom callback functions. These are optional. % With the callback functions, you can enable custom validations, customize the % project creation, software interface model generation, and the bistream build. % Register the function handle of these callback functions. % Specify an optional callback for 'Set Target Reference Design' task in Workflow Advisor. % Use the property name 'PostTargetReferenceDesignFcn'. hRD.PostTargetReferenceDesignFcn = ... @my_reference_design.callback_PostTargetReferenceDesign; % Specify an optional callback for 'Set Target Interface' task in Workflow Advisor. % Use the property name 'PostTargetInterfaceFcn'. hRD.PostTargetInterfaceFcn = ... @my_reference_design.callback_PostTargetInterface; % Specify an optional callback for 'Create Project' task % Use the property name 'PostCreateProjectFcn' for the ref design object. hRD.PostCreateProjectFcn = ... @my_reference_design.callback_PostCreateProject; % Specify an optional callback for 'Generate Software Interface Model' task % Use the property name 'PostSWInterfaceFcn' for the ref design object. hRD.PostSWInterfaceFcn = ... @my_reference_design.callback_PostSWInterface; % Specify an optional callback for 'Build FPGA Bitstream' task % Use the property name 'PostBuildBitstreamFcn' for the ref design object. hRD.PostBuildBitstreamFcn = ... @my_reference_design.callback_PostBuildBitstream; % Specify an optional callback for 'Program Target Device' % task to use a custom programming method. hRD.CallbackCustomProgrammingMethod = ... @my_reference_design.callback_CustomProgrammingMethod; %% Add interfaces % ... % ...
With the addParameter
method of the hdlcoder.ReferenceDesign
class,
you can define custom parameters. In the preceding example, the reference
design defines two custom parameters, DUT Path
and Channel
Mapping
. To learn more about the addParameter
method,
see hdlcoder.ReferenceDesign.addParameter
When you open the HDL Workflow Advisor, HDL Coder populates the Set Target Reference Design task with the reference design name, tool version, and the custom parameters that you specify.
HDL Coder™ then passes these parameter values to the callback functions in the input structure.
If your synthesis tool is Xilinx® Vivado®, HDL Coder sets the reference design parameter values to variables. The variables are then input to the block design Tcl file. This code snippet is an example from the reference design project creation Tcl file.
update_ip_catalog set DutPath {Rx} set ChannelMapping {1} source vivado_custom_block_design.tcl
The code shows how HDL Coder sets the reference design parameters before sourcing the custom block design Tcl file.
In the reference design definition, you can register the function handle to reference the custom callback functions. You then can:
Enable custom validations.
Customize the reference design project creation settings.
Change the generated software interface model.
Customize the FPGA bitstream build process.
Specify custom FPGA programming method.
With the hdlcoder.ReferenceDesign
class, you
can define callback property names. The callback properties have a
naming convention. The callback functions can have any name. In the
HDL Workflow Advisor, you can define callback functions to customize
these tasks.
Workflow Advisor Task | Callback Property Name | Functionality |
---|---|---|
Set Target Reference Design | PostTargetReferenceDesignFcn | Enable custom validations. For an example that shows
how you can validate that the Reset type is |
Set Target Interface | PostTargetInterfaceFcn | Enable custom validations. For an example that shows
how you can validate not choosing a certain interface for a certain
custom parameter setting, see |
Create Project | PostCreateProjectFcn | Specify custom settings when HDL Coder creates the
project. For an example, see |
Generate Software Interface Model | PostSWInterfaceFcn | Change the generated software interface model. For an
example, see |
Build FPGA Bitstream | PostBuildBitstreamFcn | Specify custom settings when you build the FPGA bitstream.
For an example, see |
Program Target Device | CallbackCustomProgrammingMethod | Specify a custom FPGA programming method. For an example,
see |
For each of the callback function that you want HDL Coder to execute after running a task, create a file that defines a MATLAB function with any name.
Make sure that the callback function has the documented input and output arguments.
Verify that the functions are accessible from the MATLAB path.
Register the function handle of the callback functions in the reference design definition function.
Follow the naming conventions for the callback property names.
To learn more about these callback functions, see hdlcoder.ReferenceDesign
.
hdlcoder.Board
| hdlcoder.ReferenceDesign