Using the Fixed-Point Tool, you can now derive ranges for variables inside a MATLAB^{®} Function block in Simulink^{®}. The Fixed-Point Tool uses design ranges to derive ranges for MATLAB variables in a MATLAB Function block. The tool can also propose data types for the variables based on the derived range data. You must manually apply the proposed data types to the variables. For more information, see Derive Ranges of MATLAB Function Block Variables.
The following enhancements have been added to the Fixed-Point Converter app:
You can now specify multiple entry-point functions in a Fixed-Point Converter app project. If your end goal is to generate fixed-point C/C++ library functions, conversion with multiple entry-point functions facilitates integration with larger applications. For more information, see Generate Fixed-Point MATLAB Code for Multiple Entry-Point Functions.
You can now specify global variables in the Fixed-Point Converter app workflow and convert algorithms which contain global variables without modifying your code. For more information, see Convert Code Containing Global Variables to Fixed-Point.
The Fixed-Point Converter app now detects dead and constant folded code within your project and warns you if any parts of your code were not executed during the simulation of your test file. This can help you verify if your test file is testing the algorithm over the intended operating range. The app uses this code coverage information during the translation of your code from floating-point MATLAB code to fixed-point MATLAB code. The app inserts inline comments in the fixed-point code to mark the dead and untranslated regions and includes the code coverage information in the generated fixed-point conversion html report. This code coverage information is also available from the command-line workflow. For more information, see Detect Dead and Constant-Folded Code.
Using the -tocode
option of the fixedPointConverter
command,
you can convert a fixed-point conversion project to the equivalent MATLAB code
in a MATLAB script. You can use the script to repeat the project
workflow in a command-line workflow. For more information, see Convert Fixed-Point Conversion Project to MATLAB Scripts.
The generated fixed-point code now:
Uses colon syntax for multi-output assignments, reducing
the number of fi
casts in the generated fixed-point
code.
Preserves the indentation and formatting of your original algorithm, improving the readability of the generated fixed-point code.
The Fixed-Point Converter app has been integrated into the new MATLAB Coder™ app workflow. This integration allows for a smoother conversion process from floating-point MATLAB code to fixed-point C/C++ code.
You can now convert the following DSP System Toolbox™ System objects to fixed-point using the Fixed-Point Converter app:
dsp.FIRFilter
,
direct form and direct form transposed only
You can propose and apply data types for these System objects based on simulation range data. During the conversion process, you can view simulation minimum and maximum values and proposed data types for these System objects. You can also view whole number information and histogram data. You cannot propose data types for these System objects based on static range data. This requires a DSP System Toolbox license.
The Simulink SimState
feature allows
you to save all run-time data necessary for restoring the simulation
state of the model. A SimState
includes both the
logged and internal state of every block and the internal state of
the Simulink engine. The Fixed-Point Tool now supports SimState
logging
while fixed-point instrumentation is turned on. For more information,
see Save and Restore Simulation State as SimState.
When a non-tunable structure is assigned to a bus signal (such as a block which uses a structure for its initial condition parameter), the data type of the fields of the structure no longer need to match the data type of the bus elements. The software now performs an automatic casting of the data type of the structure field so that it matches the data type of the bus signal. This flexible structure assignment simplifies the fixed-point conversion workflow by automatically casting the data type of the fields of the structure when using data type override and autoscaling your model.
eye(m,'like',a)
syntax supported for fixed-point
inputsThe eye
function
now works with fixed-point data types as well as built-in data types.
The function can now return an output whose class matches that of
a specified numeric variable or fi
object. For
built-in data types, the output assumes the numeric data type, sparsity,
and complexity (real or complex) of the specified numeric variable.
For fi
objects, the output assumes the numerictype
,
complexity (real or complex), and fimath
of the
specified fi
object.
The coder.approximation
function
now offers a 'Flat'
interpolation method for generating
lookup table MATLAB function replacements. This fully-specified
lookup table achieves high speeds by discarding the pre-lookup step
and reducing the use of multipliers in the data path. This interpolation
method is available from both the command-line workflow, and in the Function
Replacements tab of the Fixed-Point Converter app.
Fixed-point scaling information is added to the code generation report in the Code Interface Report section. Better accessibility to this information makes it easier for you to integrate with generated code containing fixed-point data types. Each fixed-point entry in the report table has a value in the new Scaling column giving its data type and fraction length using Simulink fixed-point data type notation.
Access to the Code Interface Report requires an Embedded Coder^{®} license.
The Fixed-Point Converter app enables you to convert floating-point MATLAB code to fixed-point MATLAB code.
You can choose to propose data types based on simulation range data, static range data, or both.
During fixed-point conversion, you can:
Propose fraction lengths based on default word lengths.
Propose word lengths based on default fraction lengths.
Optimize whole numbers.
Specify safety margins for simulation min/max data.
Test numerics by running the test file with the fixed-point types applied.
Compare floating-point and fixed-point test results using the Simulation Data Inspector or your own plotting functions.
View a histogram of bits used by each variable.
Specify replacement functions and generate approximate functions for functions in the original MATLAB algorithm that are not supported for fixed point.
To open the app:
In the MATLAB Toolstrip, on the Apps tab, under Code Generation, click .
At the MATLAB command prompt, enter fixedPointConverter
.
For more information, see Fixed-Point Converter.
You can now use the DataTypeWorkflow.Converter
class
to collect simulation and derived data, propose and apply data types
to the model, and analyze results.
This class performs the same fixed-point conversion tasks as the Fixed-Point Tool. This facilitates scripting of the automatic conversion workflow and accessing data for analysis. For more information, see Convert a Model to Fixed Point Using the Command-Line.
You can now convert the following DSP System Toolbox System objects to fixed point using the Fixed-Point Converter app.
You can propose and apply data types for these System objects based on simulation range data. During the conversion process, you can view simulation minimum and maximum values and proposed data types for these System objects. You can also view whole number information and histogram data. You cannot propose data types for these System objects based on static range data. This requires a DSP System Toolbox license. For more information, see Convert a System object to Fixed-Point Using the Fixed-Point Converter App.
The Fixed-Point Tool can now collect and display simulation ranges for variables inside a MATLAB Function block. The tool can also propose data types for the variables based on the simulation data. You must manually apply the proposed data types to the variables. For more information, see Convert Model Containing MATLAB Function Block to Fixed Point.
You can now separately control the diagnostics for overflows
that wrap and overflows that saturate by setting each diagnostic to error
, warning
,
or none
. These controls simplify debugging
models in which only one type overflow is of interest. For example,
if you need to detect only overflows that wrap, in the Data
Validity pane of the Configuration Parameters dialog box
you can set Wrap on overflow to error
or warning
,
and set Saturate on overflow to none
.
You can now highlight potential data type issues in the generated HTML report. The report highlights MATLAB code that requires single-precision, double-precision, or expensive fixed-point operations. The expensive fixed-point operations check identifies optimization opportunities by highlighting expressions in the MATLAB code that require cumbersome multiplication or division, or expensive rounding.
For more information, see Find Potential Data Type Issues in Generated Code
Fixed-point data types are now supported as for-loop indices
in codegen
. This capability requires a MATLAB Coder license.
For more information, see for
.
This new option improves the numerical accuracy and the readability of the C code generated for certain fixed-point conversions having nonbinary net slopes. Normally, net slope computation uses an integer multiplication followed by shifts. Enabling this optimization replaces the multiply and shift operation with a multiply and divide sequence that uses a rational number under certain simplicity and accuracy conditions.
For example, applying a net slope of 0.9, which traditionally would have generated
Vc = (int16_T)(Va * 115 >> 7);
Vc = (int16_T)(Va * 9/10);
This option prevents the Fixed-Point Tool from automatically changing the column view of the contents pane. To enable this option, in the Fixed-Point Tool menu, click View > Lock Column View. This setting is preserved across sessions.
Improved support for interaction with Simulink data objects, including bus objects
Block replacement recommendations for blocks with CORDIC support
The hdlram
System object™ has been renamed hdl.RAM
.
This System object no longer requires a Fixed-Point Designer™ license.
If you open a design that uses hdlram
, the software
displays a warning. For continued compatibility with future releases,
replace instances of hdlram
with hdl.RAM
.
Signals using fixed-point data types with slope and bias scaling
now always display the slope value in the data type name. In previous
releases, the display decomposed the slope into slope adjustment factor
and fixed exponent when it led to a more compact string. For example,
the data type fixdt(1,32,0.01953125,0)
now gets
the name sfix32_S0p01953125
. In previous releases,
the name was in the decomposed format sfix32_F1p25_en6
.
The string representation of numerictype
and fixdt
objects
returned by the tostring
function
now use 0
and 1
to represent
signedness rather than true
and false
.
T = numerictype(true,16,15); T.tostring
ans = numerictype(1,16,15)
numerictype
objects.
The string changes for this release do not change the object that
the strings are converted to. To convert a data type name string to
an object, pass the string as the input argument to fixdt
or numerictype
.
For example, fixdt('sfix32_S0p01953125')
and fixdt('sfix32_F1p25_En6')
return
identical numerictype
objects. To convert the
results of the tostring
function back to an object,
use the eval
function.
For example, the numerictype
objects returned by eval('numerictype(1,16,15)')
and eval('numerictype(true,16,15)')
are
identical.If your code converts data type strings to objects before doing
any processing, then you will not have any compatibility issues related
to the string changes. If you depend on the exact text returned by
the tostring
function or the exact text of a Simulink data
type name, then you must modify your code to account for the changes
described here. Alternatively, you can convert the string to a numerictype
object
before doing any additional processing.
The Fixed-Point Conversion Using Fixed-Point Tool and Derived Range Analysis example demonstrates using derived range analysis and the Fixed-Point Tool to convert a corner detection model to fixed point.
You can now apply data type override to models and subsystems that use virtual and non-virtual buses. The bus element types obey the data type override settings. This capability allows you to:
Obtain the idealized floating-point behavior of models that use buses.
Obtain the ideal derived ranges for models that use buses.
Easily compare the idealized floating-point behavior with the fixed-point behavior of models that use buses.
Use data type override to share fixed-point models that use buses with users who do not have a fixed-point license.
You can autoscale models that use virtual and non-virtual buses. This capability facilitates fixed-point conversion and optimization of models. The Fixed-Point Tool automatically proposes fixed-point data types for bus elements which removes the need to perform manual analysis and conversion of bus element data types.
For more information, see Refine Data Types of a Model with Buses Using Simulation Data.
Using the Fixed-Point Tool, you can now derive ranges for complex signals in Simulink. For more information, see Conversion Using Range Analysis.
cordicsqrt
function for fixed-point CORDIC-based
square root functionalityThe cordicsqrt
function provides a CORDIC-based
approximation of square root for use in fixed-point applications.
For more information, see cordicsqrt
and Compute
Square Root Using CORDIC.
The MATLAB Coder Fixed-Point Conversion tool now provides the capability to detect overflows. At the numerical testing stage in the conversion process, the tool simulates the fixed-point code using scaled doubles. It then reports which expressions in the generated code produce values that would overflow the fixed-point data type. For more information, see Detect Overflows Using the Fixed-Point Conversion Tool and Detecting Overflows.
You can also detect overflows when using the codegen
function.
For more information, see coder.FixptConfig
and Detect
Overflows at the Command Line.
These capabilities require a MATLAB Coder license.
Fixed-point ARM^{®} Cortex^{®}-M code replacement library support
is now available for the Discrete FIR block and the dsp.FIRFilter
System
object.
These capabilities require a DSP System Toolbox license.
The Fixed-Point Advisor now supports referenced configuration sets. For more information, see Preparing for Data Typing and Scaling.
R2014a includes the following enhancements to the fixed-point conversion capability in MATLAB Coder projects.
These capabilities require a MATLAB Coder license.
You can now use the MATLAB Coder Fixed-Point Conversion tool to convert floating-point MATLAB code that uses MATLAB classes. For more information, see Fixed-Point Code for MATLAB Classes.
The generated fixed-point code now:
Uses subscripted assignment (the colon(:) operator). This enhancement produces concise code that is more readable.
Has better code for constant expressions. In previous releases, multiple parts of an expression were quantized to fixed point. The final value of the expression was less accurate and the code was less readable. Now, constant expressions are quantized only once at the end of the evaluation. This new behavior results in more accurate results and more readable code.
For more informations, see Generated Fixed-Point Code.
In R2014a, when you convert floating-point MATLAB code
to fixed-point C/C++ code, the code generation software generates
a fixed-point report in HTML format. For the variables in your MATLAB code,
the report provides the proposed fixed-point types and the simulation
or derived ranges used to propose those types. For a function, my_fcn
,
and code generation output folder, out_folder
,
the location of the report is out_folder/my_fcn/fixpt/my_fcn_fixpt_Report.html
.
If you do not specify out_folder
in the project
settings or as an option of the codegen
command,
the default output folder is codegen
.
In earlier releases, to set up a compiler before using fiaccel
to
accelerate MATLAB algorithms, you were required to run mex
-setup
. Now, the code generation software automatically
locates and uses a supported installed compiler. You can use mex
-setup
to change the default compiler. See Changing
Default Compiler.
For all dsp.LMSFilter
System
object fixed-point settings, you can now specify independent fixed-point
data types.
This capability requires a DSP System Toolbox license.
Range analysis supports For Each and For Each Subsystem blocks, with the following limitations:
When For Each Subsystem contains another For Each Subsystem, not supported.
When For Each Subsystem contains one or more Simulink Design Verifier™ Test Condition, Test Objective, Proof Assumption, or Proof Objective blocks, not supported.
If your target hardware and your compiler support the C99 long long integer data type, you can use this data type for code generation. Using long long results in more efficient generated code that contains fewer cumbersome operations. Multi-line fixed-point helper functions can be replaced by simple expressions. This data type also provides more accurate simulation results for fixed-point and integer simulations. If you are using Microsoft^{®} Windows^{®} (64-bit), using long long improves performance for many workflows including:
Using Accelerator mode in Simulink
Working with Stateflow^{®} software
Generating C code with Simulink Coder
Accelerating fixed-point code using fiaccel
Generating C code and MEX functions with MATLAB Coder
For more information about enabling long long in Simulink, see the Enable long long and Number of bits: long long configuration parameters on the Hardware Implementation Pane.
For more information about enabling long long for MATLAB Coder,
see coder.HardwareImplementation
.
The Model Advisor fixed-point checks now cover additional blocks
in base Simulink and System Toolboxes. The checks also now include
the MATLAB Function block, System objects, Stateflow,
and fi
objects. These improved checks consider
model settings such as hardware configuration and code generation
settings. These updated checks also avoid false negative results.
These checks require an Embedded Coder license.
fi
object as an index in colon expressions
and an argument to numel
and bit index functionsYou can now use fi
objects in colon expressions.
When you use fi
in a colon expression, all colon
operands must have integer values. See the fi
and colon
reference
pages for examples.
The bitget
, bitset
, bitsliceget
, bitandreduce
, bitorreduce
,
and bitxorreduce
functions
now accept fi
objects as the bit index argument.
The bitsra
, bitsrl
, bitsll
, bitrol
,
and bitror
functions
now accept fi
objects as the shift-value input
argument. You can use fi
and built-in data type
shift values interchangeably in MATLAB functions. This new capability
facilitates fixed-point conversion.
Effective R2013b, the numel
function returns
the number of elements in a fi
array. Using numel
in
your MATLAB code returns the same result for built-in types and fi
objects.
Use numel
to write data-type independent MATLAB code
for array handling; you no longer need to use the numberofelements
function.
The numel
function is supported for simulation
and code generation and with the MATLAB Function block
in Simulink.
For more information, see numel
.
Blocks in the Lookup Tables library have a new internal rule
for fixed-point data types to enable faster hardware instructions
for intermediate calculations (with the exception of the Direct
Lookup Table (n-D), Prelookup and Lookup
Table Dynamic blocks). To use this new rule, select Speed
for
the Internal Rule Priority parameter in the dialog
box. To use the R2013a internal rule, select Precision
.
Using the Fixed-Point Conversion tool in MATLAB Coder projects, you can now derive ranges for complex variables. For more information, see Propose Data Types Based on Derived Ranges. This capability requires a MATLAB Coder license.
Fixed-Point Designer now uses strict single-precision algorithms for operations between singles and integer or fixed-point data types. Operations, such as cast, multiplication and division, use single-precision math instead of introducing higher-precision doubles for intermediate calculations in simulation and code generation. You no longer have to explicitly cast integer or fixed-point inputs of these operations to single precision. To detect the presence of double data types in your model, use the Model Advisor Identify questionable operations for strict single-precision design check.
In R2013b, for both simulation and code generation, Fixed-Point Designer avoids the use of double data types to achieve strict single design for operations between singles and integers or fixed-point types. In previous releases, Fixed-Point Designer used double data types in intermediate calculations for higher precision. You might see a difference in numerical behavior of an operation between earlier releases and R2013b.
For example, when you cast from a fixed-point or integer data type to single or vice versa, the type used for intermediate calculations can significantly affect numerical results. Consider:
Input type: ufix128_En127
Input value: 1.999999999254942 — Stored integer
value is (2^128 -2^100)
.
Output type: single
Release | Calculation performed by Fixed-Point Designer | Output Result | Design Goal |
---|---|---|---|
R2013b | Y = single(2^-127) * single(2^128-2^100) = single(2^-127) * Inf | Inf | Strict singles |
Previous releases | Y = single( double(2^-127) * double(2^128 - 2^100)) = single(2^-127 * 3.402823656532e+38) | 2 | Higher-precision intermediate calculation |
There is also a difference in the generated code. Previously, Fixed-Point Designer allowed the use of doubles in the generated code for a mixed multiplication that used single and integer types.
m_Y.Out1 = (real32_T)((real_T)m_U.In1*(real_T)m_U.In2);
In R2013b, it uses strict singles.
m_Y.Out1=(real32_T)m_U.In1*m_U.In2;
You can revert to the numerical behavior of previous releases, if necessary. To do so, insert explicit casting from integer and fixed-point data types to doubles for the inputs of these operations.
You can now perform derived range analysis of your model on Mac platforms. For more information, see Conversion Using Range Analysis.
When generating a printable instrumentation report, you can
now choose to display only the tables that show information about
logged variables. Used with the -printable
option,
the -nocode
option suppresses display of the MATLAB code.
Displaying only the logged variable information is useful for large
projects with many lines of code.
-browser
optionThe showInstrumentationResults
function -browser
option
has been removed. Use the -printable
option instead.
The -printable
option creates a printable report
and opens it in the system browser.
For more information, see showInstrumentationResults
.
The Continuous Simulink blocks State-Space, Transfer Fcn, and Zero-Pole are not supported and not stubbable for range analysis. For more information on blocks that are supported for range analysis, see Supported and Unsupported Simulink Blocks.
If you have a model that contains one or more continuous State-Space, Transfer Fcn, or Zero-Pole blocks, your model is incompatible with range analysis. Consider analyzing smaller portions of your model to work around this incompatibility.
If you are using Microsoft Windows (64-bit), LCC-64
is now available as the default compiler. You no longer have to install
a separate compiler to perform fixed-point acceleration using fiaccel
.
fi
and fimath
property
names All fi
and fimath
property
names are case sensitive and require that you use the full property
names. Effective R2013b, if you use inexact property names, Fixed-Point Designer generates
a warning.
To avoid seeing warnings for fi
and fimath
properties,
update your code so that it uses the full names and correct cases
of all these properties. The full names and correct cases of the properties
appear when you display a fi
or fimath
object
on the MATLAB command line.
Simulink.Parameter
objectsYou can now convert a numeric variable into a Simulink.Parameter
object
using a single step.
myVar = 5; % Define numerical variable in base workspace myObject = Simulink.Parameter(myVar); % Create data object and assign variable value to data object value
Previously, you did this conversion using two steps.
myVar = 5; % Define numerical variable in base workspace myObject = Simulink.Parameter; % Create data object myObject.Value = myVar; % Assign variable value to data object value
The MATLAB Coder Fixed-Point Conversion tool now provides test file coverage results. After simulating your design using a test file, the tool provides an indication of how often the code is executed. If you run multiple test files at once, the tool provides the cumulative coverage. This information helps you determine the completeness of your test files and verify that they are exercising the full operating range of your algorithm. The completeness of the test file directly affects the quality of the proposed fixed-point types.
This capability requires a MATLAB Coder license.
For more information, see Code Coverage.
Using the Fixed-Point Conversion tool in MATLAB Coder projects, you can now propose data types for enumerated data types using derived and simulation ranges.
For more information, see Propose Fixed-Point Data Types Based on Derived Ranges and Propose Fixed-Point Data Types Based on Simulation Ranges. This capability requires a MATLAB Coder license.
Using the Fixed-Point Conversion tool in MATLAB Coder projects, you can propose data types for variable-size data using simulation ranges.
For more information, see Propose Fixed-Point Data Types Based on Simulation Ranges. This capability requires a MATLAB Coder license.
bitconcat
, bitandreduce
, bitorreduce
, bitxorreduce
, bitsliceget
functionsThe bitconcat
, bitandreduce
, bitorreduce
, bitxorreduce
,
and bitsliceget
functions
now check that all input arguments are real. If any inputs are complex,
these functions generate an error.
The bitconcat
function now generates an
error in the unary syntax case, bitconcat(a)
,
if the input argument a
is a scalar or is empty.
To use bitconcat
with one input argument, the argument
must have more than one array element available for bit concatenation
(that is, length(a)>1
).
In previous releases, the following functions returned a MATLAB structure describing a fixed-point data type:
Effective R2013b, they return a Simulink.NumericType object. If you have existing models that use these functions as parameters to dialog boxes, the models continue to run as before and there is no need to change any model settings.
These functions do not offer full Data Type Assistant support.
To benefit from this support, use fixdt
instead.
Function | Return Value in Previous Releases — MATLAB structure | Return Value Effective R2013b — NumericType |
---|---|---|
float('double') | Class: 'DOUBLE' | DataTypeMode: 'Double' |
float('single') | Class: 'SINGLE' | DataTypeMode: 'Single' |
sfix(16) | Class: 'FIX' IsSigned: 1 MantBits: 16 | DataTypeMode: 'Fixed-point: unspecified scaling' Signedness: 'Signed' WordLength: 16 |
ufix(7) | Class: 'FIX' IsSigned: 0 MantBits: 7 | DataTypeMode: 'Fixed-point: unspecified scaling' Signedness: 'Unsigned' WordLength: 7 |
sfrac(33,5) | Class: 'FRAC' IsSigned: 1 MantBits: 33 GuardBits: 5 | DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Signed' WordLength: 33 FractionLength: 27 |
ufrac(44) | Class: 'FRAC' IsSigned: 0 MantBits: 44 GuardBits: 0 | DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Unsigned' WordLength: 44 FractionLength: 44 |
sint(55) | Class: 'INT' IsSigned: 1 MantBits: 55 | DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Signed' WordLength: 55 FractionLength: 0 |
uint(77) | Class: 'INT' IsSigned: 0 MantBits: 77 | DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Unsigned' WordLength: 77 FractionLength: 0 |
MATLAB Code
MATLAB code that depends on the return arguments of these
functions being a structure with fields named Class, MantBits
or GuardBits
no
longer works correctly. Change the code to access the appropriate
properties of a NumericType
object, for example, DataTypeMode
, Signedness
, WordLength
, FractionLength
, Slope
and Bias
.
C Code
Update C code that expects the data type of parameters to be
a legacy structure to handle NumericType
objects
instead. For example, if you have S-functions that take legacy structures
as parameters, update these S-functions to accept NumericType
objects.
MAT-files
Effective R2013b, if you open a Simulink model that uses
a MAT-file that contains a data type specification created using the
legacy functions, the model uses the same data types and behaves in
the same way as in previous releases but Simulink generates a
warning. To eliminate the warning, recreate the data type specifications
using NumericType
objects and save the MAT-file.
You can use the fixdtupdate
function to
update a data type specified using the legacy structure to use a NumericType
.
For example, if you saved a data type specification in a MAT-file
as follows in a previous release:
oldDataType = sfrac(16); save myDataTypeSpecification oldDataType
fixdtUpdate
to
recreate the data type specification to use NumericType
:load DataTypeSpecification
fixdtUpdate(oldDataType)
ans = NumericType with properties: DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Signed' WordLength: 16 FractionLength: 15 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: ''
fixdtUpdate
The numberofelements
function
will be removed in a future release of Fixed-Point Designer software.
Use numel
instead.
The Fixed-Point Designer product replaces two pre-existing products: Fixed-Point Toolbox™ and Simulink Fixed Point™. You can access archived documentation for both products on the MathWorks^{®} Web site.
The buildInstrumentedMex
and showInstrumentationResults
instrumentation
functions now can generate log2 histograms. A histogram is generated
for each named and intermediate variable and for each expression in
your code. The code generation report Variables tab
includes a link to the histogram for each variable. You can use this
histogram to determine the word and fraction lengths for your fixed-point
values. Refer to the buildInstrumentedMex
and showInstrumentationResults
reference
pages for information.
fi
object in indexing and switch-case expressionsEffective this release, you can use fi
objects
as indices to arrays of built-in types and fi
types.
You can also use fi
objects in switch-case expressions.
These changes let you use fi
objects without having
to convert them. See the fi
reference
page for examples.
zeros
, ones
, and cast
code
reuse for floating-point and fixed-point typesThe zeros
, ones
, and cast
functions
now work with fixed-point data types as well as built-in data types.
The functions can now return an output whose class matches that of
a specified numeric variable or fi
object. For
built-in data types, the output assumes the numeric data type, sparsity,
and complexity (real or complex) of the specified numeric variable.
For fi
objects, the output assumes the numerictype
,
complexity (real or complex), and fimath
of the
specified fi
object.
For example:
>> a = fi([],1,24,12); >> c = cast(pi,'like',a) c = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 24 FractionLength: 12 >> z = zeros(2,3,'like',a) z = 0 0 0 0 0 0 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 24 FractionLength: 12 >> o = ones(2,3,'like',a) o = 1 1 1 1 1 1 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 24 FractionLength: 12
This capability allows you to cleanly separate algorithm code in MATLAB from data type specifications. Using separate data type specifications enables you to:
Reuse your algorithm code with different data types.
Switch easily between fixed-point and floating-point data types to compare fixed-point behavior to a floating-point baseline.
Try different fixed-point data types to determine their effect on the behavior of your algorithm.
Write clean, readable code.
For more information, see Implement FIR Filter Algorithm for Floating-Point and Fixed-Point Types using cast and zeros.
The Fixed-Point Advisor now performs checks on referenced models. It checks the entire model reference hierarchy against fixed-point guidelines. The Advisor also provides guidance about model configuration settings and unsupported blocks to help you prepare your model for conversion to fixed point.
You can now convert floating-point MATLAB code to fixed-point C code using the fixed-point conversion capability in MATLAB Coder projects. You can choose to propose data types based on simulation range data, static range data, or both.
Note: You must have a MATLAB Coder license. |
During fixed-point conversion, you can:
Propose fraction lengths based on default word lengths.
Propose word lengths based on default fraction lengths.
Optimize whole numbers.
Specify safety margins for simulation min/max data.
Validate that you can build your project with the proposed data types.
Test numerics by running the test file with the fixed-point types applied.
View a histogram of bits used by each variable.
For more information, see Propose Fixed-Point Data Types Based on Simulation Ranges and Propose Fixed-Point Data Types Based on Derived Ranges.
Autoscaling with the Fixed-Point Tool now handles data type constraints for virtual buses that do not have any associated bus objects. The data type proposals take into account the constraints introduced by these bus signals.
This improved autoscaling reduces data type mismatch errors. It also enables the Fixed-Point Tool to provide additional diagnostic information when you accept autoscaling proposals. For more information, see Shared Data Type Summary.
The data type override rules for MATLAB Function block
input signals and parameters have changed. If the input signals and
parameters are double
or single
,
and you specify data type override to be Double
or Single
,
the overridden data types are now built-in double
or
built-in single
, not fi double
and fi
single
as in previous releases. If the input signals and
parameters are fi
objects or fixed-point signals,
and you specify data type override to be Double
or Single
,
the overridden data types are fi double
and fi
single
as in previous releases. For more information, see MATLAB
Function Block with Data Type Override.
If you have MATLAB Function block code from previous
releases that contains special cases for fi double
or fi
single
, and you specify data type override to be Double
or Single
,
you might have to update this code to handle built-in double
and single
.
The buildInstrumentedMex
and showInstrumentationResults
instrumentation
functions now show instrumentation results for arrays of structs.
Each field of each struct is logged and appears in the code generation
report on the Variables tab.
The following file I/O functions are now supported for code acceleration and generation:
To view implementation details, see Functions Supported for Code Acceleration or Generation.
You can now accelerate code using fiaccel
for
local variables that contain references to handle objects or System
objects. In previous releases, accelerating code for these objects
was limited to objects assigned to persistent variables.
fiaccel
now supports a subset of the load
function
for loading run-time values from a MAT-file. It also provides a new
function, coder.load
,
for loading compile-time constants. This support facilitates code
generation from MATLAB code that uses load
to
load constants into a function. You no longer have to manually type
in constants that were stored in a MAT-file.
To view implementation details for the load
function,
see Functions
Supported for Code Acceleration or Generation.
To view implementation details, see Functions Supported for Code Acceleration or Generation.
The saveglobalfimathpref
will be removed
in a future release.
Do not save globalfimath
as a MATLAB preference.
If you have previously saved globalfimath
as a MATLAB preference,
use removeglobalfimathpref
to remove it.
The emlmex
function has been removed.
The emlmex
function generates an error
in R2013a. Use fiaccel
instead.