Fixed-Point Blockset | ![]() ![]() |
Common Block Features
For convenience, all the common block features are described in this section. These common features include:
Block Parameters
Many Fixed-Point Blockset blocks use the same parameters, which you configure through the block dialog box. The common block parameters are associated with these blockset features:
Block-specific parameters are described in the block reference pages.
Selecting the Data Type
For many fixed-point blocks, you need to associate data type information with numerical parameters and the output. You can associate data type information in these ways:
The numerical parameter values of some fixed-point blocks inherit the data type of an input signal or the output signal. Other blocks require that you specify the parameter data type explicitly with the Parameter data type parameter.
The output of some fixed-point blocks inherits the data type of the input signal. Other blocks require that you specify the output data type with the Output data type parameter. Still other blocks provide you with the option of inheriting the output data type (and scaling) information from a driving block, or specifying the data type.
For the latter case, you control how the output data type (and scaling) is specified with the Output data type and scaling parameter list. This list supports three choices: Specify via dialog
, Inherit via internal rule
, and Inherit via back propagation
. The parameter choices involving data type inheritance are designed to minimize specification burden. Note that some fixed-point blocks support only two of the three choices.
If you select Specify via dialog
, you must explicitly specify the output data type with the Output data type parameter.
If you select Inherit via internal rule
, the output data type is inherited from the input(s). The goal of the inheritance rule is to select the "natural" data type and scaling for the output. The specific rule that is used depends on the block operation. For example, if you are multiplying two signed 16-bit signals, the FixPt Product block produces the natural output of a signed 32-bit data type. An "unnatural" output is produced if the inputs have different signs and different sizes. In this case, some trial and error may be required to achieve satisfactory results. If you are adding signals, two natural choices for the output data type and scaling are possible: to preserve the precision or to prevent overflow. However, blocks only support one rule. For example, the FixPt Sum block preserves precision. If your goal is to prevent overflow, then you should manually configure the data type and scaling.
If you select Inherit via back propagation
, the output data type is inherited by back propagation. In many cases, you will find that the FixPt Data Type Propagation block provides you with the most flexibility when back propagating the data type.
The supported data types and default scaling are shown below.
The word size (in bits) of fixed-point data types is given as an argument to the data type. For example, sfix(16)
specifies a 16-bit signed generalized fixed-point number. Word sizes from 1 to 128 bits are supported.
Floating-point data types are IEEE-style and are specified as float('single')
for single-precision numbers and float('double')
for double-precision numbers. Nonstandard IEEE-style numbers are specified as float(TotalBits,ExpBits)
where TotalBits
is the total number of physical bits and ExpBits
is the number of exponent bits.
Note A default radix point is not included with the generalized fixed-point data type. Instead, the scaling must be explicitly specified as described below. |
For more information about supported data types and their default scaling, refer to Chapter 3, Data Types and Scaling.
Selecting the Scaling
For generalized fixed-point data types, you need to associate scaling information with numerical parameters and the output. You can associate scaling information in these ways:
The numerical parameter values of some fixed-point blocks inherit the scaling of an input signal or the output signal. Other blocks require that you specify the parameter scaling explicitly with the Parameter scaling parameter.
The output of some fixed-point blocks inherits the scaling of the input signal. Other blocks require that you specify the output scaling with the Output scaling parameter. Still other blocks provide you with the option of inheriting the output scaling (and data type) information from a driving block, or specifying the scaling.
For the latter case, you control how the output scaling (and data type) is specified with the Output data type and scaling parameter list. This list supports three choices: Specify via dialog
, Inherit via internal rule
, and Inherit via back propagation
. Note that some fixed-point blocks support only two of the three choices.
If you select Specify via dialog
, you must explicitly specify the output scaling with the Output scaling parameter. If you select Inherit via internal rule
, the output scaling is inherited from the input(s). If you select Inherit via back propagation
, the output scaling is inherited by back propagation; typically from the FixPt Data Type Propagation block. For information about the inheritance rules, refer to the description in Selecting the Data Type.
The supported scaling modes for generalized fixed-point data types are given below. Default scaling is used for all other fixed-point data types.
Note that some blocks provide a form of radix point-only scaling for constant vectors and constant matrices. Refer to Example: Constant Scaling for Best Precision for more information.
Locking the Output Scaling
If the Lock output scaling so autoscaling tool can't change it check box is checked, then the automatic scaling tool autofixexp
will not change the Output scaling parameter value. Otherwise, the automatic scaling tool is free to adjust the scaling. You can run autofixexp
directly from the command line, or through the Fixed-Point Blockset Interface tool, fxptdlg
.
Rounding
You can choose the rounding mode for the block operation with the Round toward parameter list. The available rounding modes are shown below.
Handling Overflows
Overflow handling for fixed-point numbers is specified with the Saturate to max or min when overflows occur check box. If checked, fixed-point overflow results saturate. Otherwise, overflow results wrap. Whenever a result saturates, a warning is displayed.
If the Override data type(s) with doubles check box is checked, then the Parameter data type and Output data type parameter values are ignored. Instead, parameters and outputs are represented using double-precision floating-point numbers. Also, any calculations are performed using floating-point arithmetic.
An exception to this rule is when parameters or outputs contain a bias. In this case, the bias is not ignored in subsequent fixed-point operations.
If the parameter and output data types are both floating-point, the check box is not available.
The minimum and maximum values produced by the simulation are logged if the Log minimums and maximums check box is checked. The logged values are stored in the FixPtSimRanges
global cell array in the MATLAB workspace. You can access these values with the showfixptsimranges
script or with the Fixed-Point Blockset Interface tool, fxptdlg
.
In addition to logging the minimum and maximum simulation values, overflow information is also logged. If an overflow occurs, then a warning, an error, or nothing occurs depending on how the Data Overflow parameter of Simulink's Simulation Parameters dialog box is configured.
![]() | The Block Dialog Box | Block Icon Labels | ![]() |