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;
            }
        }
Beispiel #3
0
        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);
        }
        private void UpdateIntRegisterBox()
        {
            intRegisters.Clear();
            intRegisters.View = View.Details;
            intRegisters.Columns.Add("");
            for (int i = 0; i < intRegs.GetNumRegs(); i++)
            {
                intRegisters.Columns.Add("R" + i.ToString());
            }

            ListViewItem row = new ListViewItem("FU");

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

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

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

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

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

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