FPGA Based System Design
FPGA Based System Design
e.g
-6.25 1001.110
0 1 1 0 . 0 0 1 Invert each bit
1+
6.25 0110.010
Or
-6.25 1001.110
First one from right
6.25 0110.010
Till here don’t change any thing
From here invert each bit
Range of a number
if a signed number is represented in Q(n,m) format then the range of
the number is:
Range {Q(n,m)} = -2n-1 to +2n-1 – 2-m
Range {Q(4,3)} = -24-1 to +23 – 2-3
Range {Q(n,m)} = -8 to +8 – 0.125
Range {Q(n,m)} = -8 to +7.875
if a signed number has max. –ve value (-8 in above example) then the MSB
shall be 1 and rest of the bits will be zero. E.g -8 in Q(4,3) is
-8 4 2 1 . 0.5 0.25 0.125
10 0 0. 0 0 0
if a signed number has max. +ve value (7.875in above example) then the
MSB shall be 0 and rest of the bits will be 1. E.g 7.875 in Q(4,3) is
-8 4 2 1 . 0.5 0.25 0.125
01 1 1. 1 1 1
Converting a number represented in less number of
bits into equivalent in more number of bits:
In fractional part concatenate zeros and in integer part perform sign
extension:
E.g -6.25 in Q(4,3) is
-8 4 2 1 . 0.5 0.25 0.125
10 0 1. 1 1 0
Same is to be represented in Q(6,4) then
-32 16 8 4 2 1 . 0.5 0.25 0.125 0.0625
1 1 1 0 0 1. 1 1 0 0
1x-32 + 1x16 + 1x8+ 0x4+0x2+ 1x1+ 1x0.5 + 1x0.25 + 0x.125 + 0x0.0625= -6.25
Converting a number represented in more number of
bits into equivalent in less number of bits:
In fractional part either truncate or round off.
In integer part detect overflow and underflow situations and hence
maximize for overflow and minimize for under flow else truncate excess
MSB’s.
E.g -6.25 in Q(6,4) is
-32 16 8 4 2 1 . 0.5 0.25 0.125 0.0625
1 1 1 0 0 1. 1 1 0 0
Same is to be represented in Q(4,3) then first analyze if the number can fit in
the given bit numbers e.g in Q(4,3) the range is from -8 to 7.875 so there is
no underflow condition then truncate 2 MSB’s and 1 LSB and the number is:
-8 4 2 1 . 0.5 0.25 0.125
1 0 0 1. 1 1 0
Hence
B(unsigned, Q(5,6))
Range Estimation after Arithmetic Operations General
Rules:
After addition/subtraction the answer require 1 more bit than the
operand which is represented in more bits.
e.g A(signed, Q(3,3)) => Range (-4, 3.875)
B(signed, Q(2,3)) => Range (-2, 1.875) Let C = A+B then
the range is (-6, 5.75) hence C(signed, Q(4,3))
After multiplication the bits are doubled and decimal point is
adjusted as under:
e.g A(signed, Q(3,3)) => Range (-4, 3.875)
B(signed, Q(2,3)) => Range (-2, 1.875) Let C = AxB then
C(signed, Q (3+2=5, 3+3=6)) . Though actual range is (-7.75, 8)
where –ve number is -7.75 which can fit in 4 bits for integer but in
this case +8 can not be fitted. Hence, 5 bits are needed for integer
and this will cover (-16 to 15.984375).
Note: Division can also be see as multiplication with reciprocal
Range Estimation after Arithmetic Operations General
Rules:
Summation Operation
e.g Ak(signed, Q(3,3)) => Range (-4, 3.875)
Bk(signed, Q(2,3)) => Range (-2, 1.875) Let C = AxB then
Ck(signed, Q (5, 6)) . Though actual range is (-7.75, 8)
where –ve number is -7.75 which can fit in 4 bits for integer but in
this case +8 can not be fitted. Hence, 5 bits are needed for integer
and this will cover (-16 to 15.984375).
7
Let D = ∑k=0 Ck => Range is 8x Range of Ck
8 is represented in 3 bits hence D is (signed, Q(8,6))