module sim_three; // file ¡°sim_three.v¡± reg [5:0] OP; reg [5:0] Func; reg [31:0] A, B; reg [4:0] shamt; wire [1:0] ALUOp; wire [3:0] ALUctl; wire M1, M2, M3, M4, W1, W2, W3, N1, N2; wire [31:0] ALUOut; wire Zero; control CTRL (OP, M1, ALUOp, M2, M4, N1, N2, W2, W3, W1, M3); aluctrl ALUCTL (ALUOp, Func, ALUctl); alu ALU (ALUctl, A, B, shamt, ALUOut, Zero); initial begin OP = 6'b0; Func = 6'h20; // add shamt = 5'd0; A = 32'd13; B = 32'd20; #1; $display(" ADD"); $display("ALUOut = (33) ", ALUOut); // 33 or 0x21 or 0000 0000 0010 0001 $display("Zero = (0) ", Zero); // 0 //OP = 6'b0; Func = 6'h27; // nor //shamt = 5'd0; //A = 32'd13; //B = 32'd20; #1; $display(" NOR"); $display("ALUOut = (-30) ", ALUOut); // -30 or 0xffe2 or 1111 1111 1110 0010 $display("Zero = (0) ", Zero); // 0 OP = 6'b101011; //Func = 6'h27; // sw //shamt = 5'd0; A = 32'd13; B = 32'd20; #1; $display(" SW"); $display("ALUOut = (33) ", ALUOut); // 33 $display("Zero = (0) ", Zero); // 0 OP = 6'b000101; //Func = 6'h27; // bne //shamt = 5'd0; A = 32'd13; B = 32'd20; #1; $display(" BNE"); $display("ALUOut = (-7) ", ALUOut); // -7 $display("Zero = (0) ", Zero); // 0 $finish; end endmodule