Fixed-Point Blockset    
autofixexp

Automatically change the scaling for each fixed-point block that does not have its scaling locked

Syntax

Description

The autofixexp script automatically changes the scaling for each block that does not have its scaling locked. This script uses the maximum and minimum data obtained from the last simulation run to log data to the workspace. The scaling is changed such that the simulation range is covered and the precision is maximized. The script follows these steps:

  1. The global variable FixPtTempGlobal is created to "steal" parameters (such as data type) from variables not known in the base workspace. For example, assume the Sum block has its output data type specified as DerivedVar. DerivedVar is derived in the mask initialization based on mask parameters and the block is under a mask.
  1. The value of the parameter DerivedVar is retrieved by temporarily replacing DerivedVar with stealparameter(DerivedVar) in the block dialog. A model update is then forced. When stealparameter(DerivedVar) is evaluated, it returns the value of DerivedVar without modification and stores the value in FixPtTempGlobal. The stolen value is immediately used by this procedure and is not needed again. Therefore, the procedure can move from one block to the next using the same global variable.

  1. The RangeFactor variable allows you to specify a range differing from that defined by the maximum and minimum values logged in FixPtSimRanges. For example, a RangeFactor value of 1.55 specifies that a range at least 55 percent larger is desired. A value of 0.85 specifies that a range up to 15 percent smaller is acceptable.
  1. You should be aware that the scaling is not exact for the radix point-only case since the range is given (approximately) by a power of two. The lower limit is exact, but the upper limit is always one bit below a power of two.

    For example, if the maximum logged value is 5 and the minimum logged value is -0.5, then any RangeFactor from 4/5 to slightly under 8/5 would produce the same radix point since these limits are less than a factor of two from each other. The radix point selected will produce a range from -8 to +8 (minus a bit).

  1. The global variable FixPtSimRanges is retrieved from the workspace. This is the variable that holds the maximum and minimum simulation values.
  2. The workspace is searched for the variables SlopeBits and BiasBits, which specify the number of bits to use in representing slopes and biases. If these variables are not found, then they are automatically created with default values of 7 and 8, respectively.
  3. All blocks that logged maximum and minimum simulation data are processed.
  4. All blocks that do not have their scaling locked are automatically scaled. If the data type class is FIX, then radix point-only scaling is performed. If the data type class is INT, then [Slope Bias] scaling is performed. To find out a data type's class, refer to its reference page.

See Also

fxptdlg, showfixptsimranges


  Functions--Alphabetical List fixptbestexp