Verilog Code for Carry Look-Ahead Adder, Skip Adder, and Wallace Multiplier, Study Guides, Projects, Research of Very large scale integration (VLSI)

The verilog code for three types of digital logic circuits: carry look-ahead adder, carry skip adder, and wallace tree multiplier. The code includes the module implementation and testbench for each circuit.

Typology: Study Guides, Projects, Research

2019/2020

Uploaded on 03/08/2020

rohit-patnaik
rohit-patnaik 🇮🇳

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CARRY LOOK AHEAD ADDER
Verilog
Coding
module carryLookAhead(S,Cout,a,b,Cin);
input [3:0]a,b;
input Cin;
output [3:0]S;
output Cout;
wire [3:0]g,p;
wire w1,w2,w3,w4;
assign p[0] = a[0]^b[0];assign p[1] = a[1]^b[1];
assign p[2] = a[2]^b[2];assign p[3] = a[3]^b[3];
assign g[0] = a[0]&b[0];assign g[1] = a[1]&b[1];
assign g[2] = a[2]&b[2];assign g[3] = a[3]&b[3];
assign w1 = g[0]|(Cin&p[0]);
assign w2 = g[1]|(w1&p[1]);
assign w3 = g[2]|(w2&p[2]);
assign w4 = g[3]|(w3&p[3]);
assign Cout = w4; assign S[0] = p[0]^Cin;
assign S[1] = p[1]^w1; assign S[2] = p[2]^w2;
assign S[3] = p[3]^w3;
endmodule
Testbench
module carryLookAhead_TB_v;
initial begin
a=4'b1100; b=4'b0000; Cin=0; #100;
a=4'b1010; b=4'b0100; Cin=0; #100;
a=4'b1100; b=4'b0000; Cin=1; #100;
a=4'b1010; b=4'b1100; Cin=1; #100;
end
endmodule
CARRY SKIP ADDER
Carry Skip Adder Coding
module carrySkipAdder(S,Cout,a,b,Cin);
input [3:0]a,b;
input Cin;
output [3:0]S;
output Cout;
wire [3:0]p;
wire w1,bp;
rca r1(S[3:0],w1,a[3:0],b[3:0],Cin);
propagate p1(p[3:0],bp,a[3:0],b[3:0]);
mux m1(Cout,w1,Cin,bp);
endmodule
Carry Skip Adder Testbench
module carrySkipAdder_TB_v;
initial begin
a=4'b1100; b=4'b0000; Cin=0; #100;
a=4'b1010; b=4'b0100; Cin=0; #100;
a=4'b1100; b=4'b0000; Cin=1; #100;
a=4'b1010; b=4'b1100; Cin=1; #100;
end
endmodule
pf3

Partial preview of the text

Download Verilog Code for Carry Look-Ahead Adder, Skip Adder, and Wallace Multiplier and more Study Guides, Projects, Research Very large scale integration (VLSI) in PDF only on Docsity!

CARRY LOOK AHEAD ADDER

Verilog Coding module carryLookAhead(S,Cout,a,b,Cin); input [3:0]a,b; input Cin; output [3:0]S; output Cout; wire [3:0]g,p; wire w1,w2,w3,w4; assign p[0] = a[0]^b[0];assign p[1] = a[1]^b[1]; assign p[2] = a[2]^b[2];assign p[3] = a[3]^b[3]; assign g[0] = a[0]&b[0];assign g[1] = a[1]&b[1]; assign g[2] = a[2]&b[2];assign g[3] = a[3]&b[3]; assign w1 = g[0]|(Cin&p[0]); assign w2 = g[1]|(w1&p[1]); assign w3 = g[2]|(w2&p[2]); assign w4 = g[3]|(w3&p[3]); assign Cout = w4; assign S[0] = p[0]^Cin; assign S[1] = p[1]^w1; assign S[2] = p[2]^w2; assign S[3] = p[3]^w3; endmodule Testbench module carryLookAhead_TB_v; initial begin a=4'b1100; b=4'b0000; Cin=0; #100; a=4'b1010; b=4'b0100; Cin=0; #100; a=4'b1100; b=4'b0000; Cin=1; #100; a=4'b1010; b=4'b1100; Cin=1; #100; end endmodule CARRY SKIP ADDER Carry Skip Adder Coding module carrySkipAdder(S,Cout,a,b,Cin); input [3:0]a,b; input Cin; output [3:0]S; output Cout; wire [3:0]p; wire w1,bp; rca r1(S[3:0],w1,a[3:0],b[3:0],Cin); propagate p1(p[3:0],bp,a[3:0],b[3:0]); mux m1(Cout,w1,Cin,bp); Carry Skip Adder Testbench module carrySkipAdder_TB_v; initial begin a=4'b1100; b=4'b0000; Cin=0; #100; a=4'b1010; b=4'b0100; Cin=0; #100; a=4'b1100; b=4'b0000; Cin=1; #100; a=4'b1010; b=4'b1100; Cin=1; #100; end endmodule

BRAUN ARRAY MULTIPLIER

Coding module braun(p,a,b); input [3:0]a,b; output [7:0]p; wire x10,x20,x30,x01,x11,x21,x31,x02,x12,x22,x32,x 03,x13,x23,x33,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c 11,s1,s2,s3,s4,s5,s6; and a1(p[0],a[0],b[0]); and a2(x10,a[1],b[0]); and a3(x20,a[2],b[0]); and a4(x30,a[3],b[0]); and a5(x01,a[0],b[1]); and a6(x11,a[1],b[1]); and a7(x21,a[2],b[1]); and a8(x31,a[3],b[1]); and a9(x02,a[0],b[2]); and a10(x12,a[1],b[2]); and a11(x22,a[2],b[2]); and a12(x32,a[3],b[2]); and a13(x03,a[0],b[3]); and a14(x13,a[1],b[3]); and a15(x23,a[2],b[3]); and a16(x33,a[3],b[3]); FullAdder F1(p[1],c1,x10, x01,1'b0); FullAdder F2(s1,c2,x11,x02,1'b0); FullAdder F3(p[2],c3,x20,c1,s1); FullAdder F4(s2,c4,x12,1'b0,x03); FullAdder F5(s3,c5,x21,c2,s2); FullAdder F6(p[3],c6,x30,c3,s3); FullAdder F7(s4,c7,x22,c4,x13); FullAdder F8(s5,c8,x31,c5,s4); FullAdder F9(p[4],c9,1'b0,c6,s5); FullAdder F10(s6,c10,x32,c7,x23); FullAdder F11(p[5],c11,c9,c8,s6); FullAdder F12(p[6],p[7],c11,c10,x33); Testbench module braun_TB_v; initial begin a=4'b0001; b=4'b0000; #100; a=4'b0010; b=4'b0001; #100; a=4'b0100; b=4'b0011; #100; a=4'b0011; b=4'b1010; #100; a=4'b0111; b=4'b0011; #100; end endmodule