Digital Signal Processing Reference
In-Depth Information
4-bit integer arithmetic
Q1.3 fractional arithmetic
10 01 = -7 10
0 1 1 1 = +7 10
1 1 1 1 1 0 0 1
1 1 1 1 0 0 1 X
1 1 1 0 0 1 X X
1 1 0 0 1 1 1 1 = -49 10
1. 0 0 1 = -0.875 10
0. 1 1 1 = 0.875 10
1 1. 1 1 1 0 0 1
1 1. 1 1 0 0 1 X
1 1. 1 0 0 1 X X
1 1. 0 0 1 1 1 1 = 1.0011110
= - 0.7656 10
1. 0 0 1 = -0.875 10
1. 0 0 1 1 1 1 0
1 1 0 0 1 1 1 1 1111
overflow
Figure 3.19 Demonstration of the difference between integer and fractional multiplication
the operands to handle signed and unsigned operands, and in the case of fractional sign by sign
multiplication it also drops the redundant sign bit.
In many designs the result of multiplication of two N-bit numbers is rounded to an N-bit
number. This truncation of the result requires separate treatment for integer and fractional
multipliers.
. For integer multiplication, the least significant N bits are selected for the final product provided
the most significant N bits are redundant sign bits. If they are not, then the result is saturated to the
appropriate maximum or minimum level.
. For fractional multiplication, after dropping the redundant sign bit and adding a 1 to the
seventeenth bit location for rounding, the most significant N bits are selected as the final
product.
The difference between integer and fractional multiplication is illustrated in Figure 3.19. The
truncated product in integer multiplication overflows and is 1111 2
1 10 . The product for factional
multiplication, after dropping the sign bit out by shifting the product by 1 to the left and then
dropping the four LSBs, is 0.875.
ΒΌ
3.5.11 MATLAB Support for Fixed-point Arithmetic
MATLAB provides the fi tool that is a fixed-point numeric object with a complete list of attributes
that greatly help in seamless conversion of a floating-point algorithm to fixed-point format. For
example, using fi() , p is converted to a signed fixed-point Q3.5 format number:
>> PI = fi(pi, 1, 3+5, 5);% Specifying N bits and the fraction part
>> bin(PI)
01100101
>> double(PI)
3.1563
All the available attributes that a programmer can set for each fixed-point object are given in
Figure 3.20.
 
Search WWH ::




Custom Search