fimath Object Properties
Math, Rounding, and Overflow Properties
You can always write to the following properties of fimath
objects:
| Property | Description | Valid Values |
|---|---|---|
CastBeforeSum | Whether both operands are cast to the sum data type before addition |
Note This property is hidden when the
|
MaxProductWordLength | Maximum allowable word length for the product data type |
|
MaxSumWordLength | Maximum allowable word length for the sum data type |
|
OverflowAction | Action to take on overflow |
|
ProductBias | Bias of the product data type |
|
ProductFixedExponent | Fixed exponent of the product data type |
Note The |
ProductFractionLength | Fraction length, in bits, of the product data type |
Note The |
ProductMode | Defines how the product data type is determined |
|
ProductSlope | Slope of the product data type |
Note Changing one of these properties affects the others. |
ProductSlopeAdjustmentFactor | Slope adjustment factor of the product data type |
Note Changing one of these properties affects the others. |
ProductWordLength | Word length, in bits, of the product data type |
|
RoundingMethod | Rounding method |
|
SumBias | Bias of the sum data type |
|
SumFixedExponent | Fixed exponent of the sum data type |
Note The |
SumFractionLength | Fraction length, in bits, of the sum data type |
Note The |
SumMode | Defines how the sum data type is determined |
|
SumSlope | Slope of the sum data type |
Note Changing one of these properties affects the others. |
SumSlopeAdjustmentFactor | Slope adjustment factor of the sum data type |
Note Changing one of these properties affects the others. |
SumWordLength | Word length, in bits, of the sum data type |
|
For details about these properties, refer to the Set fi Object Properties. To learn how to
specify properties for fimath objects in Fixed-Point Designer™ software, refer to Setting fimath Object Properties.
How Properties are Related
Sum data type properties
The slope of the sum of two fi objects is related to the
SumSlopeAdjustmentFactor and
SumFixedExponent properties by
If any of these properties are updated, the others are modified accordingly.
In a FullPrecision sum, the resulting word length is
represented by
where
and
When the SumMode is set to KeepLSB, the
resulting word length and fraction length is determined by
When the SumMode is set to KeepMSB, the
resulting word length and fraction length is determined by
where
When the SumMode is set to
SpecifyPrecision, you specify both the word and fraction
length or slope and bias of the sum data type with the
SumWordLength and SumFractionLength,
or SumSlope and SumBias properties
respectively.
Product data type properties
The slope of the product of two fi objects is related to
the ProductSlopeAdjustmentFactor and
ProductFixedExponent properties by
If any of these properties are updated, the others are modified accordingly.
In a FullPrecision multiply, the resulting word length and
fraction length are represented by
When the ProductMode is KeepLSB the word
length and fraction length are determined by
When the ProductMode is KeepMSB the word
length and fraction length are
where
When the ProductMode is set to
SpecifyPrecision, you specify both the word and fraction
length or slope and bias of the product data type with the
ProductWordLength and
ProductFractionLength, or ProductSlope
and ProductBias properties respectively.
For more information about how certain functions use the
fimath properties, see
Setting fimath Object Properties
Setting fimath Properties at Object Creation
You can set properties of fimath objects at the time of
object creation by including properties after the arguments of the
fimath constructor function.
For example, to set the overflow action to Saturate and the
rounding method to Convergent,
F = fimath('OverflowAction','Saturate','RoundingMethod','Convergent')
F =
RoundingMethod: Convergent
OverflowAction: Saturate
ProductMode: FullPrecision
SumMode: FullPrecisionIn addition to creating a fimath object at the command
line, you can also set fimath properties using the
Insert fimath Constructor dialog box. For an example of
this approach, see Building fimath Object Constructors in a GUI.
Using Direct Property Referencing with fimath
You can reference directly into a property for setting or retrieving
fimath object property values using MATLAB® structure-like referencing. You do so by using a period to index
into a property by name.
For example, to get the RoundingMethod of
F,
F.RoundingMethod
ans =
'Convergent'To set the OverflowAction of F,
F.OverflowAction = 'Wrap'F =
RoundingMethod: Convergent
OverflowAction: Wrap
ProductMode: FullPrecision
SumMode: FullPrecision