Question: how to write testbenches for the code modules: 1- module half_adder (A,B,Sum,Carry); input A,B; //two 1-bit inputs output Sum, Carry; //two 1-bit outputs assign Sum

how to write testbenches for the code modules: 
1- 
module half_adder (A,B,Sum,Carry); input A,B; //two 1-bit inputs output Sum, Carry; //two 1-bit outputs assign Sum = A ^ B; //sum is A xor B assign Carry = A & B; //Carry is A and B 

endmodule

2-

module MIPSALU (ALUctl, A, B, ALUOut, Zero); input [3:0] ALUctl; 
 input [31:0] A,B; output reg [31:0] ALUOut; output Zero; 

assign Zero = (ALUOut==0); //Zero is true if ALUOut is 0; goes anywhere always @(ALUctl, A, B) //reevaluate if these change

 case (ALUctl) 0: ALUOut <= A & B; 
 1: ALUOut <= A | B; 2: ALUOut <= A + B; 6: ALUOut <= A  B; 7: ALUOut <= A < B ? 1:0; 12: ALUOut <= ~(A | B); // result is nor default: ALUOut <= 0; //default to 0, should not happen; 
 endcase endmodule 
 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!