Customize Floating-Point IP Configuration - MATLAB & Simulink (original) (raw)

Main Content

When mapping your Simulink® model to floating-point target libraries, you can create a floating-point target configuration with your own custom IP settings. To customize the IP settings, you can use an IP configuration table to choose from different combinations of IP names and data types. The table contains a list of IP types and additional columns that you can use to specify your own custom latency value and other IP settings.

The IP configuration depends on the library settings. The library settings are specific to the floating-point library that you choose. You can customize the IP latency by using the target frequency or the latency strategy setting.

Customize the IP Latency with Target Frequency

To specify the target frequency that you want the IP to achieve, use theAltera Megafunctions (ALTERA FP Functions) library. HDL Coder™ infers the latency of the IP based on the target frequency value. If you do not specify the target frequency, HDL Coder sets the target frequency to 200 MHz.

You can customize the IP latency by using the Target Frequency (MHz) parameter in the Configuration Parameters dialog box or theTargetFrequency property from the command line.

Customize the IP Latency in the Configuration Parameters Window

To customize the IP latency by using the Target Frequency (MHz) parameter:

  1. Specify the vendor-specific floating-point library.
    1. In the Apps tab, select HDL Coder. In the HDL Code tab, clickSettings.
    2. In the > pane, set Synthesis Tool to the synthesis tool of your choice. To use the Altera Megafunctions (ALTERA FP Functions) library, set Synthesis Tool to Altera Quartus II or Intel Quartus Pro. For more information on synthesis tools, see Set Up Tools.
    3. In the > pane, select Use Floating Point.
    4. Set Vendor Specific Floating Point Library toALTERAFPFUNCTIONS.
  2. Specify the target frequency. In the Target pane, setTarget Frequency (MHz) to the target frequency that you want the floating-point IP to achieve. If you do not specify a target frequency, HDL Coder sets the target frequency to 200 MHz. ClickOK.
  3. To specify the vendor specific library settings, get the model floating-point target configuration object, hdlcoder.FloatingPointTargetConfig, by using this command:
    fpconfig = hdlget_param(gcs, 'FloatingPointTargetConfiguration')
  4. Specify the vendor-specific floating-point library settings. Use the floating point target configuration object fpconfig to set theInitializeIPPipelinesToZero property which specifies whether to initialize pipeline registers in the IP to zero. To avoid potential numerical mismatches in the HDL simulation, it is recommended to leave theInitializeIPPipelinesToZero option set totrue.
    Note
    To avoid adding additional logic during HDL code generation that initializes the values of pipeline registers in Native Floating Point IP to zero, in the Configuration Parameters dialog box:
    • In the HDL Code Generation > Global settings pane, in the Ports tab selectMinimize global resets. For more information, seeMinimize global resets.
    • In the HDL Code Generation > Global settings pane, in the Coding style tab setNo-reset registers initialization to Do not initialize. For more information, see No-reset registers initialization.
  5. Specify the IP settings. Use the VendorIPConfig property of the fpconfig object to specify a custom latency and settings specific to the IP. To view the VendorIPConfig table, use this command:
    • In the Latency column, the default latency value of–1 means that the IP inherits the latency value from the target frequency. If you specify a latency value, HDL Coder tries to map your Simulink model to the IP at a target frequency corresponding to that latency value.
    • In the ExtraArgs column, you can specify additional settings specific to the IP.
  6. Generate code. In Simulink, in the HDL Coder tab, click Generate HDL Code.

Customize the IP Latency Programmatically

