Exemplo n.º 1
0
 public BranchEventArgs(CPU.DecodedInstruction instruction, int instructionIndex, bool taken)
 {
     //this is the branch instruction that was taken, and the index of said instruction
     CurrentIR = instruction;
     CurrentInstrIndex = instructionIndex;
     this.taken = taken;
 }
Exemplo n.º 2
0
 static void Main()
 {
     CPU cpu = new CPU();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     window = new Window(cpu);
     Application.Run(window);
 }
        public Form1()
        {
            myCPU = new CPU();

            InitializeComponent();

#if DEBUG
            loadFileButton.Text = "Hello";
#endif
        }
Exemplo n.º 4
0
 public Form1()
 { 
     myMem = new Memory();
     myCPU = new CPU();
     myCPU.OnFetchDone += myCPU_OnFetchDone;
     myCPU.OnDecodeDone += myCPU_OnDecodeDone;
     myCPU.OnExecuteDone += myCPU_OnExecuteDone;
     myCPU.OnStoreDone += myCPU_OnStoreDone;
     InitializeComponent();
 }
Exemplo n.º 5
0
        public Form1()
        {

            InitializeComponent();
            fillMemComboBox();
            fillCacheSizeComboBox();
            fillBlockSizeComboBox();

            cacheSizeBox.SelectedIndex = 0;

            memory = new Memory((int)(cacheSizeBox.SelectedItem), (int)(blockSizeBox.SelectedItem), addressMode);
            myCPU = new CPU(memory);
            myCPU.OnFetchDone += myCPU_OnFetchDone;
            myCPU.OnDecodeDone += myCPU_OnDecodeDone;
            myCPU.OnExecuteDone += myCPU_OnExecuteDone;
            myCPU.OnStoreDone += myCPU_OnStoreDone;
            myCPU.OnBranch += myCPU_OnBranch;
            myCPU.OnStageDone += myCPU_OnStageDone;
            fetchDone = false;
            decodeDone = false;
            executeDone = false;
            storeDone = false;
            programDone = false;
            
            instructionsInPipeline = new Queue<PipelineInstruction>(5);

            fillCacheIndexComboBox();

            this.zeroLabel.Text = this.myCPU.ZERO.ToString();
            this.oneLabel.Text = this.myCPU.ONE.ToString();

            //Starts with 1 way mode highlighted
            button2_Click(null, null);
            button6_Click(null, null);
            button3_Click(null, null);



#if DEBUG
            loadFileButton.Text = "Load File";
#endif
        }
Exemplo n.º 6
0
 public ExecuteEventArgs(CPU.DecodedInstruction instr)
 {
     this.CurrentInstr = instr.binary;
     this.CurrentInstructionIndex = instr.index;
 }
Exemplo n.º 7
0
        public Form1()
        {
            myCPU = new CPU();

            mainMemory = new Memory();

            InitializeComponent();
            #region GUI pretty stuff. Making transparencies
            //Making the Acc labels transparent with the picturebox background
            //Label1 = "ACC:"
  //          var pos = this.PointToScreen(label1.Location);
 //           pos = BackgroundPicBox.PointToClient(pos);
 //          label1.Parent = BackgroundPicBox;
 //           label1.Location = pos;
 //           label1.BackColor = Color.Transparent;
            //AccLabel
            var pos2 = this.PointToScreen(accLabel.Location);
            pos2 = BackgroundPicBox.PointToClient(pos2);
            accLabel.Parent = BackgroundPicBox;
            accLabel.Location = pos2;
            accLabel.BackColor = Color.Transparent;
            //"HIT!" or "MISS!" Label
            var pos3 = this.PointToScreen(MissOrHitLabel.Location);
            pos3 = BackgroundPicBox.PointToClient(pos3);
            MissOrHitLabel.Parent = BackgroundPicBox;
            MissOrHitLabel.Location = pos3;
            MissOrHitLabel.BackColor = Color.Transparent;

            //Pipeline UI
            var FetchPos = this.PointToScreen(FetchDisplayLabel.Location);
            FetchPos = BackgroundPicBox.PointToClient(FetchPos);
            FetchDisplayLabel.Parent = BackgroundPicBox;
            FetchDisplayLabel.Location = FetchPos;
            FetchDisplayLabel.BackColor = Color.Transparent;

            //Decode
            var DecodePos = this.PointToScreen(DecodeDisplayLabel.Location);
            DecodePos = BackgroundPicBox.PointToClient(DecodePos);
            DecodeDisplayLabel.Parent = BackgroundPicBox;
            DecodeDisplayLabel.Location = DecodePos;
            DecodeDisplayLabel.BackColor = Color.Transparent;

            //Execute
            var ExecutePos = this.PointToScreen(ExecuteDisplayLabel.Location);
            ExecutePos = BackgroundPicBox.PointToClient(ExecutePos);
            ExecuteDisplayLabel.Parent = BackgroundPicBox;
            ExecuteDisplayLabel.Location = ExecutePos;
            ExecuteDisplayLabel.BackColor = Color.Transparent;

            //Store
            var StorePos = this.PointToScreen(StoreDisplayLabel.Location);
            StorePos = BackgroundPicBox.PointToClient(StorePos);
            StoreDisplayLabel.Parent = BackgroundPicBox;
            StoreDisplayLabel.Location = StorePos;
            StoreDisplayLabel.BackColor = Color.Transparent;


            MaximizeBox = false;

            #endregion

        }
