예제 #1
0
파일: Main.cs 프로젝트: Gl237man/mineroute
        private static void AddOutCellLink(List<NetLink> Links, string ConnectionName, string CellName, string PortName)
        {
            if (ConnectionName != null)
            {
                if (IsPort(ConnectionName))
                {
                    NetLink Nl = new NetLink();
                    Nl.FromDev = CellName;
                    Nl.FromPort = PortName;
                    Nl.ToDev = ConnectionName;
                    Nl.ToPort = "I0";
                    Links.Add(Nl);
                }

                if (IsWire(ConnectionName))
                {
                    if (!WireConnectionExist(ConnectionName,CellName))
                        module.Wires[GetIdWireByName(ConnectionName)].Connections.Add(new Connection() { CPoint = CellName, Direction = direction.From });
                    NetLink Nl = new NetLink();
                    Nl.FromDev = CellName;
                    Nl.FromPort = PortName;
                    Nl.ToDev = ConnectionName;
                    Nl.ToPort = "I" + (GetWireInConnetionNum(ConnectionName) - 1).ToString();
                    Links.Add(Nl);
                }
            }
        }
예제 #2
0
파일: Main.cs 프로젝트: Gl237man/mineroute
 private static bool CheckMultiLink(NetLink netLink, List<NetLink> Links)
 {
     string srcPort = netLink.FromPort;
     string srcDev = netLink.FromDev;
     int cnt = 0;
     for (int i = 0; i < Links.Count; i++)
     {
         if (Links[i].FromDev == srcDev)
             if (Links[i].FromPort == srcPort)
             {
                 cnt++;
             }
     }
     if (cnt > 1)
         return true;
     else
         return false;
 }
예제 #3
0
파일: Main.cs 프로젝트: Gl237man/mineroute
 private static bool WireOptimize(List<NetLink> Links)
 {
     for (int i = 0; i < module.Wires.Count; i++)
     {
         int InPortNum = GetWireInConnetionNum(module.Wires[i].Name);
         int OutPortNum = GetWireOutConnetionNum(module.Wires[i].Name);
         if (InPortNum == 1 && OutPortNum == 1)
         {
             NetLink NNL= new NetLink();
             for (int j = 0; j < Links.Count; j++)
             {
                 if (Links[j].ToDev == module.Wires[i].Name)
                 {
                     NNL.FromDev = Links[j].FromDev;
                     NNL.FromPort = Links[j].FromPort;
                     Links.RemoveAt(j);
                 }
             }
             for (int j = 0; j < Links.Count; j++)
             {
                 if (Links[j].FromDev == module.Wires[i].Name)
                 {
                     NNL.ToDev = Links[j].ToDev;
                     NNL.ToPort = Links[j].ToPort;
                     Links.RemoveAt(j);
                 }
             }
             Links.Add(NNL);
         }
         if ((InPortNum + OutPortNum) < 3)
         {
             module.Wires.RemoveAt(i);
             return true;
         }
     }
     return false;
 }
예제 #4
0
파일: Main.cs 프로젝트: Gl237man/mineroute
        private static void MakeDup(NetLink netLink, List<NetLink> Links, List<Node> Nodes)
        {
            string srcPort = netLink.FromPort;
            string srcDev = netLink.FromDev;
            List<NetLink> DestLinksPorts = new List<NetLink>();

            for (int i = 0; i < Links.Count; i++)
            {
                if (Links[i].FromDev == srcDev)
                    if (Links[i].FromPort == srcPort)
                    {
                        DestLinksPorts.Add(Links[i]);
                    }
            }
            Nodes.Add(new Node
            {
                NodeName = "RecoveredDUP" + GlobalDup
            ,
                NodeType = "DUP" + DestLinksPorts.Count
            });

            for (int i = 0; i < DestLinksPorts.Count; i++)
            {
                DestLinksPorts[i].FromDev = "RecoveredDUP" + GlobalDup;
                DestLinksPorts[i].FromPort = "O" + i;
            }
            Links.Add(new NetLink
            {
                ToDev = "RecoveredDUP" + GlobalDup,
                ToPort = "I0",
                FromDev = srcDev,
                FromPort = srcPort
            });
        }
