Main Content

CustomizeReferenceDesignFcn

Class: hdlcoder.ReferenceDesign
Namespace: hdlcoder

Function handle for callback function that gets executed before Set Target Interface task in the HDL Workflow Advisor

Since R2020a

Syntax

CustomizeReferenceDesignFcn

Description

CustomizeReferenceDesignFcn registers a function handle for the callback function that gets executed before Set Target Interface task in the HDL Workflow Advisor. By using this callback function, you can customize the block design Tcl file, reference design interfaces, reference design interface properties, and IP repositories in your reference design.

Tip

Before you use the callback function, in the plugin_rd.m file, you must define a reference design parameter by using the addParameter method of the hdlcoder.ReferenceDesign class.

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.CustomizeReferenceDesignFcn = @my_reference_design.customcallback_aximaster;

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

For example, you can specify whether you want an AXI4 Master or AXI4 only reference design. In the plugin_rd.m file, use the addParameter method to specify the different parameter choices as a dropdown.

% ...

% Parameter For  calling AXI4 master interface from Callback function

hRD.addParameter('ParameterID',     'interface_name', ...
                 'DisplayName',     'Reference_design_interface_name', ...
                 'DefaultValue',    'AXI4 Master',...
                 'ParameterType',   hdlcoder.ParameterType.Dropdown, ...
                 'Choice',          {'AXI4 Master','AXI4 Only'});

hRD.CustomizeReferenceDesignFcn = @my_reference_design.customcallback_aximaster;

% ...

In the callback function, you can dynamically change the reference design interfaces depending on the interface types. 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.

% Callback function to control AXI Master and AXI4 interface information dynamically

function customcallback_aximaster(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
% infoStruct.ReferenceDesignToolVersion: Reference design Tool Version set in 1.2 Task

hRD = infoStruct.ReferenceDesignObject;
paramStruct = infoStruct.ParameterStruct;
interface_name = paramStruct.interface_name;
  
    if strcmp(interface_name, 'AXI4 Only')    
        hRD.addAXI4SlaveInterface( ...
            'InterfaceConnection', 'axi_interconnect_2/M01_AXI', ...
            'BaseAddress',         '0x00000000', ...
            'MasterAddressSpace',  'hdlverifier_axi_master_0/axi4m', ...
            'InterfaceType',       'AXI4');
    
    % To validate IP repository and AXI4 master interface signals
    elseif strcmp(interface_name,'AXI4 Master') 
      hRD.addAXI4SlaveInterface( ...
        'InterfaceConnection', 'axi_interconnect_2/M01_AXI', ...
        'BaseAddress',         '0x00000000', ...
        'MasterAddressSpace',  'hdlverifier_axi_master_0/axi4m', ...
        'InterfaceType',       'AXI4');
   
    hRD.addAXI4MasterInterface(...
        'InterfaceID',         'AXI4 Master', ...
        'ReadSupport',          true, ...
        'WriteSupport',         true, ...
        'MaxDataWidth',         128, ...
        'AddrWidth',            32, ...
        'DefaultReadBaseAddr',  hex2dec('40000000'), ...
        'DefaultWriteBaseAddr', hex2dec('41000000'), ...
        'InterfaceConnection', 'axi_interconnect_1/S01_AXI',...
        'TargetAddressSegments', {{'mig_7series_0/memmap/memaddr',hex2dec('40000000'),hex2dec('40000000')}})
  
    end   
end

In the HDL Workflow Advisor, on the Set Target Reference Design task, when you select the custom reference design that you want to customize for the target board, HDL Coder™ populates the reference design parameters. Depending on the parameter choices such as the interface types you specify, the callback function is evaluated. After you run this task, when you select the Set Target Interface task, the target interfaces get populated in the Target platform interface table.

Version History

Introduced in R2020a