示例#1
0
        public void sortDeflected(int[] deflected)
        {
            int [] newDeflected = new int[4];
            newDeflected[0] = newDeflected[1] = newDeflected[2] = newDeflected[3] = -1;
            for (int i = 0; i < 4; i++)
            {
                if (deflected[i] == -1)
                {
                    break;
                }
                else
                {
                    newDeflected[3] = deflected[i];
                    for (int j = 3; j > 0; j--)
                    {
                        bool swap = false;
                        if (newDeflected[j - 1] == -1)
                        {
                            swap = true;
                        }
                        else
                        {
                            Flit f1 = input[newDeflected[j - 1]];
                            Flit f2 = input[newDeflected[j]];
                            if (0 < deflPriority(f1, f2))
                            {
                                swap = true;
                            }
                        }
                        if (swap)
                        {
                            int temp = newDeflected[j - 1];
                            newDeflected[j - 1] = newDeflected[j];
                            newDeflected[j]     = temp;
                        }
                    }
                }
            }

            for (int i = 0; i < Config.rebufRemovalCount; i++)
            {
                int index = newDeflected[i];
                if (index == -1 || input[index] == null)
                {
                    break;
                }

                if (!rBuf.isFull())
                {
                    rBuf.addFlit(input[index]);
                    input[index] = null;
                }
            }
        }
示例#2
0
文件: RouterSort.cs 项目: hirous/test
        protected void rb_eject(Flit[] input, bool redirection)
        {
            int[] index = new int[TOTAL_DIR];
            int   j     = 0;

            for (int i = 0; i < TOTAL_DIR; i++)
            {
                if (input[i] != null && input[i].prefDir != i)
                {
                    input[i].wasDeflected = true;
                    if (redirection)
                    {
                        Simulator.stats.rb_isRedirection.Add();
                        continue;
                    }

                    if (Simulator.network.golden.isGolden(input[i]))
                    {
                        continue;
                    }

                    if (input[i].currentX == input[i].dest.x && input[i].currentY == input[i].dest.y)
                    {
                        continue;
                    }

                    index[j] = i;
                    j++;
                }
            }

            if (!Config.resubmitBuffer || j == 0 || redirection)
            {
                return;
            }

            int rand = Simulator.rand.Next(j);

            if (!rbuf.isFull())
            {
                Simulator.stats.resubmittedFlits.Add();
                rbuf.addFlit(input[index[rand]]);
                input[index[rand]] = null;
                //input[index[rand]].rb_inTime = Simulator.currentCycle
            }
        }