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

Ineed the code using verilog Verilog program as shown in the below table using t

ID: 2249652 • Letter: I

Question

Ineed the code using verilog Verilog program as shown in the below table using the Quartus software. This ALU has 2 8-bit data inputs (A and B), a 3-bit select input (S), and an 8-bit output (F) Operation Clear Add Subtract1 Subtract2 Complement1 Complement2 XOR XNOR Select Input (S) Output (F 001 010 011 100 101 110 A+B Complement A Complement B A XOR R A XNOR B The project report should include the Verilog program with comments, and four timing diagrams testing all eight operations for four situations 1. A 105 and B 60, 2, A = 128 and B-40, 3, A = 77 and B 77, and 4, A 0 and B-255 The team must save all their work, including "rpt" file, for future demonstration to the instructor

Explanation / Answer

/////////////// DESIGN FILE /////////////////////
module ALU_design (
  input [7:0] A, B,
  input [2:0] S,
  output reg [7:0] F
);


always @ (*)
  begin
   case(S) // With different combination of S perform operations given in the table
   3'b001 : F = 8'd0 ; // clear
   3'b010 : F = A + B ; // Add A and B
   3'b011 : F = B - A ; // subtract B from A
   3'b100 : F = ~(A) ; // Complement A
   3'b101 : F = ~(B) ; // Complement B
   3'b110 : F = (A ^ B) ; // A XOR B
   3'b111 : F = (A ^~ B) ; // A XNOR B
   default : F = 0; // default
   endcase
  end

endmodule

///////////// TEST_BENCH_FILE /////////////////
module top;
reg [7:0] A, B;
reg [2:0] S;
wire [7:0] F;

// instantiation of the module
ALU_design c1 (.A(A), .B(B), .S(S), .F(F));

integer i;

initial begin
   $monitor("A = %d B = %d S = %d F = %d", A, B, S, F); // to print the output on compile window
   A = 8'd105; // Initialize value of A and B
   B = 8'd60;
   for (i = 0; i < 8 ; i = i + 1) begin
   S = i; // put S with all values between 0 to 7
   #20; // give a delay
   end

   A = 8'd128;
   B = 8'd40;
   for (i = 0; i < 8 ; i = i + 1) begin
   S = i;
   #20;
   end

   A = 8'd77;
   B = 8'd77;
   for (i = 0; i < 8 ; i = i + 1) begin
   S = i;
   #20;
   end

   A = 8'd0;
   B = 8'd255;
   for (i = 0; i < 8 ; i = i + 1) begin
   S = i;
   #20;
   end

end

endmodule

/*********************** OUTPUT OF PROGRAM *******************
A = 105 B = 60 S = 0 F = 0
A = 105 B = 60 S = 1 F = 0
A = 105 B = 60 S = 2 F = 165
A = 105 B = 60 S = 3 F = 211
A = 105 B = 60 S = 4 F = 150
A = 105 B = 60 S = 5 F = 195
A = 105 B = 60 S = 6 F = 85
A = 105 B = 60 S = 7 F = 170
A = 128 B = 40 S = 0 F = 0
A = 128 B = 40 S = 1 F = 0
A = 128 B = 40 S = 2 F = 168
A = 128 B = 40 S = 3 F = 168
A = 128 B = 40 S = 4 F = 127
A = 128 B = 40 S = 5 F = 215
A = 128 B = 40 S = 6 F = 168
A = 128 B = 40 S = 7 F = 87
A = 77 B = 77 S = 0 F = 0
A = 77 B = 77 S = 1 F = 0
A = 77 B = 77 S = 2 F = 154
A = 77 B = 77 S = 3 F = 0
A = 77 B = 77 S = 4 F = 178
A = 77 B = 77 S = 5 F = 178
A = 77 B = 77 S = 6 F = 0
A = 77 B = 77 S = 7 F = 255
A = 0 B = 255 S = 0 F = 0
A = 0 B = 255 S = 1 F = 0
A = 0 B = 255 S = 2 F = 255
A = 0 B = 255 S = 3 F = 255
A = 0 B = 255 S = 4 F = 255
A = 0 B = 255 S = 5 F = 0
A = 0 B = 255 S = 6 F = 255
A = 0 B = 255 S = 7 F = 0
*/