Ejemplo n.º 1
0
        private void OnBranchCreated(object sender, BranchEventArgs e)
        {
            var branch = e.Object;

            if (_predicate == null || _predicate(branch))
            {
                var item = new BranchListItem(branch);
                item.Activated += OnItemActivated;
                CustomListBoxItemsCollection host;
                if (_groupItems)
                {
                    host = Heads.Items;
                }
                else
                {
                    host = _itemHost;
                }
                host.AddSafe(item);
            }
        }
Ejemplo n.º 2
0
 private void OnBranchCreated(object sender, BranchEventArgs e)
 {
     var branch = e.Object;
     if(_predicate == null || _predicate(branch))
     {
         var item = new BranchListItem(branch);
         item.Activated += OnItemActivated;
         CustomListBoxItemsCollection host;
         if(_groupItems)
         {
             host = _refsHeads.Items;
         }
         else
         {
             host = _itemHost;
         }
         host.AddSafe(item);
     }
 }
Ejemplo n.º 3
0
        void myCPU_OnBranch(object sender, BranchEventArgs args)
        {
            MethodInvoker method = delegate
            {
                if (args.taken)
                {
                    Console.WriteLine("Branch taken in GUI " + this.myCPU.ACC);

                    /*What this code does is goes through the instructions in the pipeline,
                     * and removes the ones that were being worked on prior to the branch being
                     * taken
                     * NOTE: probably will have to add an if statement to check for branch prediction*/

                    int count = 0;
                    Console.WriteLine("Queue contents before:");
                    foreach (var instr in instructionsInPipeline)
                    {
                        Console.WriteLine(count + ") " + instr.instructionText + ", stage is " + instr.stage);
                        count++;
                    }

                    PipelineInstruction[] temp = new PipelineInstruction[instructionsInPipeline.Count()];
                    instructionsInPipeline.CopyTo(temp, 0);
                    instructionsInPipeline.Clear();
                    int takenBranchIndex = args.CurrentInstrIndex;
                    Console.WriteLine("Taken branch index is " + takenBranchIndex);
                    for (int i = 0; i < temp.Count(); i++)
                    {
                        //if the index is larger than the branch that was taken, it needs to be flushed out
                        if ((temp[i]).instructionIndex < takenBranchIndex)
                        {
                            instructionsInPipeline.Enqueue(temp[i]);
                        }
                        else if (temp[i].instructionIndex == takenBranchIndex)
                        {
                            temp[i].stage++;//this is to correct for the special branch case
                            instructionsInPipeline.Enqueue(temp[i]);
                        }
                    }

                    count = 0;
                    Console.WriteLine("Queue contents after:");
                    foreach (var instr in instructionsInPipeline)
                    {
                        Console.WriteLine(count + ") " + instr.instructionText + ", stage is " + instr.stage);
                        count++;
                    }
                    //this.setPipelineValuesToView();
                }

                foreach (var branch in bhtBranches)
                {
                    String currBranchName = Memory.getAssemblyInstructions().ElementAt(args.CurrentInstrIndex);
                    if (currBranchName.CompareTo(branch.instrLabel) == 0)
                    {
                        if (args.taken)
                        {
                            branch.takenCount++;
                        }
                        else
                        {
                            branch.notTakenCount++;
                        }
                    }
                }
                //updateGUI();
            };

            if (this.InvokeRequired)
            {
                this.Invoke(method);
            }
            else
            {
                method.Invoke();
            }
        }