public Thread(ICore core, ContextStat stat, uint num, Process process)
        {
            this.Core = core;

            this.Num = num;

            this.Process = process;

            this.Bpred = new CombinedBranchPredictor ();

            this.RenameTable = new RegisterRenameTable (this);

            this.ClearArchRegs ();

            this.MemoryMapId = MemoryManagementUnit.CurrentMemoryMapId++;
            this.Mem = new Memory ();

            this.Process.Load (this);

            this.Stat = stat;

            this.Itlb = new TranslationLookasideBuffer (this.Core, this.Core.Processor.Config.Tlb, this.Stat.Itlb);
            this.Dtlb = new TranslationLookasideBuffer (this.Core, this.Core.Processor.Config.Tlb, this.Stat.Dtlb);

            this.State = ThreadState.Active;

            for (uint i = 0; i < RegisterConstants.NUM_INT_REGS; i++) {
                PhysicalRegister physReg = this.Core.IntRegFile[this.Num * RegisterConstants.NUM_INT_REGS + i];
                physReg.Commit ();
                this.RenameTable[RegisterDependency.Types.Integer, i] = physReg;
            }

            for (uint i = 0; i < RegisterConstants.NUM_FLOAT_REGS; i++) {
                PhysicalRegister physReg = this.Core.FpRegFile[this.Num * RegisterConstants.NUM_FLOAT_REGS + i];
                physReg.Commit ();
                this.RenameTable[RegisterDependency.Types.Float, i] = physReg;
            }

            for (uint i = 0; i < RegisterConstants.NUM_MISC_REGS; i++) {
                PhysicalRegister physReg = this.Core.MiscRegFile[this.Num * RegisterConstants.NUM_MISC_REGS + i];
                physReg.Commit ();
                this.RenameTable[RegisterDependency.Types.Misc, i] = physReg;
            }

            this.CommitWidth = core.Processor.Config.CommitWidth;

            this.DecodeBuffer = new List<DecodeBufferEntry> ();
            this.ReorderBuffer = new List<ReorderBufferEntry> ();
            this.LoadStoreQueue = new List<ReorderBufferEntry> ();

            this.FetchNpc = this.Regs.Npc;
            this.FetchNnpc = this.Regs.Nnpc;
        }
        public Processor(Simulation simulation)
        {
            this.Simulation = simulation;

            this.Cores = new List<ICore> ();

            this.CurrentCycle = 0;

            this.ActiveThreadCount = 0;

            for (uint i = 0; i < this.Simulation.Config.Architecture.Processor.Cores.Count; i++) {
                Core core = new Core (this, i);

                for (uint j = 0; j < this.Simulation.Config.Architecture.Processor.NumThreadsPerCore; j++) {
                    ContextConfig context = this.Simulation.Config.Contexts[(int)(i * this.Simulation.Config.Architecture.Processor.NumThreadsPerCore + j)];

                    List<string> args = new List<string> ();
                    args.Add (context.Workload.Cwd + Path.DirectorySeparatorChar + context.Workload.Exe + ".mipsel");
                    args.AddRange (context.Workload.Args.Split (' '));

                    Process process = new Process (context.Workload.Cwd, args);

                    uint threadNum = i * this.Simulation.Config.Architecture.Processor.NumThreadsPerCore + j;
                    ContextStat contextStat = this.Simulation.Stat.Processor.Contexts[(int)threadNum];

                    Thread thread = new Thread (core, contextStat, j, process);

                    core.Threads.Add (thread);

                    this.ActiveThreadCount++;
                }

                this.Cores.Add (core);
            }

            this.MemorySystem = new MemorySystem (this);
        }