public float Compute(FloatingPointRegisters floatRegs, IntegerRegisters intRegs, int index) { float jVal = 0, kVal = 0; // Get Operands. if (Vj[index].opType == Operand.OperandType.FloatReg) { jVal = floatRegs.Get((int)Vj[index].opVal).value; } else if (Vj[index].opType == Operand.OperandType.IntReg) { jVal = intRegs.Get((int)Vj[index].opVal).value; } else if (Vj[index].opType == Operand.OperandType.Num) { jVal = Vj[index].opVal; } if (Vk[index].opType == Operand.OperandType.FloatReg) { kVal = floatRegs.Get((int)Vk[index].opVal).value; } else if (Vk[index].opType == Operand.OperandType.IntReg) { kVal = intRegs.Get((int)Vk[index].opVal).value; } else if (Vk[index].opType == Operand.OperandType.Num) { kVal = Vk[index].opVal; } // Compute Result switch (opCodes[index]) { case Instruction.Opcodes.ADDD: return(jVal + kVal); case Instruction.Opcodes.SUBD: return(jVal - kVal); case Instruction.Opcodes.MULD: return(jVal * kVal); case Instruction.Opcodes.DIVD: return(jVal / kVal); default: return(0); } }
public void Init() { clocks = 0; originalInstructions = instructionUnit.GetCurrentInstructions(); issueClocks = new int[100]; executeClocks = new int[100]; writeClocks = new int[100]; for (int i = 0; i < 100; i++) { issueClocks[i] = -1; executeClocks[i] = -1; writeClocks[i] = -1; } loadStation = new ReservationStation(3, ReservationStation.RSType.Load); storeStation = new ReservationStation(3, ReservationStation.RSType.Store); addStation = new ReservationStation(3, ReservationStation.RSType.Add); multiplyStation = new ReservationStation(2, ReservationStation.RSType.Multiply); branchStation = new ReservationStation(5, ReservationStation.RSType.Multiply); floatRegs = new FloatingPointRegisters(30); for (int i = 0; i < 30; i++) { floatRegs.Set(WaitInfo.WaitState.Avail, i + 1, i); } intRegs = new IntegerRegisters(30); memLocs = new FloatingPointMemoryArrary(64); for (int i = 0; i < 64; i++) { memLocs.Set(i + 1, i); } UpdateInstructionQueueBox(); UpdateIssuedInstructionsBox(); UpdateReservationStationBoxes(); UpdateFPRegisterBox(); UpdateIntRegisterBox(); UpdateClockCountBox(); }
public void BufferValue(int index, FloatingPointRegisters fRegs, IntegerRegisters iRegs) { switch (dest[index].opType) { case Operand.OperandType.FloatReg: if (fRegs.Get((int)dest[index].opVal).waitState == WaitInfo.WaitState.Avail) { results[index] = fRegs.Get((int)dest[index].opVal).value; isReady[index] = true; } break; case Operand.OperandType.IntReg: if (iRegs.Get((int)dest[index].opVal).waitState == WaitInfo.WaitState.Avail) { results[index] = iRegs.Get((int)dest[index].opVal).value; isReady[index] = true; } break; default: break; } }
public int ComputeAddress(IntegerRegisters regs, int index) { int jVal = 0, kVal = 0; if (Vj[index].opType == Operand.OperandType.IntReg) { jVal = (int)regs.Get((int)Vj[index].opVal).value; } else if (Vj[index].opType == Operand.OperandType.Num) { jVal = (int)Vj[index].opVal; } if (Vk[index].opType == Operand.OperandType.IntReg) { kVal = (int)regs.Get((int)Vk[index].opVal).value; } else if (Vk[index].opType == Operand.OperandType.Num) { kVal = (int)Vk[index].opVal; } return(jVal + kVal); }
public float DetermineBranch(FloatingPointRegisters floatRegs, IntegerRegisters intRegs, int index) { float jVal = 0, kVal = 0; // Get Operands. if (Vj[index].opType == Operand.OperandType.FloatReg) { jVal = floatRegs.Get((int)Vj[index].opVal).value; } else if (Vj[index].opType == Operand.OperandType.IntReg) { jVal = intRegs.Get((int)Vj[index].opVal).value; } else if (Vj[index].opType == Operand.OperandType.Num) { jVal = Vj[index].opVal; } if (Vk[index].opType == Operand.OperandType.FloatReg) { kVal = floatRegs.Get((int)Vk[index].opVal).value; } else if (Vk[index].opType == Operand.OperandType.IntReg) { kVal = intRegs.Get((int)Vk[index].opVal).value; } else if (Vk[index].opType == Operand.OperandType.Num) { kVal = Vk[index].opVal; } switch (opCodes[index]) { case Instruction.Opcodes.BEQ: if (jVal == kVal) { return(dest[index].opVal); } else { return(0); } case Instruction.Opcodes.BGEZ: return(0); case Instruction.Opcodes.BLEZ: return(0); case Instruction.Opcodes.BNE: if (jVal != kVal) { return(dest[index].opVal); } else { return(0); } default: return(0); } }