Пример #1
0
        protected override void DoCommandAction()
        {
            FPGA.FPGATypes.AssertBackendType(FPGA.FPGATypes.BackendType.ISE);

            NetlistContainer netlistContainer = GetNetlistContainer();

            Regex sourceNetFilter = new Regex(SourceNetsRegexp, RegexOptions.Compiled);
            Regex targetNetFilter = new Regex(TargetNetsRegexp, RegexOptions.Compiled);
            Regex pipFilter       = new Regex(PipFilter, RegexOptions.Compiled);

            XDLNet targetNet = (XDLNet)netlistContainer.Nets.FirstOrDefault(n => targetNetFilter.IsMatch(n.Name));

            if (targetNet == null)
            {
                throw new ArgumentException("Could not find a target net");
            }

            foreach (XDLNet sourceNet in netlistContainer.Nets.Where(n => sourceNetFilter.IsMatch(n.Name)))
            {
                foreach (XDLPip pip in sourceNet.Pips.Where(p => pipFilter.IsMatch(p.Location)))
                {
                    XDLPip copy = new XDLPip(pip.Location, pip.From, pip.Operator, pip.To);
                    targetNet.Add(copy);
                }
            }
        }
 private bool PipFilter(XDLPip pip, Dictionary <string, List <XDLPip> > pipsToRemove)
 {
     if (!pipsToRemove.ContainsKey(pip.Location))
     {
         return(false);
     }
     return(pipsToRemove[pip.Location].Contains(pip));
 }
Пример #3
0
        protected override void DoCommandAction()
        {
            NetlistContainer m = GetNetlistContainer();

            // build mapping: Location -> XDLNet
            Dictionary <string, Dictionary <string, XDLNet> > netConflicts = new Dictionary <string, Dictionary <string, XDLNet> >();
            Dictionary <string, Dictionary <string, XDLPip> > pipConflicts = new Dictionary <string, Dictionary <string, XDLPip> >();

            foreach (XDLNet n in m.Nets)
            {
                foreach (XDLPip pip in n.Pips)
                {
                    if (!pip.Operator.Equals("->"))
                    {
                        continue;
                    }

                    if (!netConflicts.ContainsKey(pip.Location))
                    {
                        netConflicts.Add(pip.Location, new Dictionary <string, XDLNet>());
                        pipConflicts.Add(pip.Location, new Dictionary <string, XDLPip>());
                    }

                    // to
                    if (!netConflicts[pip.Location].ContainsKey(pip.To))
                    {
                        netConflicts[pip.Location].Add(pip.To, n);
                        pipConflicts[pip.Location].Add(pip.To, pip);
                    }
                    else
                    {
                        XDLNet conflictingNet = netConflicts[pip.Location][pip.To];
                        XDLPip conflictingPip = pipConflicts[pip.Location][pip.To];

                        string conflict = " in " + pip.ToString() + " and " + conflictingPip;
                        if (n.Name.Equals(conflictingNet.Name))
                        {
                            OutputManager.WriteOutput("Detected driver conflift in net " + n.Name + conflict);
                        }
                        else
                        {
                            OutputManager.WriteOutput("Detected driver conflift between nets " + n.Name + " and " + netConflicts[pip.Location][pip.To].Name + conflict);
                        }
                    }
                }
            }
        }
        private void RelocateNetsForXDL(LibraryElement libElement, Tile anchorCLB, XDLContainer netlistContainer)
        {
            foreach (XDLNet net in libElement.Containter.Nets)
            {
                // insert instance prefix
                XDLNet relocatedNet = new XDLNet(InstanceName + net.Name);
                relocatedNet.HeaderExtension = net.HeaderExtension;

                foreach (NetPin pin in net.NetPins)
                {
                    NetPin copy = NetPin.Copy(pin);
                    if (InsertPrefix)
                    {
                        // insert instance prefix
                        // remove greedy between double quotes
                        string oldInstanceName = pin.InstanceName;
                        string newInstanceName = "\"" + InstanceName + Regex.Replace(oldInstanceName, "\"", "") + "\"";
                        //xdlCode = Regex.Replace(xdlCode, oldInstanceName, newInstanceName);
                        copy.InstanceName = newInstanceName;
                        copy.InstanceName = copy.InstanceName.Replace("\"", "");
                    }
                    relocatedNet.Add(copy);
                }

                //foreach (NetSegment seg in originalNet.GetAllSegments())
                foreach (XDLPip pip in net.Pips)
                {
                    string targetLocation;
                    bool   success = libElement.GetTargetLocation(pip.Location, anchorCLB, out targetLocation);

                    Tile targetTile = null;
                    if (FPGA.FPGA.Instance.Contains(targetLocation))
                    {
                        targetTile = FPGA.FPGA.Instance.GetTile(targetLocation);
                    }
                    else
                    {
                        throw new ArgumentException("Error during relocation of pip " + pip + " to " + targetLocation);
                    }

                    XDLPip relocatedSegment = null;
                    if (targetTile.SwitchMatrix.Contains(pip.From, pip.To))
                    {
                        // we do not need to transform identifiers
                        relocatedSegment = new XDLPip(targetTile.Location, pip.From, pip.Operator, pip.To);
                    }
                    else
                    {
                        // naming fun
                        relocatedSegment = FPGATypes.RelocatePip(targetTile, pip, relocatedNet);
                    }

                    if (relocatedSegment == null)
                    {
                        throw new ArgumentException("Could not relocate " + pip.ToString() + " to tile " + targetLocation);
                    }

                    if (!targetTile.SwitchMatrix.Contains(relocatedSegment.From, relocatedSegment.To))
                    {
                        throw new ArgumentException("Could not relocate " + pip.ToString() + " to tile " + targetLocation);
                    }

                    relocatedNet.Add(relocatedSegment);
                }

                if (netlistContainer.Nets.Any(n => n.Name.Equals(relocatedNet.Name)))
                {
                    throw new ArgumentException("A net named " + relocatedNet.Name + " is alredy inserted to netlist " + netlistContainer.Name + ". Did you try to join two instances of the same macro in one?");
                }

                netlistContainer.Add(relocatedNet);
            }
        }
