DSP Lab Experiment 3
DSP Lab Experiment 3
Method
Kanishk Devatwal - ee23btech11029
February 26, 2025
1 Introduction
Fixed-point arithmetic is widely used in embedded systems and hardware im-
plementations where floating-point operations are costly. In this report, we
implement a fixed-point division method using the Newton-Raphson iterative
technique.
2 Methodology
15
The objective is to compute the fixed-point division of 23 using an iterative
method. The Newton-Raphson method is applied to approximate the reciprocal
of the denominator and then multiplied by the numerator to obtain the result.
xi+1 = xi × (2 − xi × D) . (4)
1
In fixed-point arithmetic, this translates to:
3 Implementation
The implementation was verified using Verilog and MATLAB. The Verilog code
simulates the fixed-point division, while the MATLAB script verifies the results
using the same Newton-Raphson method.
i n i t i a l begin
s c a l e d d i v i d e n d = d i v i d e n d ∗ SCALING FACTOR ;
r e c i p r o c a l = (SCALING FACTOR / 1 7 ) ;
f o r ( i t r = 0 ; i t r < 5 ; i t r = i t r + 1) begin
i n t e r m e d i a t e = r e c i p r o c a l ∗ ( 2 ∗ SCALING FACTOR − ( ( r e c i p r o c a l ∗ s c a
r e c i p r o c a l = i n t e r m e d i a t e >> PRECISION ;
2
end
i n t e r m e d i a t e = num ∗ r e c i p r o c a l ;
$ d i s p l a y ( ” Fixed−P oi nt R e s u l t : %d ” , i n t e r m e d i a t e ) ;
$ d i s p l a y ( ” F l o a t i n g −P oi nt R e s u l t : %f ” , i n t e r m e d i a t e ∗ 1 . 0 / SCALING FACTOR
$stop ;
end
endmodule
% Convert t o f i x e d −p o i n t
D f i x = round (D ∗ s c a l e f a c ) ; % denominator t o f i x e d p o i n t c o n v e r t
x0 = 1 / 1 7 ;
x f i x e d r e p = round ( x0 ∗ s c a l e f a c ) ; %c o n v e r t i n g i n i t i a l g u e s s 1/D t o f i x e d p o i n
% Newton−Raphson I t e r a t i o n
for i = 1:5
x f i x e d r e p = b i t s h i f t ( x f i x e d r e p ∗ (2 ∗ s c a l e f a c − b i t s h i f t ( x f i x e d r e p ∗ D
end
% computing 15/23
r e s u l t f i x e d = num ∗ x f i x e d r e p ;
% Converting to f l o a t i n g point
result floating = result fixed / scale fac ;
% Display
d i s p ( [ ’ Fixed−P oi nt R e s u l t : ’ , num2str ( r e s u l t f i x e d ) ] ) ;
d i s p ( [ ’ F l o a t i n g −P oi nt R e s u l t : ’ , num2str ( r e s u l t f l o a t i n g ) ] ) ;
3
4 Results and Discussion
The computed fixed-point result is displayed and verified in both Verilog and
MATLAB. The floating-point result obtained is:
15
≈ 0.6522. (8)
23
The fixed-point representation correctly approximates this value with high ac-
curacy.
5 Conclusion
This report presents a hardware-friendly fixed-point division method using Newton-
15
Raphson iteration. The implementation successfully computes 23 with an 8-
bit precision scaling factor, demonstrating the feasibility of efficient division in
fixed-point arithmetic.