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
FixPtTempGlobalis 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 asDerivedVar, which is derived in the mask initialization based on mask parameters and the block is under a mask. - The value of the parameter
DerivedVaris retrieved by temporarily replacingDerivedVarwithstealparameter(DerivedVar)in the block dialog. A model update is then forced. Whenstealparameter(DerivedVar)is evaluated, it returns the value ofDerivedVarwithout modification and stores the value inFixPtTempGlobal. 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
RangeFactorvariable allows you to specify a range differing from that defined by the maximum and minimum values logged inFixPtSimRanges. For example, aRangeFactorvalue 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. - 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
RangeFactorfrom 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
FixPtSimRangesis retrieved from the workspace. This is the variable that holds the maximum and minimum simulation values. - The workspace is searched for the variables
SlopeBitsandBiasBits, 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 isINT, then slope/bias scaling is performed. To find out a data type's class, refer to its reference page in this chapter.