Question

In: Electrical Engineering

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.

Solutions

Expert Solution

Answer)

Verilog Code for the 4 bit multiplier using 4 bit Full adder is shown below:-

module fulladder (
input a,
input b,
input cin,
output sum,
output cout
);

assign sum = a ^ b ^ cin;
assign cout = (a & b) | (b & cin) | (a & cin);

endmodule

module fulladder_4bit (
input [3:0] A,
input [3:0] B,
input Cin,
output [3:0] S,
output Cout
);

wire w1, w2, w3, w4;

fulladder m0 (.a(A[0]), .b(B[0]), .cin(Cin), .sum(S[0]), .cout(w1));
fulladder m1 (.a(A[1]), .b(B[1]), .cin(w1), .sum(S[1]), .cout(w2));
fulladder m2 (.a(A[2]), .b(B[2]), .cin(w2), .sum(S[2]), .cout(w3));
fulladder m3 (.a(A[3]), .b(B[3]), .cin(w3), .sum(S[3]), .cout(w4));

assign Cout = w4;

endmodule

module multiplier_4x4 (A, B, P);
input [3:0] A;
input [3:0] B;
output [7:0] P;

wire [3:0] AB0, AB1, AB2, AB3;
wire [3:0] w1, w2, w3;
wire c1, c2, c3;

assign AB0 = {4{B[0]}} & A;
assign AB1 = {4{B[1]}} & A;
assign AB2 = {4{B[2]}} & A;
assign AB3 = {4{B[3]}} & A;

fulladder_4bit DUT1 (.A(AB1), .B({1'b0, AB0[3:1]}), .Cin(1'b0), .S(w1), .Cout(c1));
fulladder_4bit DUT2 (.A(AB2), .B({c1, w1[3:1]}), .Cin(1'b0), .S(w2), .Cout(c2));
fulladder_4bit DUT3 (.A(AB3), .B({c2, w2[3:1]}), .Cin(1'b0), .S(w3), .Cout(c3));

assign P[0] = AB0[0];
assign P[1] = w1[0];
assign P[2] = w2[0];
assign P[6:3] = w3;
assign P[7] = c3;

endmodule


Related Solutions

Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write a verilog code for 5 to 8 multiplier using fourbit adder
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to...
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to implement this.
Design a 32 bit after using a single 4 bit using verilog code
Design a 32 bit after using a single 4 bit using verilog code
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using...
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using full adder that is coded using data flow model. Use test bench to test 8-bit adder and consider at least five different test vectors to test it.
Design an 8-bit adder. Show the truth table, logic circuit, and Verilog code.
Design an 8-bit adder. Show the truth table, logic circuit, and Verilog code.
Design a Verilog code for 64x64 array multiplier. Use behavioral Verilog description with full adders and/or...
Design a Verilog code for 64x64 array multiplier. Use behavioral Verilog description with full adders and/or half adders. Please include testbench
verilog code to implement 32 bit Floating Point Adder in Verilog using IEEE 754 floating point...
verilog code to implement 32 bit Floating Point Adder in Verilog using IEEE 754 floating point representation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT