Esempio n. 1
0
        /// <summary>
        /// copy and relocate the net
        /// </summary>
        /// <param name="other"></param>
        public static TCLNet Relocate(TCLNet other,LibraryElement libElement,Tile anchor)
        {
            TCLNet copiedNet = new TCLNet(other.Name);

            copiedNet.RoutingTree = new TCLRoutingTree(other.RoutingTree);
            foreach (TCLRoutingTreeNode node in copiedNet.RoutingTree.GetAllRoutingNodes().Where(n => n.Tile != null))
            {
                string targetLocation = "";
                bool   success        = libElement.GetTargetLocation(node.Tile.Location, anchor, out targetLocation);
                Tile   targetTile     = FPGA.FPGA.Instance.GetTile(targetLocation);
                node.Tile = targetTile;
            }


            copiedNet.m_footerComment.Append(other.FooterComment);
            copiedNet.Properties = new TCLProperties(other.Properties);

            copiedNet.m_netPins = new List <NetPin>();
            foreach (NetPin pin in other.NetPins)
            {
                NetPin copiedPin = NetPin.Copy(pin);
                copiedNet.m_netPins.Add(copiedPin);
                string targetLocation = "";
                bool   success        = libElement.GetTargetLocation(pin.TileName, anchor, out targetLocation);
                Tile   targetTile     = FPGA.FPGA.Instance.GetTile(targetLocation);
                pin.TileName = targetTile.Location;
            }
            copiedNet.IsBlockerNet = other.IsBlockerNet;
            copiedNet.NodeNet      = other.NodeNet;
            if (other.OutpinInstance != null)
            {
                copiedNet.OutpinInstance = new TCLInstance((TCLInstance)other.OutpinInstance);
            }
            return(copiedNet);
        }
Esempio n. 2
0
        /// <summary>
        /// Copy TODO use Clone
        /// </summary>
        /// <param name="other"></param>
        public static TCLNet Copy(TCLNet other)
        {
            TCLNet copy = new TCLNet(other.Name);

            copy.RoutingTree = new TCLRoutingTree(other.RoutingTree);
            copy.m_footerComment.Append(other.FooterComment);
            copy.Properties = new TCLProperties(other.Properties);

            copy.m_netPins = new List <NetPin>();
            foreach (NetPin pin in other.NetPins)
            {
                copy.m_netPins.Add(NetPin.Copy(pin));
            }
            copy.IsBlockerNet = other.IsBlockerNet;
            copy.NodeNet      = other.NodeNet;
            if (other.OutpinInstance != null)
            {
                copy.OutpinInstance = new TCLInstance((TCLInstance)other.OutpinInstance);
            }
            return(copy);
        }
        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);
            }
        }