# Page History

## Key

• This line was removed.
• Formatting was changed.

### 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 in Version 14 or higher you can open the project directly from this page using this button. Make sure to select the Enable Guided Help before clicking this button.

HTML
```<script src="https://s3.amazonaws.com/downloads.awrcorp.com/gh/ghcommon.bas"
type="text/awrscript">
</script>
<button class="gh-button gh-projectopen" onclick="runAwrScript('awrGhOpenProject','Magnitude_Estimator_Fixed_Point.emp')">Open Install Example</button>
```

#### AWR Version 13

This example was renamed since the previous version. Please see Previous Example Page for the version 13 page.

### Design Notes

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  A B Average Error RMS Error Peak Error

(linear)        (dB)         (dB)

1.0      0 0.5      5 -0.086775      086775 -20.7       7 -18.6

1.0      0 0.25      25 0.006456      006456 -27.6       6 -18.7

1.0      0 0.4      4 -0.049482      049482 -25.1       1 -22.3

0.94754  94754 0.39248   39248 0.000547      000547 -32.6       6 -25.6 (min RMS error)

0.96043  96043 0.39782  39782 -0.013049      013049 -31.4       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.

...

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.

...