In Fixed-Point Designer™ software, the fipref
object determines the display
properties of fi
objects. Code examples generally show
fi
objects as they appear with the following
fipref
object properties:
NumberDisplay
—
'RealWorldValue'
NumericTypeDisplay
—
'full'
FimathDisplay
— 'full'
Setting 'FimathDisplay'
to 'full'
provides a
quick and easy way to differentiate between fi
objects with a local
fimath and those that are associated with the default fimath. When
'FimathDisplay'
is set to 'full'
, MATLAB® displays fimath
object properties for
fi
objects with a local fimath. MATLAB never displays fimath
object properties for
fi
objects that are associated with the default fimath. Because
of this display difference, you can tell when a fi
object is
associated with the default fimath just by looking at the output.
Additionally, unless otherwise specified, examples throughout the Fixed-Point Designer documentation use the following default configuration of fimath:
RoundingMethod: Nearest OverflowAction: Saturate ProductMode: FullPrecision SumMode: FullPrecision
For more information on display settings, refer to fi Object Display Preferences Using fipref.
To see the output as it appears in most Fixed-Point Designer code examples, set your fipref
properties as
follows and create two fi
objects:
p = fipref('NumberDisplay', 'RealWorldValue',... 'NumericTypeDisplay', 'full', 'FimathDisplay', 'full'); a = fi(pi,'RoundingMethod', 'Floor', 'OverflowAction', 'Wrap') b = fi(pi)
MATLAB returns the following:
a = 3.1415 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13 RoundingMethod: Floor OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision b = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
MATLAB displays fimath
object properties in the output of
fi
object a
because a
has a local fimath.
MATLAB does not display any fimath
object properties in
the output of fi
object b
because
b
associates itself with the default fimath.
If you are working with multiple fi
objects that have local
fimaths, you may want to turn off the fimath
object
display:
NumberDisplay
—
'RealWorldValue'
NumericTypeDisplay
—
'full'
FimathDisplay
— 'none'
For example,
p = fipref('NumberDisplay','RealWorldValue',... 'NumericTypeDisplay','full','FimathDisplay','none') p = NumberDisplay: 'RealWorldValue' NumericTypeDisplay: 'full' FimathDisplay: 'none' LoggingMode: 'Off' DataTypeOverride: 'ForceOff' F = fimath('RoundingMethod','Floor','OverflowAction','Wrap'); a = fi(pi, F) a = 3.1415 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
Although this setting helps decrease the amount of output produced, it also makes
it impossible to tell from the output whether a fi
object uses
the default fimath. To do so, you can use the isfimathlocal
function. For
example,
isfimathlocal(a) ans = 1
When the isfimathlocal
function returns 1
,
the fi
object has a local fimath. If the function returns
0
, the fi
object uses the default fimath.
To reduce the amount of output even further, you can set the
NumericTypeDisplay
to 'short'
. For
example,
p = fipref('NumberDisplay','RealWorldValue',... 'NumericTypeDisplay','short','FimathDisplay','full'); a = fi(pi) a = 3.1416 s16,13