Products & Services Solutions Academia Support User Community Company

Learn more about Fixed-Point Toolbox   

fimath Object Properties

Math, Rounding, and Overflow Properties

You can always write to the following properties of fimath objects:

PropertyDescription
CastBeforeSum

Whether both operands are cast to the sum data type before addition

MaxProductWordLength

Maximum allowable word length for the product data type

MaxSumWordLength

Maximum allowable word length for the sum data type

OverflowMode

Overflow-handling mode

ProductBias

Bias of the product data type

ProductFixedExponent

Fixed exponent of the product data type

ProductFractionLength

Fraction length, in bits, of the product data type

ProductMode

Defines how the product data type is determined

ProductSlope

Slope of the product data type

ProductSlopeAdjustmentFactor

Slope adjustment factor of the product data type

ProductWordLength

Word length, in bits, of the product data type

RoundMode

Rounding mode

SumBias

Bias of the sum data type

SumFixedExponent

Fixed exponent of the sum data type

SumFractionLength

Fraction length, in bits, of the sum data type

SumMode

Defines how the sum data type is determined

SumSlope

Slope of the sum data type

SumSlopeAdjustmentFactor

Slope adjustment factor of the sum data type

SumWordLength

Word length, in bits, of the sum data type

For details about these properties, refer to the Property Reference. To learn how to specify properties for fimath objects in Fixed-Point Toolbox software, refer to Setting fimath Object Properties.

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 mode to saturate and the rounding mode to convergent,

F = fimath('OverflowMode','saturate','RoundMode','convergent')
 
F =
 

             RoundMode: convergent
          OverflowMode: saturate
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128
         CastBeforeSum: true

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 RoundMode of F,

F.RoundMode

ans =

convergent

To set the OverflowMode of F,

F.OverflowMode = 'wrap'
 
F =
 

             RoundMode: convergent
          OverflowMode: wrap
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128
         CastBeforeSum: true

Setting fimath Properties in the Model Explorer

You can view and change the properties for any fimath object defined in the MATLAB workspace in the Model Explorer. Open the Model Explorer by selecting View > Model Explorer in any Simulink model, or by typing daexplr at the MATLAB command line.

The following figure shows the Model Explorer when you define the following fimath objects in the MATLAB workspace:

F = fimath
 
F =
 

             RoundMode: nearest
          OverflowMode: saturate
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128
         CastBeforeSum: true

G = fimath('OverflowMode','wrap')
 
G =
 
             RoundMode: nearest
          OverflowMode: wrap
           ProductMode: FullPrecision
  MaxProductWordLength: 128
               SumMode: FullPrecision
      MaxSumWordLength: 128
         CastBeforeSum: true

Select the Base Workspace node in the Model Hierarchy pane to view the current objects in the Contents pane. When you select a fimath object in the Contents pane, you can view and change its properties in the Dialog pane.

For more information on working with the Model Explorer, see the following sections of the Fixed-Point Toolbox documentation:

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS