Question

In: Electrical Engineering

write gate level 4bit carry look ahead adder in verilog without any assign and always in...

write gate level 4bit carry look ahead adder in verilog without any assign and always in the code.

Solutions

Expert Solution

the gate level module is shown below:

// Code your design here
module full_adder (a,b,cin,s,cout);
input a,b,cin;
output cout,s;
wire w1,w2,w3,w4,w5;
xor x1(w1,a,b);
xor x2(s,w1,cin);
and a1(w2,a,b);
and a2(w3,b,cin);
and a3(w4,a,cin);
or r1(w5,w2,w3);
or r2(cout,w5,w4);
endmodule
module carry_lookahead_adder_4_bit
(
input [3:0] i_add1,
input [3:0] i_add2,
output [4:0] o_result
);

wire [4:0] w_C;
wire [3:0] w_G, w_P, w_SUM;
wire [3:0] w;

full_adder full_adder_bit_0
(
.a(i_add1[0]),
.b(i_add2[0]),
.cin(w_C[0]),
.s(w_SUM[0]),
.cout()
);

full_adder full_adder_bit_1
(
.a(i_add1[1]),
.b(i_add2[1]),
.cin(w_C[1]),
.s(w_SUM[1]),
.cout()
);

full_adder full_adder_bit_2
(
.a(i_add1[2]),
.b(i_add2[2]),
.cin(w_C[2]),
.s(w_SUM[2]),
.cout()
);

full_adder full_adder_bit_3
(
.a(i_add1[3]),
.b(i_add2[3]),
.cin(w_C[3]),
.s(w_SUM[3]),
.cout()
);

// Create the Generate (G) Terms: Gi=Ai*Bi
and an1(w_G[0],i_add1[0],i_add2[0]);
and an2(w_G[1],i_add1[1],i_add2[1]);
and an3(w_G[2],i_add1[2],i_add2[2]);
and an4(w_G[3],i_add1[3],i_add2[3]);

// Create the Propagate Terms: Pi=Ai+Bi
or or1(w_P[0],i_add1[0],i_add2[0]);
or or2(w_P[1],i_add1[1],i_add2[1]);
or or3(w_P[2],i_add1[2],i_add2[2]);
or or4(w_P[3],i_add1[3],i_add2[3]);

// Create the Carry Terms:
buf b1(w_C[0],1'b0); // no carry input
and c1(w[0],w_P[0],w_C[0]);
or oc1 (w_C[1],w_G[0],w[0]);
and c2(w[1],w_P[1],w_C[1]);
or oc2(w_C[2],w_G[1],w[1]);
and c3(w[2],w_P[2],w_C[2]);
or oc3(w_C[3],w_G[2],w[2]);
and c4(w[3],w_P[3],w_C[3]);
or oc4 (w_C[4],w_G[3],w[3]);

// result concatination
buf res1(o_result[4],w_C[4]);
buf res2(o_result[3],w_SUM[3]);
buf res3(o_result[2],w_SUM[2]);
buf res4(o_result[1],w_SUM[1]);
buf res5(o_result[0],w_SUM[0]);

endmodule

testbench:

// Code your testbench here
// or browse Examples
module test();
reg [3:0] i_add1,i_add2;
wire [4:0] o_result;
carry_lookahead_adder_4_bit ccc1(.*);
initial
begin
i_add1=5;i_add2=6;
#2 i_add1=15;i_add2=1;
end
initial
$monitor("%b %b %b",i_add1,i_add2,o_result);
endmodule

output:

0101 0110 01011
1111 0001 10000


Related Solutions

write gate level 16bit carry look ahead adder in verilog without any assign and always in...
write gate level 16bit carry look ahead adder in verilog without any assign and always in the code.
Q. Compare and contrast Ripple-Carry Adder and Carry-Look ahead Adder 1) In a 4-bit ripple-carry adder...
Q. Compare and contrast Ripple-Carry Adder and Carry-Look ahead Adder 1) In a 4-bit ripple-carry adder as shown in Figure 5.2, assume that each full-adder is implemented using the design as shown in Figure 3.11 (a) and each single logic gate (e.g., AND, OR, XOR, etc.) has a propagation delay of 10 ns. What is the earliest time this 4-bit ripple-carry adder can be sure of having a valid summation output? Explain how you reached your answer and how you...
SYSTEM VERILOG: Using your preferred HDL program, design a complete 4-bit Carry Look Ahead (CLA) adder...
SYSTEM VERILOG: Using your preferred HDL program, design a complete 4-bit Carry Look Ahead (CLA) adder module.
Implement 4-bit binary adder/subtractor using gate level. ( verilog code and test bench)
Implement 4-bit binary adder/subtractor using gate level. ( verilog code and test bench)
Problem 3.73 (1-bit full adder using carry lookahead – gate level circuit) 3.73 Design a 4-bit...
Problem 3.73 (1-bit full adder using carry lookahead – gate level circuit) 3.73 Design a 4-bit full adder using carry look-ahead rather than ripple carry.
Digital System Design Write the verilog HDL code for 2-4 decoder (Gate level modeling) along with...
Digital System Design Write the verilog HDL code for 2-4 decoder (Gate level modeling) along with the testbench and simulate using ModelSim. Upload the assignment (i) code (ii) testbench (iii) simulation in single pdf file.
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write down the VERILOG code for an XOR gate and the testbench code to test it
Write down the VERILOG code for an XOR gate and the testbench code to test it
Write the equations for carry-out bits for a 4-bit carry lookahead adder. Draw its diagram and...
Write the equations for carry-out bits for a 4-bit carry lookahead adder. Draw its diagram and label all the inputs and the outputs. Compare the delays of the 4-bit ripple-carry and 4-bit carry lookahead adders.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT