private void PerformFetch() { while (!areWeDone) { fetchEvent.WaitOne(); Console.WriteLine("In Fetch"); //fetch the instruction here if (Fetch_Counter < Memory.getBinaryInstructions().Count) { short instruction = Memory.getBinaryInstructions().ElementAt(Fetch_Counter); var FI = new FetchedInstruction(instruction, Fetch_Counter); fetched_instructions.Enqueue(FI); this.IR = instruction; Console.WriteLine("IR is " + this.IR + ", fetch counter is " + Fetch_Counter); Fetch_Counter++; if (OnFetchDone != null) { OnFetchDone(this, new FetchEventArgs(FI)); //OnFetchDone(this, new StageDoneEventArgs(Fetch_Counter - 1, StageType.Fetch)); } /*if (OnStageDone != null) * { * Console.WriteLine("Inside on stage done for fetch..."); * OnStageDone(this, new StageDoneEventArgs(StageType.Fetch)); * }*/ } CPU_OnStageDone(StageType.Fetch); } }
public void PerformDecode() { while (!areWeDone) { decodeEvent.WaitOne(); Console.WriteLine("In Decode"); if (fetched_instructions.Count > 0) { FetchedInstruction instr = fetched_instructions.Dequeue(); Console.WriteLine("Decode counter is: " + Decode_Counter); DecodedInstruction decodedInstr = new DecodedInstruction(instr.binary, instr.index); decoded_instructions.Enqueue(decodedInstr); Decode_IR = decodedInstr; //If Branch, then add to table. if (decodedInstr.opcode == "100") { currBranchInstr = Memory.getAssemblyInstructions().ElementAt(decodedInstr.index); branches.Add(new branchClass(decodedInstr.index)); } else { currBranchInstr = ""; } Console.WriteLine("Just decoded: " + decodedInstr.binary); if (OnDecodeDone != null) { OnDecodeDone(this, new DecodeEventArgs(decodedInstr)); //OnDecodeDone(this, new StageDoneEventArgs(instr.index, StageType.Decode)); } /*if (OnStageDone != null) * { * OnStageDone(this, new StageDoneEventArgs(StageType.Decode)); * }*/ Decode_Counter++; } CPU_OnStageDone(StageType.Decode); } }
private void PerformFetch() { while (!areWeDone) { fetchEvent.WaitOne(); Console.WriteLine("In Fetch"); //fetch the instruction here if (Fetch_Counter < Memory.getBinaryInstructions().Count) { short instruction = Memory.getBinaryInstructions().ElementAt(Fetch_Counter); var FI = new FetchedInstruction(instruction, Fetch_Counter); fetched_instructions.Enqueue(FI); this.IR = instruction; Console.WriteLine("IR is " + this.IR + ", fetch counter is " + Fetch_Counter); Fetch_Counter++; if (OnFetchDone != null) { OnFetchDone(this, new FetchEventArgs(FI)); //OnFetchDone(this, new StageDoneEventArgs(Fetch_Counter - 1, StageType.Fetch)); } /*if (OnStageDone != null) { Console.WriteLine("Inside on stage done for fetch..."); OnStageDone(this, new StageDoneEventArgs(StageType.Fetch)); }*/ } CPU_OnStageDone(StageType.Fetch); } }