Example #1
0
        protected bool rb_inject(Flit[] input)
        {
            bool redirection = false;
            Flit temp        = null;

            if (rbuf.isEmpty())
            {
                rb_inject_block_count = 0;
            }

            if (rb_inject_block_count > Config.redirectThreshold)
            {
                redirection = true;
            }

            if (redirection)
            {
                int rand = Simulator.rand.Next(TOTAL_DIR);

                if (input[rand] != null && !Simulator.network.golden.isGolden(input[rand]))
                {
                    temp                  = input[rand];
                    input[rand]           = null;
                    rb_inject_block_count = 0;
                }
            }

            int injectedCount = 0;

            // Resubmit Buffer Injection
            for (int i = 0; i < TOTAL_DIR; i++)
            {
                if (rbuf.isEmpty() || injectedCount == Config.rbInjectCount)
                {
                    break;
                }

                if (input[i] == null)
                {
                    input[i] = rbuf.removeFlit();
                    injectedCount++;
                    Simulator.stats.rb_injectCount.Add();
                }
            }

            if (!rbuf.isEmpty() && injectedCount == 0)
            {
                rb_inject_block_count++;
            }

            if (redirection && temp != null)
            {
                Simulator.stats.redirectedFlits.Add();
                Simulator.stats.rb_ejectCount.Add();
                rbuf.addFlit(temp);
            }
            return(redirection);
        }
Example #2
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;
                }
            }
        }
Example #3
0
        void route()
        {
            Flit[] temp = new Flit[6];
            for (int i = 0; i < 6; i++)
            {
                temp[i] = input[i];
            }

            int dir;

            if (clockwise)
            {
                dir = Simulator.DIR_CCW;
            }
            else
            {
                dir = Simulator.DIR_CW;
            }

            if (injectPlaceholder > 0)
            {
                injectPlaceholder--;
                if (temp[connectionDirection] != null)
                {
                    rBuf.addFlit(temp[connectionDirection]);
                }

                temp[connectionDirection] = null;

                int tempX = 0;
                int tempY = 0;
                switch (injectPlaceholder % 4)
                {
                case 0:
                    tempX = 4; tempY = 3; break;

                case 1:
                    tempX = 0; tempY = 0; break;

                case 2:
                    tempX = 1; tempY = 2; break;

                case 3:
                    tempX = 2; tempY = 4; break;
                }
                Coord tempCoord = new Coord(tempX, tempY);

                temp[connectionDirection]          = new Flit(new Packet(null, 1337, 1337, tempCoord, tempCoord), 1337);
                temp[connectionDirection].initPrio = -1;
                                #if INEJ
                Console.WriteLine("!!!!!!!!!! INJECTING PLACEHOLDER {0}.{1} at node {2} cyc {3} !!!!!!!!!!!", temp[connectionDirection].packet.ID, temp[connectionDirection].flitNr, ringCoord, Simulator.CurrentRound);
                                #endif

                /*injectPlaceholder--;
                 * temp[dir] = new Flit(new Packet(null, 1337, 1337, new Coord(4,4), new Coord(4,4)), 1337);
                 * temp[dir].initPrio = -1;
                 */
            }

            if (connectionDirection == dir)
            {
                throw new Exception("Connection direction should not be clockwise or counter clockwise");
            }

            // If there is something coming in, try to pull it in.
            if (temp[connectionDirection] != null)
            {
                if (isDestRing(temp[connectionDirection]))
                {
                    if (temp[dir] == null)
                    {
                                                #if INTERCONNECT
                        Console.WriteLine("|Moving Into Ring|   \t \tflit {0}.{1} at node {2} cyc {3} \t | dest: {4}", temp[connectionDirection].packet.ID, temp[connectionDirection].flitNr, ringCoord, Simulator.CurrentRound, temp[connectionDirection].packet.ringdest);
                                                #endif
                        temp[dir] = temp[connectionDirection];
                        temp[connectionDirection] = null;
                    }
                    else
                    {
                        if (isRingProductive(temp[dir], connectionDirection))
                        {
                            Flit tempFlit;
                                                        #if INTERCONNECT
                            Console.WriteLine("|Swapping outside-inside|\tflit {0}.{1} && flit {2}.{3} at node {4} cyc {5} \t \n| dest1: {6} dest2: {7}", temp[connectionDirection].packet.ID, temp[connectionDirection].flitNr, temp[dir].packet.ID, temp[dir].flitNr, ringCoord, Simulator.CurrentRound, temp[connectionDirection].packet.ringdest, temp[dir].packet.ringdest);
                                                        #endif
                            tempFlit  = temp[dir];
                            temp[dir] = temp[connectionDirection];
                            temp[connectionDirection] = tempFlit;
                            getNeighborXY(out temp[connectionDirection].tempX, out temp[connectionDirection].tempY);
                        }
                                                #if INTERCONNECT
                        else
                        {
                            Console.WriteLine("!Deflected outside ring!\tflit {0}.{1} at node{2} cyc {3} \t | dest: {4}", temp[connectionDirection].packet.ID, temp[connectionDirection].flitNr, ringCoord, Simulator.CurrentRound, temp[connectionDirection].packet.ringdest);
                            Console.WriteLine("!!!! DEFLECTED another outside ring!!!\t flit{0}.{1} at node{2} cyc {3} \t | dest: {4}\t Flit {5}.{6} dest:{7}", temp[dir].packet.ID, temp[dir].flitNr, ringCoord, Simulator.CurrentRound, temp[dir].packet.ringdest, temp[connectionDirection].packet.ID, temp[connectionDirection].flitNr, temp[connectionDirection].ringdest);
                        }
                                                #endif
                    }
                }
            }
            // Otherwise, try to push something into the connection.
            else
            {
                if (temp[dir] != null && isRingProductive(temp[dir], connectionDirection))
                {
                                        #if INTERCONNECT
                    Console.WriteLine("|Moving Out of Ring|\t \tflit {0}.{1} at node {2} cyc {3} \t | dest: {4}", temp[dir].packet.ID, temp[dir].flitNr, ringCoord, Simulator.CurrentRound, temp[dir].packet.ringdest);
                                        #endif
                    temp[connectionDirection] = temp[dir];
                    temp[dir] = null;
                    getNeighborXY(out temp[connectionDirection].tempX, out temp[connectionDirection].tempY);
                }
                                #if INTERCONNECT
                else if (temp[dir] != null)
                {
                    Console.WriteLine("!Deflected inside ring!\tflit {0}.{1} at node{2} cyc {3}\t | dest: {4}", temp[dir].packet.ID, temp[dir].flitNr, ringCoord, Simulator.CurrentRound, temp[dir].packet.ringdest);
                }
                                #endif
            }
            input[connectionDirection] = temp[connectionDirection];

            if (clockwise)
            {
                input[Simulator.DIR_CW]  = temp[Simulator.DIR_CCW];
                input[Simulator.DIR_CCW] = null;
            }
            else
            {
                input[Simulator.DIR_CCW] = temp[Simulator.DIR_CW];
                input[Simulator.DIR_CW]  = null;
            }
        }