Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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;
            }
        }
        private void UpdateFPRegisterBox()
        {
            fpRegisters.Clear();
            fpRegisters.View = View.Details;
            fpRegisters.Columns.Add("");
            for (int i = 0; i < floatRegs.GetNumRegs(); i++)
            {
                fpRegisters.Columns.Add("F" + i.ToString());
            }

            ListViewItem row = new ListViewItem("FU");

            for (int i = 0; i < floatRegs.GetNumRegs(); i++)
            {
                switch (floatRegs.Get(i).waitState)
                {
                case WaitInfo.WaitState.AddStation:
                    row.SubItems.Add("Add" + (floatRegs.Get(i).value + 1).ToString());
                    break;

                case WaitInfo.WaitState.Avail:
                    row.SubItems.Add(floatRegs.Get(i).value.ToString());
                    break;

                case WaitInfo.WaitState.Compute:
                    row.SubItems.Add(floatRegs.Get(i).value.ToString());
                    break;

                case WaitInfo.WaitState.LoadStation:
                    row.SubItems.Add("Load" + (floatRegs.Get(i).value + 1).ToString());
                    break;

                case WaitInfo.WaitState.MultStation:
                    row.SubItems.Add("Mult" + (floatRegs.Get(i).value + 1).ToString());
                    break;

                case WaitInfo.WaitState.StoreStation:
                    row.SubItems.Add("Store" + (floatRegs.Get(i).value + 1).ToString());
                    break;
                }
            }
            fpRegisters.Items.Add(row);
        }
Beispiel #4
0
        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);
            }
        }