Exemple #1
0
 public void FwdB(ExecuteStage e, ExecuteRegister E, MemoryStage m, MemoryRegister M, WritebackRegister W)
 {
     int[] Set = new int[] { E.dstE, M.dstM, M.dstE, W.dstM, W.dstE };
     int[] Val = new int[] { e.valE, m.valM, M.valE, W.valM, W.valE };
     for (int i = 0; i < 5; i++)
         if (Set[i] == srcB)
         {
             valB = Val[i];
             return;
         }
     valB = rf.Read(srcB);
 }
Exemple #2
0
 public void SelFwdA(ExecuteStage e, ExecuteRegister E, MemoryStage m, MemoryRegister M, WritebackRegister W)
 {
     if (icode == ConstVar.IJXX || icode == ConstVar.ICALL)
         valA = D.valP;
     else
     {
         int[] Set = new int[] { E.dstE, M.dstM, M.dstE, W.dstM, W.dstE };
         int[] Val = new int[] { e.valE, m.valM, M.valE, W.valM, W.valE };
         for (int i = 0; i < 5; i++)
             if (Set[i] == srcA)
             {
                 valA = Val[i];
                 return;
             }
         valA = rf.Read(srcA);
     }
 }
Exemple #3
0
        public void Init(string inPath, string outPath = "output.txt")
        {
            Mem = new Memory(CodeStart + CodeMaxLen);
            StreamReader IStream = new StreamReader(inPath);
            BinaryReader reader = new BinaryReader(IStream.BaseStream);
            CodeLen = reader.Read(Mem.Data, CodeStart, CodeMaxLen);
            IStream.Close();

            writer = File.CreateText(outPath);

            Circle = 0;

            CL = new ControlLogic();
            CC = new ControlCode();
            rf = new Registerfile();

            f = new FetchStage();
            d = new DecodeStage();
            e = new ExecuteStage();
            m = new MemoryStage();

            F = new FetchRegister();
            D = new DecodeRegister();
            E = new ExecuteRegister();
            M = new MemoryRegister();
            W = new WritebackRegister();

            F.predPC = CodeStart;
            rf.Data[ConstVar.RESP] = CodeStart;

            f.F = F;
            f.Mem = Mem;
            d.D = D;
            d.rf = rf;
            e.E = E;
            e.CC = CC;
            m.M = M;
            m.Mem = Mem;

            CL.set(D, d, E, e, M);
        }
Exemple #4
0
 public void init(MemoryStage m)
 {
     icode = m.icode;
     valE = m.valE;
     valM = m.valM;
     dstE = m.dstE;
     dstM = m.dstM;
     Ins = m.Ins;
 }