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:
Specify the vendor-specific floating-point library.
In the Apps tab, select HDL Coder. In the HDL Code tab, click Settings.
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
orIntel Quartus Pro
. For more information on synthesis tools, see Tool Setup.In the HDL Code Generation > Floating Point pane, select Use Floating Point.
Set Vendor Specific Floating Point Library to
ALTERAFPFUNCTIONS
.
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.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')
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 select Minimize global resets. For more information, see Minimize global resets.
In the HDL Code Generation > Global settings pane, in the Coding style tab set No-reset registers initialization to
Do not initialize
. For more information, see No-reset registers initialization.
Specify the IP settings. Use the
VendorIPConfig
property of thefpconfig
object to specify a custom latency and settings specific to the IP. To view theVendorIPConfig
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.
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:
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 the
Altera Megafunctions (ALTERA FP FUNCTIONS)
library with the default settings for the modelsfir_single
, enter:To see the default settings for the floating-point IP, enterfpconfig = hdlcoder.createFloatingPointTargetConfig("NativeFloatingPoint",... VendorFloatingPointLibrary="ALTERAFPFUNCTIONS"); hdlset_param('sfir_single', 'FloatingPointTargetConfiguration', fpconfig);
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]
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);
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 thefpconfig.VendorLibrarySettings
property.For example, to set the
InitializeIPPipelinesToZero
property to false, enter:To see the library settings, enterfpconfig.VendorLibrarySettings.InitializeIPPipelinesToZero = false;
fpconfig.VendorLibrarySettings
.To avoid potential numerical mismatches in the HDL simulation, it is recommended to setans = FrequencyDrivenMode with properties: InitializeIPPipelinesToZero: 0
InitializeIPPipelinesToZero
totrue
.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:To see the IP settings, enterfpconfig.VendorIPConfig.customize('ADDSUB', 'SINGLE', 'Latency', 8);
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 ''
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:
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 the
ALTERA MEGAFUNCTION (ALTFP)
library with the default settings for the modelsfir_single
, enter:By default, the library uses the minimum latency and speed objective for the floating-point IP.fpconfig = hdlcoder.createFloatingPointTargetConfig("NativeFloatingPoint",... VendorFloatingPointLibrary="ALTFP"); hdlset_param('sfir_single', 'FloatingPointTargetConfiguration', fpconfig);
Specify the library settings. Customize the library settings by setting the
Objective
andLatencyStrategy
properties of thefpconfig.VendorLibrarySettings
object.For example, to customize the
ALTERA MEGAFUNCTION (ALTFP)
library to use the maximum latency and objective as area, enter:To see the library settings, enterfpconfig.VendorLibrarySettings.Objective = 'AREA'; fpconfig.VendorLibrarySettings.LatencyStrategy = 'MAX';
fpconfig.VendorLibrarySettings
.ans = LatencyDrivenMode with properties: LatencyStrategy: 'MAX' Objective: 'AREA'
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 thecmultusage
parameter, enter:To see the IP settings, enterfpconfig.VendorIPConfig.customize('ADDSUB', 'SINGLE',... 'Latency', 8, 'ExtraArgs', 'CSET c_mult_usage=Full_usage');
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 ''
Generate HDL code. To generate code from the subsystem, use
makehdl
.
See Also
hdlcoder.FloatingPointTargetConfig
| createFloatingPointTargetConfig
| hdlcoder.FloatingPointTargetConfig.IPConfig
| customize
Related Examples
- FPGA Floating-Point Library IP Mapping
- Design Model by Using HDL Coder Native Floating Point and Intel Hard Floating Point