예제 #5
0
파일: Main.cs 프로젝트: Gl237man/mineroute
        static void Main(string[] args)
        {
            string InFile = "test";
            if (args.Length == 1)
            {
                InFile = args[0];
            }
            module = new Module();
            string InFileName = InFile + ".vqm";
            string[] InFileData = System.IO.File.ReadAllLines(InFileName);
            string[] CleanStrings = ClearData(InFileData);
            for (int i = 0; i < CleanStrings.Length; i++)
            {
                ProccessString(CleanStrings[i]);
            }
            List<Node> Nodes = new List<Node>();
            List<NetLink> Links = new List<NetLink>();
            //Заполнение констант
            FillConst(Nodes);
            //Заполнение портов
            FillPorts(Nodes);
            //Заполнение ячеек
            FillCells(Nodes);
            //Заполнение DupСоеденений
            //FillDup(Nodes);
            //Заполнение Соеденений
            FillLinkCell(Links);
            FillLinkPorts(Links);
            //Удаление пустых и односложных Wire
            while (WireOptimize(Links)) { }

            FillDup(Nodes);
            FillLostDupLinks(Links);
            //Пересздание DUP

            var newLinks = new List<NetLink>();
            var newNodes = new List<Node>();
            foreach (var link in Links)
            {
                var mlinks = Links.Where(t => t.FromDev == link.FromDev && t.FromPort == link.FromPort).ToList();
                if (mlinks.Count > 1)
                {
                    var newDup = new Node { NodeName = "RDUP_" + GlobalDup, NodeType = "DUP" + mlinks.Count };
                    GlobalDup++;
                    var newLink = new NetLink { FromDev = link.FromDev, FromPort = link.FromPort ,ToDev = newDup.NodeName,ToPort = "I0"};
                    newNodes.Add(newDup);
                    newLinks.Add(newLink);
                    int p = 0;
                    foreach (var llink in mlinks)
                    {
                        llink.FromDev = newDup.NodeName;
                        llink.FromPort = "O" + p;
                        p++;
                    }
                }
            }
            Nodes.AddRange(newNodes);
            Links.AddRange(newLinks);

            //ConvertLostLink2Dup(Nodes, Links);
            //Выгрузка

            Console.WriteLine("Nodes {0}",Nodes.Count);
            Console.WriteLine("Cells {0}",module.Cells.Count);
            Console.WriteLine("Wires {0}",Links.Count);

            string OutFileName = InFile + ".MNET";
            string Ofile = "";

            for (int i = 0; i < Nodes.Count; i++)
            {
                Ofile += "NODE:" + Nodes[i].NodeType + ":" + Nodes[i].NodeName + "\r\n";
            }

            for (int i = 0; i < Links.Count; i++)
            {
                Ofile += "WIRE:" + Links[i].FromDev + "-" + Links[i].FromPort + ":" + Links[i].ToDev + "-" + Links[i].ToPort + "\r\n";
            }
            System.IO.File.WriteAllText(OutFileName, Ofile);
        }
예제 #6
0
파일: Main.cs 프로젝트: Gl237man/mineroute
        //Проверка на входящие линки на ветвитель
        //Хак для обхода модулей синхронизации
        private static void FillLostDupLinks(List<NetLink> Links)
        {
            for (int i = 0; i < module.Wires.Count; i++)
            {
                string LinkName = "";
                for (int j=0;j<module.Wires[i].Connections.Count;j++)
                {
                    if (module.Wires[i].Connections[j].Direction == direction.From)
                    {
                        LinkName = module.Wires[i].Connections[j].CPoint;
                    }
                }

                if (!CheckToDupLink(LinkName, Links, module.Wires[i].Name))
                {
                    NetLink Nl = new NetLink();
                    Nl.FromDev = LinkName;
                    Nl.FromPort = "O0";
                    Nl.ToDev = module.Wires[i].Name;
                    Nl.ToPort = "I0";
                    Links.Add(Nl);
                }
            }
        }
예제 #7
0
파일: Main.cs 프로젝트: Gl237man/mineroute
 private static void FillLinkPorts(List<NetLink> Links)
 {
     for (int i = 0; i < module.Ports.Count; i++)
     {
         string ConnectionName = module.Ports[i].Connection;
         string CellName = module.Ports[i].Name;
         PortType Ptype = module.Ports[i].Ptype;
         if (ConnectionName != null)
         {
             if (IsWire(ConnectionName))
             {
                 NetLink Nl = new NetLink();
                 switch (Ptype)
                 {
                     case PortType.IN:
                         if (!WireConnectionExist(ConnectionName, CellName))
                             module.Wires[GetIdWireByName(ConnectionName)].Connections.Add(new Connection() { CPoint = CellName, Direction = direction.From });
                         Nl.FromDev = CellName;
                         Nl.FromPort = "O0";
                         Nl.ToDev = ConnectionName;
                         Nl.ToPort = "I" + (GetWireConnetionNum(ConnectionName, CellName)).ToString();
                         Links.Add(Nl);
                         break;
                     case PortType.OUT:
                         if (!WireConnectionExist(ConnectionName, CellName))
                             module.Wires[GetIdWireByName(ConnectionName)].Connections.Add(new Connection() { CPoint = CellName, Direction = direction.To });
                         Nl.FromDev = ConnectionName;
                         Nl.FromPort = "O" + (GetWireConnetionNum(ConnectionName, CellName)).ToString();
                         Nl.ToDev = CellName;
                         Nl.ToPort = "I0";
                         Links.Add(Nl);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
 }