**ABSTRACT**

A large amount of today’s telecommunication consists of mobile and short distance wireless applications, where the effect of the channel is unknown and changing over time, and thus needs to be described statistically. Therefore the received signal cannot be accurately predicted and has to be estimated. Since telecom systems are implemented in real‐time, the hardware in the receiver for estimating the sent signal can for example be based on a DSP where the statistic calculations are performed.

A fixed‐point DSP with a limited number of bits and a fixed binary point causes larger quantization errors compared to floating point operations with higher accuracy. The focus on this thesis has been to build a library of functions for handling fixed‐point data. A class that can handle the most common arithmetic operations and a least squares solver for fixed‐point have been implemented in MATLAB code.

The MATLAB Fixed‐Point Toolbox could have been used to solve this task, but in order to have full control of the algorithms and the fixed-point handling an independent library was created. The conclusion of the simulation made in this thesis is that the least squares result are depending more on the number of integer bits then the number of fractional bits.

**THEORY**

In fixed‐point the binary point has a fixed position compared to floating point where the binary point can “float”. The binary point separates the integer part from the fractional part. In figure 2.2 it is shown how the decimal number 18.25 is represented binary with a fixed bit width. To be able to represent negative values the first bit must be allocated to define if the number is positive or negative, in figure 2.2 the msb is set to 0, which makes the value positive.

**MATLAB CODE**

The test is constructed to compare fp with the Fixed‐Point Toolbox. This is done by executing the same operations in both programs and comparing the results. The test is divided into different parts that execute different operations. The test program uses global properties which makes it possible to test every function in the program with different properties. If the result of any part in the test differs, the test program shows both results and an error message. An example of this is showed in figure 3.2.

**SIMULATIONS**

In figure 4.5 the fractional width is increased to 16. The fractional width of 16 makes it possible to represent even more decimals but this decrease the number of integer bits to 7. As discussed before the multiplication needs double the bit width to avoid saturation. Since there are only 7 integer bits a saturation is introduced. This is easily seen at the level of approximately 128 in figure 4.5.

**CONCLUSIONS**

The focus of this thesis has been to build a library of functions for handling fixed‐point data. A class that can handle the most common arithmetic operations and a least squares solver for fixed‐point has been implemented. In addition to the original task further functions have been added in consultation with the mentor. In general calculations the class fp has the Fixed‐Point Toolbox as a reference but there are some important exceptions. In the Fixed‐Point Toolbox a division by zero results in the maximum data value.

The class fp returns one in this case and is due to that DSP:s often handles this problem. Another exception is that the arithmetic functions of the class fp round incoming float values. This is due to that a DSP receives rounded and saturated values to be able to handle arithmetic operations. This compared to the Fixed‐Point Toolbox which not do this rounding. The last exception is that the Fixed‐Point Toolbox rounds the quotient in a division to an integer, which in most cases results in an unnecessary precision loss.

The class fp uses the original precision, i.e. no additional rounding to the quotient is performed. The conclusion of the simulation made in this thesis is that the fractional width needs to be greater than zero due to rounding. The results are depending more on the number of integer bits, due to the need of double bit width in a multiplication. If the fractional width is increased to minimize rounding errors, the bit width also needs to be increased to avoid saturation.

Source: Karlstad University

Authors: Robin Englund | Andreas Grill