Exemplo n.º 8
0
 private void resetButton_Click(object sender, EventArgs e)
 {
     cpu = new CPU();
     cpu.currentInsNum = 0;
     cpu.registerPC = 0;
     updateView();
     if (cpu.memory.instructions != null)
     {
         cpu.currentIns = cpu.memory.instructions[cpu.currentInsNum];
         nxtIns = cpu.engine.binaryParse(cpu.currentIns);
         cpu.engine.LabelDic.Clear();
         cpu.memory.resetInstructions();
     }
     a = "0b 0";
     b = "0b 0";
     acc = "0b 0";
     pc = "0b 0";
     mar = "0b 0";
     mdr = "0b 0";
     temp = "0b 0";
     ir = "0b 0";
     cc = "0b 0";
 }
Exemplo n.º 9
0
 //load file button
 private void loadButton_Click(object sender, EventArgs e)
 {
     cpu = new CPU();
     OpenFileDialog ofd = new OpenFileDialog();
     if (ofd.ShowDialog() == DialogResult.OK)
     {
         cpu.engine.path = ofd.FileName;
         try
         {
             cpu.engine.Assemble(cpu.engine.path, "g.out");
             cpu.fillMem();
             for (int i = 1; i <= 3; i++)
             {
                 cpu.pushNoop();
             }
             updateNxtIns();
             updateView();
         }
         catch (SyntaxException exception)
         {
             MessageBox.Show("Syntax Error");
             resetButton_Click(null, null);
         }
         catch (SegFaultException segE)
         {
             MessageBox.Show("Memory was addressed out of bounds");
             resetButton_Click(null, null);
         }
         catch (ArgMismatchException argE)
         {
             MessageBox.Show("argument mispatch in source");
             resetButton_Click(null, null);
         }
         catch (InvalidCommandException inE)
         {
             MessageBox.Show("invalid command in source");
             resetButton_Click(null, null);
         }
         catch (InvalidArgFormattingException inAE)
         {
             MessageBox.Show("argument formatted incorrectly in source");
             resetButton_Click(null, null);
         }
         catch (InvalidLabelNameException inL)
         {
             MessageBox.Show("label not defined in source");
             resetButton_Click(null, null);
         }
     }
 }
Exemplo n.º 10
0
 public Window(CPU cpu)
 {
     InitializeComponent();
     this.cpu = cpu;
 }
Exemplo n.º 11
0
 public FetchEventArgs(CPU.FetchedInstruction instruction)
 {
     CurrentIR = instruction.binary;
     CurrentInstructionIndex = instruction.index;
 }
Exemplo n.º 12
0
 public StageDoneEventArgs(int instrIndex, CPU.StageType stageType)
 {
     //this.CurrentInstr = instr.binary;
     this.CurrentInstructionIndex = instrIndex;
     this.stageType = stageType;
 }