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.
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.
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.
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write a verilog code for 5 to 8 multiplier using fourbit adder
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 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
Provide the VHDL specification of a hybrid 32-bit adder that cascades 2 12 bit carry look...
Provide the VHDL specification of a hybrid 32-bit adder that cascades 2 12 bit carry look ahead adders and one 10 bit carry look ahead adder. a) Compare your adder with a full 32-bit carry-look ahead in performance and cost. b) Compare your adder with a full combinational adder in performance and cost c) Compare your adder with a ripple-carry adder in performance and cost. d) Compare your adder to a bit serial (sequential) adder in performance and cost. e)...
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Question B Write an 8 bit adder module in System Verilog by appropriately connecting two 4...
Question B Write an 8 bit adder module in System Verilog by appropriately connecting two 4 bit adders (the System Verilog code of a 4 bit adder is available in the lecture notes). Instantiate your 8 bit adder module on DE2 board. Design a test circuit on DE2 board that allows us to test the 8 bit adder using the switches and the seven segment displays on DE2 board. The test circuit will need the module you designed for Part...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT