Where To Find This Example
AWR Version 14
Select Help > Open Examples... from the menus and type either the example name listed above or one of the keywords below.
Or you can open the project directly from this page using this button. Make sure to select the Enable Guided Help before clicking this button.
AWR Version 13
This example was renamed since the previous version. Please see Previous Example Page for the version 13 page.
Fixed-Point Magnitude Calculation
This example demonstrates a magnitude estimator whose hardware complexity is much simpler and faster than that of the full-precision exact calculation using a square-root operation. Magnitude estimators are used in many fixed-point ASIC designs for received signal strength indicators (RSSI) and demodulation algorithms.
The magnitude of a complex number, I + jQ, is defined as sqrt(I^2 + Q^2) and is approximated as:
Mag ~= A * max(|I|,|Q|) + B * min(|I|,|Q|)
where A and B are two constants whose values can be set such that either the RMS error, peak error and/or implementation complexity is reduced within acceptable levels. Some of the most common values for A and B are given below, together with the associated errors:
A B Average Error RMS Error Peak Error
(linear) (dB) (dB)
1.0 0.5 -0.086775 -20.7 -18.6
1.0 0.25 0.006456 -27.6 -18.7
1.0 0.4 -0.049482 -25.1 -22.3
0.94754 0.39248 0.000547 -32.6 -25.6 (min RMS error)
0.96043 0.39782 -0.013049 -31.4 -28.1 (min peak error)
Note that the first two choices are very simple to implement in hardware (using shifts and adds), while the others are more complex.
This project calculates the magnitude of the input in three different ways:
1. The exact calculation uses a CMAG block to compute the magnitude of a complex input.
2. The floating-point approximation uses the algorithm above and double-precision arithmetic.
3. The fixed-point approximation uses fixed-point arithmetic for the algorithm above. In this case, bit and decimal widths should be selected such that loss of information due to the real to fixed-point conversion is within acceptable limits. For example, the bit and decimal widths for the SCALE parameter in the SCALE_FP block should be set such that the selected values for A and B are represented by these widths.