Beispiel #1
0
        private void runBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (initialized)
                {
                    cycleNumberLbl.Text = (CycleNumber + 1).ToString();
                    int NumberOfInstructions = MIPS.INSTRUCTION_MEM.Count;
                    if (CycleNumber < 5 + (NumberOfInstructions - 1))
                    {
                        //****
                        //the next condetions are to excute each phase with instructions in there oreder
                        //****
                        if (CycleNumber - 4 < NumberOfInstructions && CycleNumber - 4 >= 0)
                        {
                            MIPS.WriteBack();
                            MIPS.MEM_WB = new MEM_WB();
                        }
                        if (CycleNumber - 3 < NumberOfInstructions && CycleNumber - 3 >= 0)
                        {
                            MIPS.AccessMem();
                            MIPS.EX_MEM = new EX_MEM();
                        }
                        if (CycleNumber - 2 < NumberOfInstructions && CycleNumber - 2 >= 0)
                        {
                            MIPS.Excute();
                            MIPS.ID_EX = new ID_EX();
                        }
                        if (CycleNumber - 1 < NumberOfInstructions && CycleNumber - 1 >= 0)
                        {
                            MIPS.Decode();
                            MIPS.IF_ID = new IF_ID();
                        }
                        if (CycleNumber < NumberOfInstructions)
                        {
                            MIPS.Fetch();
                        }

                        CycleNumber++;
                        Refresh();
                    }
                    else
                    {
                        MessageBox.Show("no instructions to excute");
                    }
                }
                else
                {
                    MessageBox.Show("Please initialize the the values (Press Initialize button!)", "Values not initialized", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     mipsObject = new MIPS();
     mipsRegGrid.Rows.Clear();
     pipRegGrid.Rows.Clear();
     pcTextBox.Text = "1000";
     xDim           = yDim = columnToDisplay = 0;
     gabCycles      = 4;
     desiredJumpPC  = desiredLevel = -1;
     mipsObject.fillInstructionSet(userCodeData);
     mipsObject.update(mipsRegGrid, pcTextBox);
 }
Beispiel #3
0
 private void initializeBtn_Click(object sender, EventArgs e)
 {
     try
     {
         //reset all values to its default
         Reset();
         //split the instructions string into separate instructions
         string[] instructions = userCodeTxt.Text.Split('\n');
         //set the PC of MIPS with the given
         MIPS.PC = Convert.ToInt32(pcTxt.Text);
         //splits the instructions into PC and instruction machine code
         MIPS.SplitInstructions(instructions);
         initialized = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     clr();
     mips = new MIPS();
     mips.init();
     for (int i = 0; i < 32; i++)
     {
         dataGridView3.Rows.Add(new string[] { "$" + i, mips.registers[i].ToString() });
     }
     for (int i = 0; i < 1024; i++)
     {
         dataGridView2.Rows.Add(new string[] { "$" + i, "99" });
     }
     if (textBox1.Text.Length < 4)
     {
         convert_from_assembly_to_machine();
     }
     if (textBox2.Text.Length < 4)
     {
         convert_from_machine_to_assembly();
     }
     init();
 }
Beispiel #5
0
 public Form1()
 {
     InitializeComponent();
     mipsObject = new MIPS();
     mipsObject.update(mipsRegGrid, pcTextBox);
 }