Пример #5
0
 private bool Remove(XDLPip pip)
 {
     return(TileSelectionManager.Instance.IsSelected(FPGA.FPGA.Instance.GetTile(pip.Location).TileKey));
 }
Пример #6
0
        public static XDLPip RelocatePip(Tile targetLocation, XDLPip pip, XDLNet targetNet)
        {
            if (!IdentifierManager.Instance.IsMatch(targetLocation.Location, IdentifierManager.RegexTypes.CLB))
            {
                throw new ArgumentException("Expecting CLB");
            }

            Tile referenceTile = FPGA.Instance.GetAllTiles().First(t => t.SwitchMatrix.Contains(pip.From, pip.To));

            if (referenceTile == null)
            {
                throw new ArgumentException("Could not relocate " + pip.ToString() + " to tile " + targetLocation.Location);
            }

            int fromSliceIndex = -1;
            int toSliceIndex   = -1;

            foreach (Slice s in referenceTile.Slices)
            {
                if (s.PortMapping.Contains(new Port(pip.From)))
                {
                    fromSliceIndex = referenceTile.GetSliceNumberByName(s.SliceName);
                }
                if (s.PortMapping.Contains(new Port(pip.To)))
                {
                    toSliceIndex = referenceTile.GetSliceNumberByName(s.SliceName);
                }
            }

            if (fromSliceIndex != toSliceIndex)
            {
            }

            Tuple <Port, Port> drivingArc = null;

            // route into slice
            if (fromSliceIndex == -1 && toSliceIndex != -1)
            {
                int    lastUnderscore = pip.To.LastIndexOf("_");
                string suffix         = pip.To.Substring(lastUnderscore, pip.To.Length - lastUnderscore);

                Port sliceInPort = targetLocation.Slices[toSliceIndex].PortMapping.Ports.FirstOrDefault(p => p.Name.EndsWith(suffix));
                drivingArc = targetLocation.SwitchMatrix.GetAllArcs().FirstOrDefault(t => t.Item2.Name.Equals(sliceInPort.Name));
            }
            else if (fromSliceIndex != -1 && toSliceIndex == -1)
            {
                int    lastUnderscore = pip.From.LastIndexOf("_");
                string suffix         = pip.From.Substring(lastUnderscore, pip.From.Length - lastUnderscore);

                Port sliceOutPort = targetLocation.Slices[fromSliceIndex].PortMapping.Ports.FirstOrDefault(p => p.Name.EndsWith(suffix));
                // IsSlicePort: toSliceIndex is not found in slice, prevent using arcs that route in SLICE, i.e., prevent that CLBLL_L_AA -> IMUX get mapped to CLBLL_L_AA -> AMUX
                foreach (Tuple <Port, Port> candicate in targetLocation.SwitchMatrix.GetAllArcs().Where(t => t.Item1.Name.Equals(sliceOutPort.Name)))
                {
                    string prefix = candicate.Item2.Name.Contains(" ") ? candicate.Item2.Name.Substring(0, candicate.Item2.Name.IndexOf(" ")) : candicate.Item2.Name;
                    if (!targetLocation.IsSlicePort(prefix))
                    {
                        drivingArc = candicate;
                        break;
                    }
                }

                //drivingArc = targetLocation.SwitchMatrix.GetAllArcs().FirstOrDefault(t => t.Item1.Name.Equals(sliceOutPort.Name) && !referenceTile.IsSlicePort(t.Item2.Name));
            }
            else if (fromSliceIndex != -1 && toSliceIndex != -1)
            {
                int    lastUnderscoreTo = pip.To.LastIndexOf("_");
                string toSuffix         = pip.To.Substring(lastUnderscoreTo, pip.To.Length - lastUnderscoreTo);
                Port   toPort           = targetLocation.Slices[toSliceIndex].PortMapping.Ports.FirstOrDefault(p => p.Name.EndsWith(toSuffix));

                int    lastUnderscoreFrom = pip.From.LastIndexOf("_");
                string fromSuffix         = pip.From.Substring(lastUnderscoreFrom, pip.From.Length - lastUnderscoreFrom);
                Port   fromPort           = targetLocation.Slices[fromSliceIndex].PortMapping.Ports.FirstOrDefault(p => p.Name.EndsWith(fromSuffix));

                drivingArc = targetLocation.SwitchMatrix.GetAllArcs().FirstOrDefault(t => t.Item1.Name.Equals(fromPort.Name) && t.Item2.Name.StartsWith(toPort.Name));
            }
            else
            {
                throw new ArgumentException("Could not relocate " + pip.ToString() + " to tile " + targetLocation.Location);
            }

            // cut of routethrough
            string relocatedToPortName = drivingArc.Item2.Name;

            if (relocatedToPortName.Contains(" "))
            {
                relocatedToPortName = relocatedToPortName.Substring(0, relocatedToPortName.IndexOf(" "));
            }
            XDLPip result = new XDLPip(targetLocation.Location, drivingArc.Item1.Name, pip.Operator, relocatedToPortName);

            return(result);

            /*
             * int indexOfFirstUnderScore = pip.From.IndexOf("_");
             * String fromSuffix = pip.From.Substring(indexOfFirstUnderScore, pip.From.Length - indexOfFirstUnderScore);
             *
             * indexOfFirstUnderScore = pip.To.LastIndexOf("_");
             * String toSuffix = pip.To.Substring(indexOfFirstUnderScore, pip.To.Length - indexOfFirstUnderScore);
             *
             * int tries = 0;
             * while (tries < 10)
             * {
             *  foreach (Port from in targetLocation.SwitchMatrix.Ports.Where(p => p.Name.EndsWith(fromSuffix) && targetLocation.GetSliceNumberByPortName(p) == fromSliceIndex))
             *  {
             *      foreach (Port p in targetLocation.SwitchMatrix.GetDrivenPorts(from).Where(p => targetLocation.GetSliceNumberByPortName(p) == toSliceIndex))
             *      {
             *          String portNameWithoutRouteThrough = p.Name;
             *          if (p.Name.Contains(" "))
             *          {
             *              portNameWithoutRouteThrough = p.Name.Substring(0, p.Name.IndexOf(" "));
             *          }
             *          if (portNameWithoutRouteThrough.EndsWith(toSuffix))
             *          {
             *              if (targetLocation.SwitchMatrix.Contains(from.Name, p.Name))
             *              {
             *                  XDLPip result = new XDLPip(targetLocation.Location, from.Name, pip.Operator, portNameWithoutRouteThrough);
             *                  return result;
             *              }
             *          }
             *      }
             *  }
             *  if (fromSuffix.Length > 1)
             *  {
             *      fromSuffix = fromSuffix.Substring(1, fromSuffix.Length - 1);
             *  }
             *  tries++;
             * }
             */
            throw new ArgumentException("Could not relocate " + pip.ToString() + " to tile " + targetLocation.Location);
        }