Products & Services Solutions Academia Support User Community Company

Learn more about Fixed-Point Toolbox   

Constructing fimath Objects

fimath Object Syntaxes

When attached to a fi object, fimath objects define the arithmetic attributes of that fi object. If a fi object does not have an attached fimath object, the global fimath determines the arithmetic attributes of the fi object.

You can create fimath objects in Fixed-Point Toolbox software in one of two ways:

To get started, type

F = fimath

to create a fimath object. If your global fimath is set to the factory default configuration, you get the following output:

F =
 

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

To learn how to configure the global fimath, see Working with the Global fimath.

To copy a fimath object, simply use assignment as in the following example:

F = fimath;
G = F;
isequal(F,G)

ans =

     1

The syntax

F = fimath(...'PropertyName',PropertyValue...)

allows you to set properties for a fimath object at object creation with property name/property value pairs. Refer to Setting fimath Properties at Object Creation.

Building fimath Object Constructors in a GUI

When you are working with M-files, you can build your fimath object constructors using the Insert fimath Constructor dialog box. After specifying the properties of the fimath object in the dialog box, you can insert the prepopulated fimath object constructor string at a specific location in your M-file.

For example, to create a fimath object that uses convergent rounding and wraps on overflow, perform the following steps:

  1. Open the Insert fimath Constructor dialog box by selecting Tools > Fixed-Point Toolbox > Insert fimath Constructor from the editor menu.

  2. Use the edit boxes and drop-down menus to specify the following properties of the fimath object:

    • Round mode = Floor

    • Overflow mode = Wrap

    • Product mode = FullPrecision

    • Maximum product word length = 128

    • Sum mode = FullPrecision

    • Maximum sum word length = 128

    • Cast before sum = Checked

  3. To insert the fimath object constructor string into your M-file, place your cursor at the desired location in the M-file. Then click OK on the Insert fimath Constructor dialog box. Clicking OK closes the Insert fimath Constructor dialog box and automatically populates the fimath object constructor string in your M-file:

  


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