Skip to Main Content Skip to Search
Product Documentation

Constructing fimath Objects

fimath Object Syntaxes

The arithmetic attributes of fi objects are defined by either a local fimath object, or the global fimath.

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

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 files in MATLAB, 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 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 in your file, place your cursor at the desired location in the 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 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-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS