public bool IsAntenna(out Dictionary <string, List <XDLPip> > pipsToRemove)
        {
            pipsToRemove = new Dictionary <string, List <XDLPip> >();

            string outpinName          = NetPins.Where(np => np is NetOutpin).First().SlicePort;
            XDLPip firstPipAfterOutpin = Pips.Where(p => p.From.EndsWith(outpinName) && IdentifierManager.Instance.IsMatch(p.Location, IdentifierManager.RegexTypes.CLB)).FirstOrDefault();

            if (firstPipAfterOutpin == null)
            {
                //Console.WriteLine("Could not find the pip right after the outpin " + outpinName + " in net " + this.Name);
                return(false);
            }

            Queue <XDLPip> reachablePips = new Queue <XDLPip>();

            reachablePips.Enqueue(firstPipAfterOutpin);

            foreach (XDLPip pip in Pips.Where(p => !p.Equals(firstPipAfterOutpin)))
            {
                if (!pipsToRemove.ContainsKey(pip.Location))
                {
                    pipsToRemove.Add(pip.Location, new List <XDLPip>());
                }
                pipsToRemove[pip.Location].Add(pip);
            }

            while (reachablePips.Count > 0)
            {
                // from the current pip
                XDLPip current = reachablePips.Dequeue();
                // go to all reachable locations
                foreach (Location loc in Navigator.GetDestinations(current.Location, current.To))
                {
                    if (!pipsToRemove.ContainsKey(loc.Tile.Location))
                    {
                        continue;
                    }
                    // for readability we reference the list of pips
                    List <XDLPip> pipsToRemoveOnTile = pipsToRemove[loc.Tile.Location];
                    while (true)
                    {
                        int index = pipsToRemoveOnTile.FindIndex(pip => pip.From.Equals(loc.Pip.Name));
                        if (index == -1)
                        {
                            break;
                        }
                        XDLPip reachable = pipsToRemoveOnTile[index];
                        pipsToRemoveOnTile.RemoveAt(index);
                        reachablePips.Enqueue(reachable);
                        // remove empty lists for readability
                        if (pipsToRemoveOnTile.Count == 0)
                        {
                            pipsToRemove.Remove(loc.Tile.Location);
                        }
                    }
                }
            }
            return(pipsToRemove.Values.Any(l => l.Count > 0));
        }
 public void Add(XDLPip pip)
 {
     if (m_xdlPips == null)
     {
         m_xdlPips = new List <XDLPip>();
     }
     m_xdlPips.Add(pip);
 }
        /// <summary>
        /// Insert a pseudo pip that serves as a comment
        /// </summary>
        /// <param name="comment"></param>
        public void Add(string comment)
        {
            XDLPip commentPip = new XDLPip(!comment.StartsWith("#") ? "# " + comment : comment, "", "", "");

            if (m_xdlPips == null)
            {
                m_xdlPips = new List <XDLPip>();
            }
            m_xdlPips.Add(commentPip);
        }
        public void Add(Tile where, string from, string to)
        {
            XDLPip pip = new XDLPip(where.Location, from, "->", to);

            if (m_xdlPips == null)
            {
                m_xdlPips = new List <XDLPip>();
            }
            m_xdlPips.Add(pip);
        }
        public void Add(Tile where, Port from, Port to)
        {
            XDLPip pip = new XDLPip(where.Location, from.Name, "->", to.Name);

            if (m_xdlPips == null)
            {
                m_xdlPips = new List <XDLPip>();
            }
            m_xdlPips.Add(pip);
        }
 private void ProcessNextNetLine(char[] buffer, int size, XDLNet net)
 {
     string[] atoms = null;
     try
     {
         atoms = m_splitNetLineWhiteSpaceOnly.Split(new string(buffer, 0, size));
     }
     catch
     {
         Console.WriteLine(size);
         Console.WriteLine(buffer);
         Console.WriteLine(net);
     }
     for (int i = 0; i < atoms.Length; i++)
     {
         if (atoms[i].Equals("pip"))
         {
             string location = atoms[i + 1];
             string from     = atoms[i + 2];
             string op       = atoms[i + 3];
             string to       = atoms[i + 4].Replace(",", "");
             XDLPip pip      = new XDLPip(location, from, op, to);
             net.Add(pip);
             return;
         }
         else if (atoms[i].Equals("inpin"))
         {
             NetInpin inpin = new NetInpin();
             inpin.InstanceName = atoms[i + 1];
             inpin.SlicePort    = atoms[i + 2];
             net.Add(Trim(inpin));
             return;
         }
         else if (atoms[i].Equals("outpin"))
         {
             NetOutpin outpin = new NetOutpin();
             outpin.InstanceName = atoms[i + 1];
             outpin.SlicePort    = atoms[i + 2];
             net.Add(Trim(outpin));
             return;
         }
         else if (atoms[i].Equals("cfg"))
         {
             //net.Config = "cfg ";
             for (int j = 0; j < size; j++)
             {
                 net.Config += buffer[j];
             }
             return;
         }
     }
 }
        public XDLNet(List <Location> path)
        {
            int i     = 0;
            int limit = path.Count - 1;

            while (i < limit)
            {
                int lookAhead  = i + 1;
                int hopsInTile = 0;
                while (lookAhead < limit)
                {
                    bool locationMatch             = path[lookAhead].Tile.Location.Equals(path[i].Tile.Location);
                    bool directSwitchMatrxiConnect = path[i].Tile.SwitchMatrix.Contains(path[lookAhead - 1].Pip, path[lookAhead].Pip);

                    if (!locationMatch || !directSwitchMatrxiConnect)
                    {
                        break;
                    }
                    lookAhead++;
                    hopsInTile++;
                }

                switch (hopsInTile)
                {
                case 0:     // last arc
                case 1:
                {
                    XDLPip arc = new XDLPip(path[i].Tile.Location, path[i].Pip.Name, "->", path[i + 1].Pip.Name);
                    Add(arc);
                    i += 2;
                    break;
                }

                default:
                {
                    for (int hopIndex = 0; hopIndex < hopsInTile; hopIndex++)
                    {
                        XDLPip arc = new XDLPip(path[i].Tile.Location, path[i + hopIndex].Pip.Name, "->", path[i + hopIndex + 1].Pip.Name);
                        Add(arc);
                    }

                    if (hopsInTile > maxHops)
                    {
                        maxHops = hopsInTile;
                    }
                    i += hopsInTile + 1;
                    break;
                }
                }
            }
        }
Exemple #8
0
        public override bool Equals(object obj)
        {
            if (obj is XDLPip)
            {
                XDLPip other = (XDLPip)obj;
                if (other.FromKey != FromKey || other.ToKey != ToKey)
                {
                    return(false);
                }
                return(other.Location.Equals(Location));

                /*
                 * return
                 * other.Location.Equals(this.Location) &&
                 * other.From.Equals(this.From) &&
                 * other.To.Equals(this.To);*/
            }
            else
            {
                return(false);
            }
        }