Question

In: Electrical Engineering

mke individul modulees of for bit ader, for bit subtractor, for bit multiplier, for bit comparaator...

mke individul modulees of for bit ader, for bit subtractor, for bit multiplier, for bit comparaator modules[You can Ignore this part]

aand theen use a multiplexxer to combine these modules to make an ALUu where user should select which operation he/she wants to perform (for instance, ALU may performs four bit addition when selection lines are ‘00’using selection lines of multiplexer or perform subtraction when selections lines are ‘01’ and so on).{Just make this}

using verilooog coding on xilinxX

answer within 1 hourrrr pleez

Solutions

Expert Solution

Main ALU module:-

module alu(
input [3:0] X,Y, // ALU 4-bit Inputs   
input [1:0] sel,// ALU Selection
output [3:0] result, // ALU 4-bit Output
output Carry // Carry Flag
);
reg [3:0] ALU;
reg co;
wire [3:0] Result1,Result2,Result3,Result4;
wire Carry1,Carry2,Carry3,Carry4;
add test_unit1( X,Y,Result1,Carry1);
sub test_unit2( X,Y,Result2,Carry2);
mul test_unit3( X,Y,Result3,Carry3);
comp test_unit4( X,Y,Result4,Carry4);
assign result = ALU;
assign Carry = co;
always @(*)
begin
case(sel) //Here starts the MUX logic
2'b00: // Addition
begin
ALU = Result1;
co = Carry1;
end
2'b01: // Subtraction
begin
ALU = Result2 ;
co = Carry2;
end
2'b10: // Multiplication
begin
ALU = Result3;
co = Carry3;
end
2'b11: // Comparison
begin
ALU = Result4;
co = Carry4;
end
default: ALU = X ;
endcase
end

endmodule

SUBMODULES:-

ADD MODULE:-

module add(
input [3:0] A,B, // ALU 4-bit Inputs   
output [3:0] sum, // ALU 4-bit Output
output carry // Carry Flag
);
reg [3:0] sum_alu;
wire [4:0] tmp;
assign sum = sum_alu;
assign tmp = {1'b0,A} + {1'b0,B};
assign carry = tmp[4]; // Carry flag
always @(*)
begin
sum_alu = A + B ;
end
endmodule

SUBTRACTION MODULE:-

module sub(
input [3:0] A,B, // ALU 4-bit Inputs   
output [3:0] diff, // ALU 4-bit Output
output borr // Borrow Flag
);
reg [3:0] dif_alu;
wire [4:0] tmp;
assign diff = dif_alu;
assign tmp = {1'b0,A} - {1'b0,B};
assign borr = tmp[4]; // Borrow flag
always @(*)
begin
dif_alu = A - B ;
end
endmodule

MULTIPLICATION MODULE:-

module mul(
input [3:0] A,B, // ALU 4-bit Inputs   
output [3:0] pro, // ALU 4-bit Output
output carry // Carry Flag
);
reg [3:0] mul_alu;
wire [4:0] tmp;
assign pro = mul_alu;
assign tmp = {1'b0,A} + {1'b0,B};
assign carry = tmp[4]; // Carry flag
always @(*)
begin
mul_alu = A * B ;
end
endmodule

COMPARATOR MODULE:-

module comp(
input [3:0] A,B, // ALU 4-bit Inputs   
output [3:0] com, // ALU 4-bit Output
output carry // Carry Flag
);
reg [3:0] com_alu;
assign com = com_alu;
assign carry = 1'b0; //No use of carry in this module
always @(*)
begin
com_alu = (A==B)?4'd1:4'd0 ; //if a=b is true, then com_alu=1. if a=b is false , then com_alu=0
end
endmodule

(NOTE: As you have not asked for testbench ,i have not included it.Codes are software tested and they are error free.)


Related Solutions

Make a 2 bit binary adder subtractor multiplier on verilog and display it on seven segment...
Make a 2 bit binary adder subtractor multiplier on verilog and display it on seven segment using fpga
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.
Advanced Digital System Design Build a 1-bit subtractor and scale it up to become an 8-bit...
Advanced Digital System Design Build a 1-bit subtractor and scale it up to become an 8-bit subrtactor. Include truth tables and gate level diagrams for the 1-bit version.
What's the schematic of the 4-bit multiplier that has two 4-bit inputs and an 8-bit output...
What's the schematic of the 4-bit multiplier that has two 4-bit inputs and an 8-bit output with pure combinational logic? Can you draw the circuit?
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) -
3. The lecture notes show a 4-bit by 4-bit multiplier. If the same approach is used...
3. The lecture notes show a 4-bit by 4-bit multiplier. If the same approach is used to make an 8-bit by 8-bit multiplier: a) How many AND gates are required? b) If each AND gate has 1 ns of delay and each adder has 5 ns of delay, what is the total delay for the 8-bit by 8-bit multiplier? c) Can you think of a better way to array the adders to reduce the delay?
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.
Using full adders and some other gates, design subtractor that subtracts an 8-bit binary number [Y7...
Using full adders and some other gates, design subtractor that subtracts an 8-bit binary number [Y7 …. Y0] from 8-bit binary number [X7 … X0]. Write necessary equations. Draw detailed circuit diagram and explain steps & write verilog code
Design a 3-bit 2’s complement adder/subtractor with overflow flag detection Design and simulate a structural model...
Design a 3-bit 2’s complement adder/subtractor with overflow flag detection Design and simulate a structural model (not behavioral) of a 3-bit Adder/Subtractor). Use the 3-bit carry propagate adder of the project as a module for your adder/subtractor. The inputs A and B should be positive binary numbers where vector B must be converted to a negative 2's complement when a subtraction operation is configured. When m=0 it should perform and addition (A+B) and if m=1 it should perform a subtraction...
Multiply 14 times -5 using 5-bit numbers? Fill in the table for the Product, Multiplier and...
Multiply 14 times -5 using 5-bit numbers? Fill in the table for the Product, Multiplier and Multiplicand for each step. You need to provide the DESCRIPTION of the step being performed.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT