There are three key parameters which describe the form of the expected input data necessary for approximation:
- TP_COARSE_BITS: Specifies the number of bits in a data sample used to address the lookup table for coarse approximation.
- TP_FINE_BITS: Specifies the number of least-significant bits in a data sample used for interpolation.
- TP_DOMAIN_MODE: Sets the mode of the expected domain that the input is normalized to. For example, TP_DOMAIN_MODE = 0 identifies that the domain of the input to the function for approximation is 0 to 1.
The required bit-field of a data sample from MSB to LSB is [headroom, TP_COARSE_BITS, TP_FINE_BITS]. Headroom is optional, but TP_COARSE_BITS + TP_FINE_BITS must be less than or equal to the number of bits in the specified TT_DATA type.
Therefore, for a given input sample, the corresponding TP_COARSE_BITS will provide the index to the supplied lookup table. At this index of the lookup table will be a slope and an offset value. For integer types, the slope-offset values are in point-slope form. The offset value is the coarse approximation, and the slope value is multiplied with the TP_FINE_BITS of the input sample for linear interpolation. The sum of these two values will provide the resulting approximation, f(x) for an input, x.
Shifting input down by TP_FINE_BITS will leave just the TP_COARSE_BITS. (If headroom exists, these bits must be zero).
index = input >> TP_FINE_BITS
Use index as an address to the lookup of slope-offset values. Multiply lower TP_FINE_BITS of input with looked-up slope and add to lookup offset values to find the resulting approximation.
output = offset[index] + slope[index] * input[TP_FINE_BITS-1:0]
For floating-point types, the slope-offset values are in slope-intercept form. The float input sample is cast to an integer, and the TP_COARSE_BITS of this cast integer sample is used as an index to the lookup tables.
index = int(input) >> TP_FINE_BITS output = offset[index] + slope[index] * input
Note, for floating-point data, all of the input is multiplied by the slope, whereas for integer data, only the lower TP_FINE_BITS is multiplied with the slope. This means that slope-offset values for the interpolated function lines are point-slope for integers and slope-intercept for floats. Further information can be found in the following section about configuring the lookup tables.