ALU (20 pts) Implement a 32-bit ALU. Input: a (32 bits), b (32 bits), and op (3 bits). Output: s (32 bits). The ALU shou

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

ALU (20 pts) Implement a 32-bit ALU. Input: a (32 bits), b (32 bits), and op (3 bits). Output: s (32 bits). The ALU shou

Post by answerhappygod »

Alu 20 Pts Implement A 32 Bit Alu Input A 32 Bits B 32 Bits And Op 3 Bits Output S 32 Bits The Alu Shou 1
Alu 20 Pts Implement A 32 Bit Alu Input A 32 Bits B 32 Bits And Op 3 Bits Output S 32 Bits The Alu Shou 1 (55.61 KiB) Viewed 79 times
//32-bit ALU
module ALU(input [31:0] a,
input [31:0] b,
input [2:0] op,
output reg [31:0] s);
//write your code here
always @(*) begin
case (op)
0:s=a+b;
1:s=a-b;
2:s=a+1;
3:s=0;
4:s=a&b;
5:s=a|b;
6:s=a^b;
7:s=~a;
default: s=0;
endcase

end
endmodule
here is my code.
but I have no idea to write the TestBench code,
can some explain how to write the TestBench code for me pls!
ALU (20 pts) Implement a 32-bit ALU. Input: a (32 bits), b (32 bits), and op (3 bits). Output: s (32 bits). The ALU should send the results of operations with a and b to s. The operations are specified by the value of op, as shown in the following table: Assume a = 0x0000001 and b = OxFFFFFFFF, we Table 3: Operations of ALU op operation 0 a + b 1 a - b 2 a + 1 3 0 4 a AND 5 a OR b 6 a XOR b 7 NOT a S Ox00000000 Ox00000002 Ox00000002 Ox00000000 Ox00000001 OxFFFFFFFF OxFFFFFFFE OxFFFFFFF also show the results of each operations in the above table. Notice that AND, OR, XOR, and NOT are bitwise operations. Evaluation Your score will be computed out of a maximum 100 points. 80 points are given based on the correctness of all modules. 20 points are given based on your testbench code.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply