autofixexp
Automatically change the scaling for each fixed-point block that does not have its scaling locked.
Syntax
autofixexp
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:
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 FixPt 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.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.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.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).The global variableÂ
FixPtSimRanges
 is retrieved from the workspace. This is the variable that holds the maximum and minimum simulation values.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.ÂAll blocks that logged maximum and minimum simulation data are processed.
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 in this chapter.