Пример #1
0
        protected override void DoCommandAction()
        {
            FileStream fs = File.OpenRead(OverlayScript);

            byte[] byteBuffer = new byte[fs.Length];
            int    length     = Convert.ToInt32(fs.Length);

            fs.Read(byteBuffer, 0, length);
            fs.Close();

            CommandExecuter.Instance.MuteCommandTrace = true;

            CommandStringParser parser = new CommandStringParser(byteBuffer, length);

            TextWriter sl    = new StreamWriter(SearchLoad, false);
            TextWriter fence = new StreamWriter(Fence, false);

            foreach (string cmdString in parser.Parse())
            {
                Command resolvedCommand = null;
                string  errorDescr;

                bool valid = parser.ParseCommand(cmdString, true, out resolvedCommand, out errorDescr);

                if (resolvedCommand is Set)
                {
                    CommandExecuter.Instance.Execute(resolvedCommand);

                    Set    setCmd = (Set)resolvedCommand;
                    string value  = setCmd.Value;
                    if (Objects.IdentifierManager.Instance.IsMatch(value, Objects.IdentifierManager.RegexTypes.CLB))
                    {
                        AddToSelectionLoc addCmd = new AddToSelectionLoc();
                        addCmd.Location = value;
                        fence.WriteLine(addCmd.ToString());
                    }
                }
                else if (resolvedCommand is PathSearchOnFPGA)
                {
                    CommandExecuter.Instance.MuteCommandTrace = false;
                    PathSearchOnFPGA searchCmd = (PathSearchOnFPGA)resolvedCommand;
                    //String from
                    //this.OutputManager.WriteOutput(searchCmd.StartLocation + "." + searchCmd.StartPort + "-" + searchCmd.TargetLocation + "." + searchCmd.TargetPort);
                    sl.WriteLine(searchCmd.StartLocation + "." + searchCmd.StartPort + "-" + searchCmd.TargetLocation + "." + searchCmd.TargetPort);
                }
                else
                {
                }
            }

            sl.Close();
            fence.Close();
        }
        private void ReadSearchInput(out Queue <Tuple <Location, Location> > fromToTuples)
        {
            fromToTuples = new Queue <Tuple <Location, Location> >();

            TextReader tr = new StreamReader(InputFile);
            string     l  = "";

            while ((l = tr.ReadLine()) != null)
            {
                string[] tuples = l.Split('-');
                if (tuples.Length != 2)
                {
                    Console.WriteLine("Skipping " + l);
                    continue;
                }

                string[] left  = tuples[0].Split('.');
                string[] right = tuples[1].Split('.');

                if (left.Length != 2 || right.Length != 2)
                {
                    Console.WriteLine("Skipping " + l);
                    continue;
                }

                Tile sourceTile = FPGA.FPGA.Instance.GetTile(left[0]);
                Tile sinkTile   = FPGA.FPGA.Instance.GetTile(right[0]);

                Location source = new Location(sourceTile, new Port(left[1]));
                Location sink   = new Location(sinkTile, new Port(right[1]));

                if (source.Tile.Location.Equals("CLEXL_X4Y10"))
                {
                    continue;
                }

                PathSearchOnFPGA.CheckExistence(source);
                PathSearchOnFPGA.CheckExistence(sink);

                fromToTuples.Enqueue(new Tuple <Location, Location>(source, sink));
            }
            tr.Close();
        }
        protected override void DoCommandAction()
        {
            if (this.StartLocations.Count != this.SinkLocations.Count)
            {
                throw new ArgumentException("Number of sinks and source must match");
            }
            List<Location> sources = this.GetLocations(this.StartLocations);
            List<Location> sinks = this.GetLocations(this.SinkLocations);

            // result
            List<List<Location>> paths = new List<List<Location>>();

            Dictionary<Location, PathUsage> pipUsage = new Dictionary<Location, PathUsage>();

            for (int i = 0; i < sources.Count; i++)
            {
                Location source = sources[i];
                Location sink = sinks[i];
                PathSearchOnFPGA.CheckLocationsForExistence(source, sink);

                RouteNet routeCmd = new RouteNet();
                foreach (List<Location> path in routeCmd.Route("BFS", true, Enumerable.Repeat(source, 1), sink, 100, this.MaxDepth, true))
                {
                    if (!PathSearchOnFPGA.PathAlreadyFound(path, paths))
                    {
                        paths.Add(path);

                        // attach
                        PathUsage usage = new PathUsage(source, sink);

                        foreach (Location l in path)
                        {
                            if(
                        }
                    }
                }

            }
        }
        protected override void DoCommandAction()
        {
            // read input
            Queue <Tuple <Location, Location> > fromToTuples = null;

            ReadSearchInput(out fromToTuples);

            // result
            List <List <Location> > paths = new List <List <Location> >();
            List <XDLNet>           nets  = new List <XDLNet>();

            RouteNet routeCmd = new RouteNet();

            routeCmd.Watch = Watch;

            int size  = fromToTuples.Count;
            int count = 0;

            UsageManager usageManager = new UsageManager();

            // upon sink chnmage, block the last nets
            Location lastSink = null;

            while (fromToTuples.Count > 0)
            {
                ProgressInfo.Progress = ProgressStart + (int)((double)count++ / (double)size * ProgressShare);

                Tuple <Location, Location> tuple = fromToTuples.Dequeue();
                Location source = tuple.Item1;
                Location sink   = tuple.Item2;

                bool pathFound = false;

                bool sinkChange = lastSink == null ? false : !lastSink.Equals(sink);
                lastSink = sink;
                if (sinkChange)
                {
                    BlockPips(nets);
                }
                Usage usage = new Usage(source, sink);

                //if (source.Tile.Location.Equals("CLEXL_X22Y16") && source.Pip.Name.Equals("XX_AQ") && sink.Tile.Location.Equals("CLEXM_X23Y18") && sink.Pip.Name.Equals("X_AX"))
                if (source.Tile.Location.Equals("CLEXL_X22Y16") && source.Pip.Name.Equals("XX_AQ") && sink.Tile.Location.Equals("CLEXM_X23Y16") && sink.Pip.Name.Equals("X_AX"))
                {
                }

                List <Location> initialSearchFront = new List <Location>();
                foreach (Location location in usageManager.GetLocationsWithExclusiveUsage(usage).OrderBy(l => Distance(l, sink)))
                {
                    initialSearchFront.Add(location);
                }
                // add default source after the others
                initialSearchFront.Add(source);

                // truncate on first run
                TextWriter tw = new StreamWriter(OutputFile, count > 1);
                tw.Write(PathSearchOnFPGA.GetBanner(source, sink));



                //Console.WriteLine("Running path " + count + " " + usage + (initialSearchFront.Count > 1 ? " with shortcut" : ""));

                if (initialSearchFront.Count > 1)
                {
                }

                Watch.Start("search");
                foreach (List <Location> path in routeCmd.Route("BFS", true, initialSearchFront, sink, 100, MaxDepth, false))
                {
                    if (!PathSearchOnFPGA.PathAlreadyFound(path, paths))
                    {
                        paths.Add(path);

                        XDLNet n = PathToNet(source, sink, path);
                        nets.Add(n);
                        usage.Net = n;

                        tw.Write(PathSearchOnFPGA.PathToString(source, sink, Enumerable.Repeat(path, 1)));
                        pathFound = true;

                        // no blocking on CLEX LOGIC
                        foreach (XDLPip pip in GetPipsToBlock(n))
                        {
                            Location l = new Location(FPGA.FPGA.Instance.GetTile(pip.Location), new Port(pip.From));
                            //Location r = new Location(FPGA.FPGA.Instance.GetTile(pip.Location), new Port(pip.To));
                            usageManager.Add(l, usage, n);
                            //usageManager.Add(r, usage);
                        }
                        break;
                    }
                }
                Watch.Stop("search");

                if (!pathFound)
                {
                    tw.WriteLine("No path found");
                    string trigger = ("if (source.Tile.Location.Equals(\"" + source.Tile.Location + "\") && source.Pip.Name.Equals(\"" + source.Pip.Name + "\") && sink.Tile.Location.Equals(\"" + sink.Tile.Location + "\") && sink.Pip.Name.Equals(\"" + sink.Pip.Name + "\"))");
                    Console.WriteLine(trigger);
                }

                tw.Close();

                if (nets.Count % 20 == 0)
                {
                    //    Console.WriteLine(this.Watch.GetResults());
                }
            }
        }
        protected override void DoCommandAction()
        {
            Tile startTile  = FPGA.FPGA.Instance.GetTile(StartLocation);
            Tile targetTile = FPGA.FPGA.Instance.GetTile(TargetLocation);

            List <List <Location> > m_paths = new List <List <Location> >();

            string startPortRegexp = "";

            foreach (string s in StartPortRegexps)
            {
                startPortRegexp += "(" + s + ")|";
            }
            startPortRegexp = startPortRegexp.Remove(startPortRegexp.Length - 1);

            foreach (Port startPort in startTile.SwitchMatrix.GetAllDrivers().Where(p => Regex.IsMatch(p.Name, startPortRegexp)).OrderBy(p => p.Name))
            {
                foreach (Port targetPort in targetTile.SwitchMatrix.GetDrivenPorts().Where(p => Regex.IsMatch(p.Name, TargetPortRegexp)).OrderBy(p => p.Name))
                {
                    PathSearchOnFPGA searchCmd = new PathSearchOnFPGA();
                    searchCmd.Forward        = true;
                    searchCmd.MaxDepth       = MaxDepth;
                    searchCmd.MaxSolutions   = 1;
                    searchCmd.SearchMode     = "BFS";
                    searchCmd.StartLocation  = startTile.Location;
                    searchCmd.StartPort      = startPort.Name;
                    searchCmd.TargetLocation = targetTile.Location;
                    searchCmd.TargetPort     = targetPort.Name;
                    searchCmd.PrintBanner    = false;
                    CommandExecuter.Instance.Execute(searchCmd);
                    m_paths.AddRange(searchCmd.m_paths);
                    // copy output
                    if (searchCmd.OutputManager.HasOutput)
                    {
                        OutputManager.WriteWrapperOutput(searchCmd.OutputManager.GetOutput());
                    }
                }
                // one blank for readability
                OutputManager.WriteWrapperOutput("");
            }

            return;

            List <Tuple <Tuple <Location, Location>, List <Location> > > solutionSet = new List <Tuple <Tuple <Location, Location>, List <Location> > >();

            foreach (List <Location> p in m_paths)
            {
                solutionSet.Add(new Tuple <Tuple <Location, Location>, List <Location> >(new Tuple <Location, Location>(p[0], p[p.Count - 1]), p));
                //solutionSet.Add(new Tuple<Location, Location>(p[0], p[p.Count - 1]), p);
            }


            List <Tuple <Tuple <Location, Location>, List <Location> > > west = solutionSet.Where(t => Regex.IsMatch(t.Item1.Item1.Pip.Name, StartPortRegexps[0])).Distinct().ToList();
            List <Tuple <Tuple <Location, Location>, List <Location> > > east = solutionSet.Where(t => Regex.IsMatch(t.Item1.Item1.Pip.Name, StartPortRegexps[1])).Distinct().ToList();


            SubSets subSets = new SubSets();
            int     tries   = 0;
            int     size    = 4;

            foreach (IEnumerable <Tuple <Tuple <Location, Location>, List <Location> > > wc in subSets.GetAllSubSets(west, size).Where(s => IsUnique(s)))
            {
                var westImuxes =
                    from t in wc
                    select t.Item1.Item2;

                foreach (IEnumerable <Tuple <Tuple <Location, Location>, List <Location> > > ec in subSets.GetAllSubSets(east, size).Where(s => IsUnique(s)))
                {
                    tries++;



                    var eastImuxes =
                        from t in ec
                        select t.Item1.Item2;

                    if (westImuxes.Equals(eastImuxes))
                    {
                        Console.WriteLine(wc);
                        Console.WriteLine(ec);
                    }
                }
            }

            return;

            List <Tuple <Tuple <Location, Location>, List <Location> > > result = new List <Tuple <Tuple <Location, Location>, List <Location> > >();

            foreach (IEnumerable <Tuple <Tuple <Location, Location>, List <Location> > > candidates in subSets.GetAllSubSets(solutionSet, 8))
            {
                List <Location> startPointsAndEndPoints = new List <Location>();
                foreach (Tuple <Tuple <Location, Location>, List <Location> > c in candidates)
                {
                    startPointsAndEndPoints.Add(c.Item1.Item1);
                    //startPointsAndEndPoints.Add(c.Item1.Item2);
                }
                int distinctCount = startPointsAndEndPoints.Distinct().Count();
                if (distinctCount != candidates.Count())
                {
                    continue;
                }

                //List<Tuple<Tuple<Location, Location>, List<Location>>> west = candidates.Where(t => t.Item1.Item1.Pip.Name.StartsWith(this.StartPortRegexps[0])).Distinct().ToList();
                //List<Tuple<Tuple<Location, Location>, List<Location>>> east = candidates.Where(t => t.Item1.Item1.Pip.Name.StartsWith(this.StartPortRegexps[1])).Distinct().ToList();


                if (west.Count == east.Count)
                {
                    var westImuxes =
                        from t in west
                        select t.Item1.Item2;

                    var eastImuxes =
                        from t in east
                        select t.Item1.Item2;

                    if (westImuxes.Equals(eastImuxes))
                    {
                    }
                }


                // List<Location> westImuxes = west.
            }
        }