Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

help Objective: To implement and simulate the 32-bit ALU shown below using Veril

ID: 1846125 • Letter: H

Question

help

Objective: To implement and simulate the 32-bit ALU shown below using Verilog. Instructions for SLT: If A is less than B, Y must be the 32-bit representation of 1 (0 times 00000001) Example: Suppose A = 25 and B = 32. - For SLT, F2:0 = 111. -F2 = 1 configures the added unit as a subtracter. So 25 - 32 = -7. - The two's complement representation of -7 has a 1 in the most significant bit, so S31 = 1. With F1:0 = 11, the final multiplexer selects Y = S31 (zero extended) = 0 times 00000001. Assignment: Create the ALU in Verilog that reflects the diagram illustrated in the previous page. Provide comments throughout your code. Synthesize, simulate, and test your design for various input combinations.

Explanation / Answer


    1 module ALU (A, B, F,Y);     2 input [N:0]A,[N:0] B, [2:0]F;
  3 output [N:0]Y;
reg [N:0]Y;
reg [2:0]F;
  5 reg [N:0]A;
6 reg [N:0]B; 7 8 always @ (A or B or F) 9 case (F) 10 0 : Y = A&B ;
 11   1 : Y = A|B;    12   2 : Y = A+B; 
 12   3 : $display("Error in SEL");  
13 4 : Y =A & ~B ;
  10  5 : Y = A | ~B ; 
   11   6 : Y = A-B;    12   7 : Y = A+B;    13   4 : Y = Y << 1 ;
14 default : $display("Error in F"); 15 endcase 16 17 endmodule