Main Content

Customize Floating-Point IP Configuration

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 the Altera 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 the TargetFrequency 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, click Settings.

    2. In the HDL Code Generation > Target 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 Tool Setup.

    3. In the HDL Code Generation > Floating Point pane, select Use Floating Point.

    4. Set Vendor Specific Floating Point Library to ALTERAFPFUNCTIONS.

  2. Specify the target frequency. In the Target pane, set Target 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. Click OK.

  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 the InitializeIPPipelinesToZero 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 the InitializeIPPipelinesToZero option set to true.

  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:

    fpconfig.VendorIPConfig

    • 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 the hdlcoder.createFloatingPointTargetConfig function. Then, use hdlset_param to save the configuration on the model.

    For example, to create a floating-point target configuration for the Altera 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, enter fpconfig.
    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 the TargetFrequency 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 the InitializeIPPipelinesToZero property of the fpconfig.VendorLibrarySettings property.

    For example, to set the InitializeIPPipelinesToZero property to false, enter:

    fpconfig.VendorLibrarySettings.InitializeIPPipelinesToZero = false;
    
    To see the library settings, enter fpconfig.VendorLibrarySettings.
    
    ans = 
    
      FrequencyDrivenMode with properties:
    
        InitializeIPPipelinesToZero: 0
    
    
    
    To avoid potential numerical mismatches in the HDL simulation, it is recommended to set InitializeIPPipelinesToZero to true.

  4. Specify the IP settings. Use the Latency and ExtraArgs input arguments of the VendorIPConfig.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, enter fpconfig.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 the ALTERA 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 the hdlcoder.createFloatingPointTargetConfig function. Then, use hdlset_param to save the configuration on the model.

    For example, to create a floating-point target configuration for the ALTERA 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 the Objective 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, enter fpconfig.VendorLibrarySettings.
    ans = 
    
      LatencyDrivenMode with properties:
    
        LatencyStrategy: 'MAX'
              Objective: 'AREA'

  3. Specify the IP settings. Use the Latency and ExtraArgs input arguments of the VendorIPConfig.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, enter fpconfig.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

| | |

Related Examples

More About