static void Show_WriteBack() { Text txt = GameObject.Find("Canvas/PipeLine_Panel/W_State/Value").GetComponent <Text>(); txt.text = Get_State(Write_back.Show_W_state()); txt = GameObject.Find("Canvas/PipeLine_Panel/W_Instr/Value").GetComponent <Text>(); txt.text = Get_Ins(Write_back.Show_W_icode(), Write_back.Show_W_ifun()); txt = GameObject.Find("Canvas/PipeLine_Panel/W_dstE/Value").GetComponent <Text>(); txt.text = Get_Reg(Write_back.Show_W_dstE()); txt = GameObject.Find("Canvas/PipeLine_Panel/W_dstM/Value").GetComponent <Text>(); txt.text = Get_Reg(Write_back.Show_W_dstM()); txt = GameObject.Find("Canvas/PipeLine_Panel/W_valE/Value").GetComponent <Text>(); txt.text = Get_Fmt(Write_back.Show_W_valE()); txt = GameObject.Find("Canvas/PipeLine_Panel/W_valM/Value").GetComponent <Text>(); txt.text = Get_Fmt(Write_back.Show_W_valM()); }
static public void Shown_Log() { if (nlog == 10000) { return; } nlog++; System.IO.StreamWriter sw = new StreamWriter(@"./log.out", true); sw.WriteLine("Clock = " + Updata.Clock.ToString("X")); sw.WriteLine("Fetch:"); sw.WriteLine("Pred_PC = " + Fetch.Show_F_predPC().ToString("X")); sw.WriteLine("Decode:"); sw.Write("state = " + Decode.Show_D_state().ToString() + " ; "); sw.Write("Instr = " + Get_Ins(Decode.Show_D_icode(), Decode.Show_D_ifun()) + " ; "); sw.Write("rA = " + Get_Reg(Decode.Show_D_rA()) + " ; "); sw.Write("rB = " + Get_Reg(Decode.Show_D_rB()) + " ; "); sw.WriteLine(""); sw.Write("valC = " + Decode.Show_D_valC().ToString("X") + " ; "); sw.Write("valP = " + Decode.Show_D_valP().ToString("X") + " ; "); sw.WriteLine(""); sw.WriteLine("Excute:"); sw.Write("state = " + Excute.Show_E_state().ToString() + " ; "); sw.Write("Instr = " + Get_Ins(Excute.Show_E_icode(), Excute.Show_E_ifun()) + " ; "); sw.Write("dstE = " + Get_Reg(Excute.Show_E_dstE()) + " ; "); sw.Write("dstM = " + Get_Reg(Excute.Show_E_dstM()) + " ; "); sw.Write("srcA = " + Get_Reg(Excute.Show_E_srcA()) + " ; "); sw.Write("srcB = " + Get_Reg(Excute.Show_E_srcB()) + " ; "); sw.WriteLine(""); sw.Write("valA = " + Excute.Show_E_valA().ToString("X") + " ; "); sw.Write("valB = " + Excute.Show_E_valB().ToString("X") + " ; "); sw.Write("valC = " + Excute.Show_E_valC().ToString("X") + " ; "); sw.WriteLine(""); sw.Write("OF = " + Excute.Show_OF().ToString() + " ; " + "ZF = " + Excute.Show_ZF().ToString() + " ; "); sw.WriteLine("SF = " + Excute.Show_SF().ToString() + " ; "); sw.WriteLine("Memory:"); sw.Write("state = " + Memory.Show_M_state().ToString() + " ; "); sw.Write("Instr = " + Get_Ins(Memory.Show_M_icode(), Memory.Show_M_ifun()) + " ; "); sw.Write("dstE = " + Get_Reg(Memory.Show_M_dstE()) + " ; "); sw.Write("dstM = " + Get_Reg(Memory.Show_M_dstM()) + " ; "); sw.WriteLine(""); sw.Write("valA = " + Memory.Show_M_valA().ToString("X") + " ; "); sw.Write("valE = " + Memory.Show_M_valE().ToString("X") + " ; "); sw.Write("Cnd = " + Memory.Show_M_Cnd().ToString() + " ; "); sw.WriteLine(""); sw.WriteLine("Write_Back:"); sw.Write("state = " + Write_back.Show_W_state().ToString() + " ; "); sw.Write("Instr = " + Get_Ins(Write_back.Show_W_icode(), Write_back.Show_W_ifun()) + " ; "); sw.Write("dstE = " + Get_Reg(Write_back.Show_W_dstE()) + " ; "); sw.Write("dstM = " + Get_Reg(Write_back.Show_W_dstM()) + " ; "); sw.WriteLine(""); sw.Write("valE = " + Write_back.Show_W_valE().ToString("X") + " ; "); sw.Write("valM = " + Write_back.Show_W_valM().ToString("X") + " ; "); sw.WriteLine(""); for (int i = 0; i < 15; i++) { sw.Write(((Control.Registers)i).ToString() + " = " + Decode.Read_reg(i).ToString("X") + " ; "); if ((i + 1) % 3 == 0) { sw.WriteLine(""); } } sw.WriteLine(""); sw.Close(); }
static public void Work() { e_state = E_state; long e_ALUA = 0, e_ALUB = 0; if (E_icode == Control.Codes.IRRMOVQ || E_icode == Control.Codes.IOPQ) { e_ALUA = E_valA; } if (E_icode == Control.Codes.IIRMOVQ || E_icode == Control.Codes.IRMMOVQ || E_icode == Control.Codes.IMRMOVQ || E_icode == Control.Codes.IIOPQ) { e_ALUA = E_valC; } if (E_icode == Control.Codes.IRET || E_icode == Control.Codes.IPOPQ) { e_ALUA = 8; } if (E_icode == Control.Codes.ICALL || E_icode == Control.Codes.IPUSHQ) { e_ALUA = -8; } if (E_icode == Control.Codes.IRRMOVQ || E_icode == Control.Codes.IIRMOVQ) { e_ALUB = 0; } else { e_ALUB = E_valB; } switch (E_ifun) { case (0): e_valE = e_ALUB + e_ALUA; break; case (1): e_valE = e_ALUB - e_ALUA; break; case (2): e_valE = e_ALUB & e_ALUA; break; case (3): e_valE = e_ALUB ^ e_ALUA; break; } if ((E_icode == Control.Codes.IOPQ || E_icode == Control.Codes.IIOPQ) && Write_back.Show_W_state() == Control.States.SAOK && Memory.Show_m_state() == Control.States.SAOK && E_state == Control.States.SAOK) { e_SetCC = true; } else { e_SetCC = false; } if (e_SetCC) { ZF = (e_valE == 0); SF = (e_valE < 0); if (E_ifun == 0) { OF = (((e_ALUA < 0) == (e_ALUB < 0)) && ((e_valE < 0) != (e_ALUA < 0))); } if (E_ifun == 1) { OF = (((e_ALUA < 0) != (e_ALUB < 0)) && ((e_valE < 0) != (e_ALUB < 0))); } if (E_ifun == 2 || E_ifun == 3) { OF = false; } } e_valA = E_valA; e_Cnd = false; switch (E_ifun) { case 0: e_Cnd = true; break; case 1: e_Cnd = SF | ZF; break; case 2: e_Cnd = SF; break; case 3: e_Cnd = ZF; break; case 4: e_Cnd = (!ZF); break; case 5: e_Cnd = (!SF); break; case 6: e_Cnd = (!SF && !ZF); break; } e_ifun = E_ifun; e_dstM = E_dstM; e_icode = E_icode; if (e_icode == Control.Codes.IRRMOVQ && !e_Cnd) { e_dstE = Control.Registers.RNONE; } else { e_dstE = E_dstE; } }