module MUX_PC(PC_Sel_D,PC_Sel_M,ADD4,NPC,EPC,NextPC);
//interface
	input [31:0] PC_Sel_D;
	input [31:0] PC_Sel_M;
	
	input [31:0] ADD4;
	input [31:0] NPC;
	input [31:0] EPC;
	
	output reg [31:0] NextPC;	//real NPC to output

//select logic
	parameter ADD4_NPC=0,
			  NPC_NPC=1,
			  CP0_EPC=2;
	
	always @(*)
		begin
			NextPC=ADD4;				//avoid latch
			if(PC_Sel_M==2)NextPC=EPC;	//i.e. eret is at MEM
			else
				begin
					case(PC_Sel_D)		//not jump until eret at MEM
						ADD4_NPC:NextPC=ADD4;
						NPC_NPC:NextPC=NPC;
					endcase
				end
		end
	
endmodule