To customize the IP latency from the command line:

  1. Specify the library. Create a hdlcoder.FloatingPointTargetConfig object for the floating-point library by using thehdlcoder.createFloatingPointTargetConfig function. Then, usehdlset_param to save the configuration on the model.
    For example, to create a floating-point target configuration for theAltera Megafunctions (ALTERA FP FUNCTIONS) library with the default settings for the model sfir_single, enter:
    fpconfig = hdlcoder.createFloatingPointTargetConfig("NativeFloatingPoint",...
    VendorFloatingPointLibrary="ALTERAFPFUNCTIONS");
    hdlset_param('sfir_single', 'FloatingPointTargetConfiguration', fpconfig);
    To see the default settings for the floating-point IP, enterfpconfig.
    fpconfig =
    FloatingPointTargetConfig with properties:
    Library: 'NATIVEFLOATINGPOINT'
    LibrarySettings: [1×1 fpconfig.NFPLatencyDrivenMode]
    IPConfig: [1×1 hdlcoder.FloatingPointTargetConfig.IPConfig]
    VendorLibrary: 'ALTERAFPFUNCTIONS'
    VendorLibrarySettings: [1×1 fpconfig.FrequencyDrivenMode]
    VendorIPConfig: [1×1 hdlcoder.FloatingPointTargetConfig.IPConfig]
  2. Specify the target frequency. If you choose ALTERA MEGAFUNCTION (ALTERA FP FUNCTIONS) as the vendor-specific floating-point library, you can create a floating-point configuration with a custom target frequency. To specify the target frequency for the IP to achieve, use theTargetFrequency property. For example:
    hdlset_param('sfir_single', 'TargetFrequency', 300);
  3. Specify the vendor-specific floating-point library settings. Specify whether you want to initialize the pipeline registers in the IP to zero. Use theInitializeIPPipelinesToZero property of thefpconfig.VendorLibrarySettings property.
    For example, to set the InitializeIPPipelinesToZero property to false, enter:
    fpconfig.VendorLibrarySettings.InitializeIPPipelinesToZero = false;
    To see the library settings, enterfpconfig.VendorLibrarySettings.
    ans =
    FrequencyDrivenMode with properties:
    InitializeIPPipelinesToZero: 0
    To avoid potential numerical mismatches in the HDL simulation, it is recommended to set InitializeIPPipelinesToZero totrue.
  4. Specify the IP settings. Use the Latency andExtraArgs input arguments of theVendorIPConfig.customize method to customize the latency of the IP and specify additional settings specific to the IP.
    For example, when mapping to the ADDSUB IP with Xilinx® LogiCORE libraries, to specify a custom latency of 8:
    fpconfig.VendorIPConfig.customize('ADDSUB', 'SINGLE', 'Latency', 8);
    To see the IP settings, enterfpconfig.VendorIPConfig.
    ans =
    Name DataType Latency ExtraArgs
    'ABS' 'DOUBLE' -1 ''
    'ABS' 'SINGLE' -1 ''
    'ADDSUB' 'DOUBLE' -1 ''
    'ADDSUB' 'SINGLE' 8 ''
    'CONVERT' 'DOUBLE_TO_NUMERICTYPE' -1 ''
    'CONVERT' 'NUMERICTYPE_TO_DOUBLE' -1 ''
    'CONVERT' 'NUMERICTYPE_TO_SINGLE' -1 ''
    'CONVERT' 'SINGLE_TO_NUMERICTYPE' -1 ''
  5. Generate HDL code. To generate code from the subsystem, use makehdl.

Customize the IP Latency with Latency Strategy

To customize the IP latency with the latency strategy setting, use theALTERA MEGAFUNCTION (ALTFP) or XILINX LOGICORE libraries. Specify whether to map your Simulink model to maximum or minimum latency. HDL Coder infers the latency of the IP from the latency strategy setting.

To customize the IP latency from the command line:

  1. Specify the library. Create a hdlcoder.FloatingPointTargetConfig object for the floating-point library by using thehdlcoder.createFloatingPointTargetConfig function. Then, usehdlset_param to save the configuration on the model.
    For example, to create a floating-point target configuration for theALTERA MEGAFUNCTION (ALTFP) library with the default settings for the model sfir_single, enter:
    fpconfig = hdlcoder.createFloatingPointTargetConfig("NativeFloatingPoint",...
    VendorFloatingPointLibrary="ALTFP");
    hdlset_param('sfir_single', 'FloatingPointTargetConfiguration', fpconfig);
    By default, the library uses the minimum latency and speed objective for the floating-point IP.
  2. Specify the library settings. Customize the library settings by setting theObjective and LatencyStrategy properties of the fpconfig.VendorLibrarySettings object.
    For example, to customize the ALTERA MEGAFUNCTION (ALTFP) library to use the maximum latency and objective as area, enter:
    fpconfig.VendorLibrarySettings.Objective = 'AREA';
    fpconfig.VendorLibrarySettings.LatencyStrategy = 'MAX';
    To see the library settings, enterfpconfig.VendorLibrarySettings.
    ans =
    LatencyDrivenMode with properties:
    LatencyStrategy: 'MAX'
    Objective: 'AREA'
  3. Specify the IP settings. Use the Latency andExtraArgs input arguments of theVendorIPConfig.customize method to customize the latency of the IP and specify additional settings specific to the IP.
    For example, when mapping to the ADDSUB IP with Xilinx LogiCORE libraries, to use a custom latency of 8 and specify the DSP resource usage with the cmultusage parameter, enter:
    fpconfig.VendorIPConfig.customize('ADDSUB', 'SINGLE',...
    'Latency', 8, 'ExtraArgs', 'CSET c_mult_usage=Full_usage');
    To see the IP settings, enterfpconfig.VendorIPConfig.
    ans =
    Name DataType MinLatency MaxLatency Latency ExtraArgs
    'ADDSUB' 'DOUBLE' 7 14 -1 ''
    'ADDSUB' 'SINGLE' 7 14 8 'CSET c_mult_usage=Full_usage'
    'CONVERT' 'DOUBLE_TO_NUMERICTYPE' 6 6 -1 ''
    'CONVERT' 'NUMERICTYPE_TO_DOUBLE' 6 6 -1 ''
    'CONVERT' 'NUMERICTYPE_TO_SINGLE' 6 6 -1 ''
  4. Generate HDL code. To generate code from the subsystem, use makehdl.

See Also

hdlcoder.FloatingPointTargetConfig | createFloatingPointTargetConfig | hdlcoder.FloatingPointTargetConfig.IPConfig | customize

Topics