Question

Design and code in Verilog an Arithmetic Logic Unit(ALU). It should be able to take two numbers o...

Design and code in Verilog an Arithmetic Logic Unit(ALU). It should be able to take two numbers of 32 bits and realize any instruction that requires logic and arithmetic operations. The output of the ALU will be a number of 32 bits.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
`timescale 1 ps / 100 fs
module Add(S,A,B);
output [31:0] S;
input [31:0] A,B;
wire [31:0] C;
 adder1bit adder1bit0(S[0],C[0],A[0],B[0],1'b0);
 adder1bit adder1bit1(S[1],C[1],A[1],B[1],C[0]);
 adder1bit adder1bit2(S[2],C[2],A[2],B[2],C[1]);
 adder1bit adder1bit3(S[3],C[3],A[3],B[3],C[2]);
 adder1bit adder1bit4(S[4],C[4],A[4],B[4],C[3]);
 adder1bit adder1bit5(S[5],C[5],A[5],B[5],C[4]);
 adder1bit adder1bit6(S[6],C[6],A[6],B[6],C[5]);
 adder1bit adder1bit7(S[7],C[7],A[7],B[7],C[6]);
 adder1bit adder1bit8(S[8],C[8],A[8],B[8],C[7]);
 adder1bit adder1bit9(S[9],C[9],A[9],B[9],C[8]);
 adder1bit adder1bit10(S[10],C[10],A[10],B[10],C[9]);
 adder1bit adder1bit11(S[11],C[11],A[11],B[11],C[10]);
 adder1bit adder1bit12(S[12],C[12],A[12],B[12],C[11]);
 adder1bit adder1bit13(S[13],C[13],A[13],B[13],C[12]);
 adder1bit adder1bit14(S[14],C[14],A[14],B[14],C[13]);
 adder1bit adder1bit15(S[15],C[15],A[15],B[15],C[14]);
 adder1bit adder1bit16(S[16],C[16],A[16],B[16],C[15]);
 adder1bit adder1bit17(S[17],C[17],A[17],B[17],C[16]);
 adder1bit adder1bit18(S[18],C[18],A[18],B[18],C[17]);
 adder1bit adder1bit19(S[19],C[19],A[19],B[19],C[18]);
 adder1bit adder1bit20(S[20],C[20],A[20],B[20],C[19]);
 adder1bit adder1bit21(S[21],C[21],A[21],B[21],C[20]);
 adder1bit adder1bit22(S[22],C[22],A[22],B[22],C[21]);
 adder1bit adder1bit23(S[23],C[23],A[23],B[23],C[22]);
 adder1bit adder1bit24(S[24],C[24],A[24],B[24],C[23]);
 adder1bit adder1bit25(S[25],C[25],A[25],B[25],C[24]);
 adder1bit adder1bit26(S[26],C[26],A[26],B[26],C[25]);
 adder1bit adder1bit27(S[27],C[27],A[27],B[27],C[26]);
 adder1bit adder1bit28(S[28],C[28],A[28],B[28],C[27]);
 adder1bit adder1bit29(S[29],C[29],A[29],B[29],C[28]);
 adder1bit adder1bit30(S[30],C[30],A[30],B[30],C[29]);
 adder1bit adder1bit31(S[31],C[31],A[31],B[31],C[30]);

endmodule

//---------------------------------------------------------------------------------------------------

`timescale 1 ps / 100 fs
module adder1bit(sum,cout,a,b,cin);
input   a,b,cin;
output  cout,sum;
// sum = a xor b xor cin
xor #(50) (sum,a,b,cin);
// carry out = a.b + cin.(a+b)
and #(50) and1(c1,a,b);
or #(50) or1(c2,a,b);
and #(50) and2(c3,c2,cin);
or #(50) or2(cout,c1,c3);
endmodule 
Add a comment
Know the answer?
Add Answer to:
Design and code in Verilog an Arithmetic Logic Unit(ALU). It should be able to take two numbers o...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design and code in Verilog an Arithmetic Logic Unit(ALU). It should be able to take two...

    Design and code in Verilog an Arithmetic Logic Unit(ALU). It should be able to take two numbers of 32 bits and realize any instruction that requires logic and arithmetic operations. The output of the ALU will be a number of 32 bits.

  • VHDL code for a 32-bit Arithmetic Logic Unit using "Reversible logic gates". Should be able to...

    VHDL code for a 32-bit Arithmetic Logic Unit using "Reversible logic gates". Should be able to perform all Arithmetic and logic operations.

  • Implement an arithmetic logic unit (ALU) using Verilog. Consider signed number arithmetic operation. The outputs of...

    Implement an arithmetic logic unit (ALU) using Verilog. Consider signed number arithmetic operation. The outputs of the ALU should be 1) Addition of two 8-bit numbers 2) A Zero Flag. It is set (it is 1 if the condition is met and 0 otherwise) if the result is zero. 3) A Negative Flag. It is set (it is 1 if the condition is met and 0 otherwise) if the result is less than 0. 4) An Overflow Flag. It is...

  • The Arithmetic Logic Unit The first topic for the project is to create an Arithmetic Logic...

    The Arithmetic Logic Unit The first topic for the project is to create an Arithmetic Logic Unit, using a structured approached with a Virtual Hardware Design Language such as Verilog. Mainly, the program is very close to a simulator for a programming calculator. An ALU typically has the following operations Math Functions: Add, Subtract, Multiply, Divide, Modulus Logic Functions: And, Or, XOR, Not, Nand, Nor, XNOR Error Modes: Divide by Zero, Overflow Support Functions: No Operation, Shift Left, Shift Right,...

  • Q2. Design a 8-bit ALU (Arithmetic Logic Unit) supporting the following instructions, Z and C values...

    Q2. Design a 8-bit ALU (Arithmetic Logic Unit) supporting the following instructions, Z and C values should be re-evaluated (updated) ifY changes Instruction type code[2:0] operations Logical Status update 001 010 011 100 101 110 ( Bitwise AND) Y = A & B: | Z (C is always 0) (bitwise OR) Y- A B; (bitwise XOR) Y-A B Z (Cis always 0) (negation) Y =-A; (Addition) Y A + B: (subtraction) Y = A-B: (Increment) Y-A+1 (decrement) Y-A-1 Z (C...

  • Design a 4-bit Arithmetic Logic Unit (ALU) according to the following specification

     Design a 4-bit Arithmetic Logic Unit (ALU) according to the following specification. Follow the design shown during the lecture. Notice this table is different, though. a. Create the internal of 1-bit of the logic unit (It is recommended that you design the internal of a 4 to 1 MUX first, create a symbol for it and use it for creating the logic unit) b. Create a symbol for your logic unit and use four of them to make a 4-bit logic unit c....

  • Using Structural Modeling in VHDL write the code for: An Arithmetic Logic Unit (ALU) shown in...

    Using Structural Modeling in VHDL write the code for: An Arithmetic Logic Unit (ALU) shown in the figure below. A (16-bit), B (16-bit), Opcode (3-bit), and Mode (1-bit) are the inputs; and ALUOut (16-bit) and Cout (1-bit) are the outputs of the design. A and B hold the values of the operands. Mode and Opcode together indicate the type of the operation performed by ALU. The ALU components ARE: -Arithmetic Unit that consists of one 16-bit adder, 16-bit subtractor, 16-bit...

  • Derive the logic gates for a 2-bit Arithmetic Logic Unit (ALU) with four micro-operations: 1) Complete...

    Derive the logic gates for a 2-bit Arithmetic Logic Unit (ALU) with four micro-operations: 1) Complete the table below by showing the select input bits and the necessary groupings. (5 points) Select Inputs Micro-Operation Description F = A-B-1 F = A + B +1 F = AVB F = ashl A Subtraction with borrow Addition with carry Logic OR Arithmetic shift left 2) Draw a detailed logic circuit of the ALU's arithmetic unit. (10 points) 3) Draw a detailed logic...

  • Problem 3 - Arithmetie Logic Unit (ALU) Design us poins Design a 4-bit ALU that has two selection...

    Problem 3 - Arithmetie Logic Unit (ALU) Design us poins Design a 4-bit ALU that has two selection variables Si Design an optimized circuit (mus external gates for circuit B operates based on the function table given below. The arithmetic unit and So and generates the arithmetic operations given below. and generatest Use a 4-1 MUX block with Si So Cin = 1 F-A (complement) F = A+B (add) FB (transfer) F A+B F = A+ 1 (negate) F A+B+...

  • FIRST ACTIVITY: (100/100) . SIMPLE 4-BIT ARITHMETIC LOGIC UNIT (ALU): This circuit selects between arithmetic (absolute...

    FIRST ACTIVITY: (100/100) . SIMPLE 4-BIT ARITHMETIC LOGIC UNIT (ALU): This circuit selects between arithmetic (absolute value, addition) and logical (XOR, AND) operations. Only one result (hexadecimal value) can be shown on the 7-segment display This is selected by the input sel (1..0) B A-BI A+B A xnor B A nand B Input EN: If EN-1result appears on the 7 segment display. If EN=0 → all LEDs in the 7 segment display are off Arithmetic operations: The 4-bit inputs A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT