data/full_repos/permissive/157101210/no-op.v
 line:66: before: "/"
data/verilator_xmls/61279a2c-e55a-40cd-916e-8e9648c8ea3a.xml
module noOp(
	input[31:0] initiaInstruction,
	input ID_NoOp,
	input ID_PreNoOp,
	output reg[31:0] instr,
	output reg IF_NoOp,
	output reg IF_PreNoOp
);

reg needsPreNoOp;
reg isOtherBranch;
wire[31:0] noOPInstr;
reg[5:0] opcode;
reg[5:0] funct;

assign noOPInstr = 32'b00100000000000000000000000000000;

always @(initiaInstruction or ID_NoOp or ID_PreNoOp) begin
	opcode = initiaInstruction[31:26];
	funct = initiaInstruction[5:0];
	case (opcode)
		`LW_OP:   begin needsPreNoOp=0; isOtherBranch=1; end
		`SW_OP:   begin needsPreNoOp=0; isOtherBranch=0; end
		`J_OP:    begin needsPreNoOp=0; isOtherBranch=0; end
		`JAL_OP:  begin needsPreNoOp=0; isOtherBranch=0; end
		`BEQ_OP:  begin needsPreNoOp=1; isOtherBranch=0; end
		`BNE_OP:  begin needsPreNoOp=1; isOtherBranch=0; end
		`XORI_OP: begin needsPreNoOp=0; isOtherBranch=0; end
		`ADDI_OP: begin needsPreNoOp=0; isOtherBranch=0; end

		`RTYPE_OP: begin
			case (funct)
				`JR_FUNCT:  begin needsPreNoOp=1; isOtherBranch=0; end
				`ADD_FUNCT: begin needsPreNoOp=0; isOtherBranch=0; end
				`SUB_FUNCT: begin needsPreNoOp=0; isOtherBranch=0; end
				`SLT_FUNCT: begin needsPreNoOp=0; isOtherBranch=0; end
				default: $display("Error in No-Op: Invalid funct");
			endcase
		end
		default: $display("Error in No-Op: Invalid opcode. OPCODE: %b", opcode);
	endcase

	if(needsPreNoOp && !ID_PreNoOp && !ID_NoOp) begin instr = noOPInstr; IF_PreNoOp = 1; IF_NoOp = 0; end
	else if(ID_PreNoOp) begin instr = initiaInstruction; IF_PreNoOp = 0; IF_NoOp = 1; end
	else if(ID_NoOp) begin instr = noOPInstr; IF_PreNoOp = 0; IF_NoOp = 0; end
	else if(isOtherBranch) begin instr = initiaInstruction; IF_PreNoOp = 0; IF_NoOp = 1; end
	else begin instr = initiaInstruction; IF_PreNoOp = 0; IF_NoOp = 0; end
end
endmodule
module noOp(
	input[31:0] initiaInstruction,
	input ID_NoOp,
	input ID_PreNoOp,
	output reg[31:0] instr,
	output reg IF_NoOp,
	output reg IF_PreNoOp
);


reg needsPreNoOp;
reg isOtherBranch;
wire[31:0] noOPInstr;
reg[5:0] opcode;
reg[5:0] funct;

assign noOPInstr = 32'b00100000000000000000000000000000;

always @(initiaInstruction or ID_NoOp or ID_PreNoOp) begin
	opcode = initiaInstruction[31:26];
	funct = initiaInstruction[5:0];
	case (opcode)
		`LW_OP:   begin needsPreNoOp=0; isOtherBranch=1; end
		`SW_OP:   begin needsPreNoOp=0; isOtherBranch=0; end
		`J_OP:    begin needsPreNoOp=0; isOtherBranch=0; end
		`JAL_OP:  begin needsPreNoOp=0; isOtherBranch=0; end
		`BEQ_OP:  begin needsPreNoOp=1; isOtherBranch=0; end
		`BNE_OP:  begin needsPreNoOp=1; isOtherBranch=0; end
		`XORI_OP: begin needsPreNoOp=0; isOtherBranch=0; end
		`ADDI_OP: begin needsPreNoOp=0; isOtherBranch=0; end

		`RTYPE_OP: begin
			case (funct)
				`JR_FUNCT:  begin needsPreNoOp=1; isOtherBranch=0; end
				`ADD_FUNCT: begin needsPreNoOp=0; isOtherBranch=0; end
				`SUB_FUNCT: begin needsPreNoOp=0; isOtherBranch=0; end
				`SLT_FUNCT: begin needsPreNoOp=0; isOtherBranch=0; end
				default: $display("Error in No-Op: Invalid funct");
			endcase
		end
		default: $display("Error in No-Op: Invalid opcode. OPCODE: %b", opcode);
	endcase

	if(needsPreNoOp && !ID_PreNoOp && !ID_NoOp) begin instr = noOPInstr; IF_PreNoOp = 1; IF_NoOp = 0; end
	else if(ID_PreNoOp) begin instr = initiaInstruction; IF_PreNoOp = 0; IF_NoOp = 1; end
	else if(ID_NoOp) begin instr = noOPInstr; IF_PreNoOp = 0; IF_NoOp = 0; end
	else if(isOtherBranch) begin instr = initiaInstruction; IF_PreNoOp = 0; IF_NoOp = 1; end
	else begin instr = initiaInstruction; IF_PreNoOp = 0; IF_NoOp = 0; end
end
endmodule