Internship Training Program Day18
Internship Training Program Day18
on
FPGA DESIGN TECHNIQUES
USING Quartus/Xilinx FRONT END
TOOL
Presented by
Dr.R.UMA
Day – 18
Design and performance of multiplier topology
Array Multiplier
Coding
module arraymul(p,a,b); assign w[12]=a[3]&b[0];
input [3:0] a,b; assign w[13]=a[3]&b[1];
output [7:0] p; assign w[14]=a[3]&b[2];
wire [15:0] w; assign w[15]=a[3]&b[3];
assign w[0]=a[0]&b[0]; fa x9(p[3],c9,s6,w[12],1'b0);
assign w[1]=a[0]&b[1]; fa x10(p[4],c10,s7,c9,w[13]);
assign p[0]=w[0];
assign w[2]=a[0]&b[2]; fa x11(p[5],c11,s8,c10,w[14]);
wire s1,s2,s3,s4,c1,c2,c3,c4;
assign w[3]=a[0]&b[3]; fa x12(p[6],p[7],c11,c8,w[15]);
fa x1(p[1],c1,w[1],w[4],1'b0);
endmodule
fa x2(s2,c2,w[2],w[5],c1);
assign w[4]=a[1]&b[0]; fa x3(s3,c3,w[3],w[6],c2);
assign w[5]=a[1]&b[1]; fa x4(s4,c4,w[7],1'b0,c3);
assign w[6]=a[1]&b[2];
assign w[7]=a[1]&b[3]; wire s5,s6,s7,s8,c5,c6,c7,c8;
fa x5(p[2],c5,s2,1'b0,w[8]);
assign w[8]=a[2]&b[0]; fa x6(s6,c6,w[9],c5,s3);
assign w[9]=a[2]&b[1]; fa x7(s7,c7,w[10],c6,s4);
assign w[10]=a[2]&b[2]; fa x8(s8,c8,w[11],c7,c4);
assign w[11]=a[2]&b[3];
module arraymul_test;
reg [3:0] a; Test Bench
reg [3:0] b;
wire [7:0] p;
arraymul uut (
.p(p),
.a(a),
.b(b)
);
initial begin
a=4'b1000;b=4'b1000;
#10 a=4'b1001;b=4'b0110;
#10 a=4'b1010;b=4'b0010;
#10 a=4'b0011;b=4'b0010;
#10 a=4'b1111;b=4'b1111;
end
initial
$monitor($time,"a=%d,b=%d,p=%d\n",a,b,p);
initial #50 $stop;
endmodule
Output
endmodule
module wallace_test; Test Bench
reg [3:0] a;
reg [3:0] b;
wire [7:0] p;
wallace uut (
.p(p),
.a(a),
.b(b)
);
initial begin
a=4'b1000;b=4'b1000;
#10 a=4'b1001;b=4'b0110;
#10 a=4'b1010;b=4'b0010;
#10 a=4'b0011;b=4'b0010;
#10 a=4'b1111;b=4'b1111;
end
initial
$monitor($time,"a=%d,b=%d,p=%d\n",a,b,p);
initial #50 $stop;
endmodule
Output
module dadda_test;
reg [3:0] a;
reg [3:0] b;
wire [7:0] p;
dadda uut (
.p(p),
.a(a),
.b(b)
);
initial begin
a=4'b1000;b=4'b1000;
#10 a=4'b1001;b=4'b0110;
#10 a=4'b1010;b=4'b0010;
#10 a=4'b0011;b=4'b0010;
end
initial
$monitor($time,"a=%d,b=%d,p=%d\n",a,b,p);
initial #50 $stop;
endmodule
Output
0a=0,b=0,p= 0
10a=1,b=1,p= 1
20a=2,b=2,p= 4
30a=3,b=2,p= 6
40a=3,b=3,p= 9
Vedic 4x4
Example
Coding
module vedic4x4(p,a,b);
input [3:0] a,b;
output [7:0] p; assign p[0]=pp[0];
wire [15:0] pp; assign p[1]=pp[1];
vedic2x2 d1(pp[3:0],a[1:0],b[1:0]); fa x7(p[2],w1,s1,pp[8],1'b0);
vedic2x2 d2(pp[7:4],a[1:0],b[3:2]); fa x8(p[3],w2,w1,s2,pp[9]);
vedic2x2 d3(pp[11:8],a[3:2],b[1:0]); fa x9(p[4],w3,w2,s3,s4);
vedic2x2 d4(pp[15:12],a[3:2],b[3:2]); fa x10(p[5],w4,w3,pp[7],s5);
fa x11(p[6],w5,w4,s6,1'b0);
wire s1,s2,s3,s4,s5,s6,c1,c2,c3,c4,c5,c6; fa x12(p[7],w6,w5,pp[15],1'b0);
fa x1(s1,c1,pp[2],pp[4],1'b0); endmodule
fa x2(s2,c2,pp[3],pp[5],c1);
fa x3(s3,c3,pp[6],c2,1'b0);
fa x4(s4,c4,pp[10],pp[12],1'b0);
fa x5(s5,c5,pp[11],pp[13],c4);
fa x6(s6,c6,pp[14],c5,1'b0);
Test bench
module vedic4x4_test;
reg [3:0] a;
reg [3:0] b;
wire [7:0] p;
vedic4x4 uut (.p(p),.a(a),.b(b));
initial begin
a=4'b1000;b=4'b1000;
#10 a=4'b1001;b=4'b0110;
#10 a=4'b1010;b=4'b0010;
#10 a=4'b0011;b=4'b0010;
#10 a=4'b1111;b=4'b1111;
end
initial
$monitor($time,"a=%d,b=%d,p=%d\n",a,b,p);
initial #50 $stop;
endmodule
Output
Timing Details:
---------------
All values displayed in nanoseconds (ns)
==================================================================
=======
Timing constraint: Default path analysis
Total number of paths / destination ports: 77 / 37
-------------------------------------------------------------------------
Delay: 6.395ns (Levels of Logic = 3)
Source: a<0> (PAD)
Destination: p<1> (PAD)