public static void StoreAndShareSwitchMatrix(Tile tile, SwitchMatrix switchMatrix)
        {
            // string compare the current SM with the previous read in
            bool equalSmFound = false;

            foreach (SwitchMatrix sm in FPGA.FPGA.Instance.GetAllSwitchMatrices().Where(s => s.ArcCount == switchMatrix.ArcCount))
            {
                if (sm.Equals(switchMatrix))
                {
                    switchMatrix.HashCode = sm.HashCode;
                    equalSmFound          = true;
                    break;
                }
            }
            if (!equalSmFound)
            {
                switchMatrix.HashCode = FPGA.FPGA.Instance.SwitchMatrixCount;
            }

            //reached end of tile -> share common switch matrices
            if (!FPGA.FPGA.Instance.Contains(switchMatrix))
            {
                FPGA.FPGA.Instance.Add(switchMatrix.HashCode, switchMatrix);
            }

            tile.SwitchMatrixHashCode = switchMatrix.HashCode;
        }
Exemple #2
0
        static List <string> ReadSwitchPaths(string filename)
        {
            List <string> returnValue = new List <string>();
            SwitchMatrix  sw          = new SwitchMatrix(SwitchConfigFile);

            foreach (var path in sw.paths)
            {
                returnValue.Add(path.desc);
            }
            return(returnValue);
        }
Exemple #3
0
 public override void Run()
 {
     if (SelectedChannel != null)
     {
         Log.Info("Setting switch '{0}' channel to '{1}'.", SwitchMatrix.Name, SelectedChannel.Name);
         SwitchMatrix.SetMatrixChannel(SelectedChannel.Row, SelectedChannel.Column);
     }
     else
     {
         Log.Warning("Please select a valid channel.");
     }
 }
Exemple #4
0
        private void ProcessPips(string line)
        {
            string[] pairs = line.Split(',');
            if (pairs.Length != 2)
            {
                throw new ArgumentException("Error in line " + line);
            }
            int          startIndex = pairs[0].IndexOf('=');
            string       tileName   = pairs[0].Remove(0, startIndex + 1);
            Tile         t          = FPGA.FPGA.Instance.GetTile(tileName);
            SwitchMatrix sm         = new SwitchMatrix();

            string[] switching = pairs[1].Split(' ');

            foreach (string entry in switching.Where(s => !string.IsNullOrEmpty(s)))
            {
                // "LIOI3_SING.IOI_BYP6_0->IOI_IDELAY0_CINVCTRL"
                int fromEnd = entry.IndexOf('-');
                int toStart = entry.LastIndexOf('>'); // last due to ->>

                string from          = entry.Substring(0, fromEnd);
                bool   biDirectional = from.EndsWith("<<");
                // handle LH0<<->>LH12
                while (from.EndsWith(">") || from.EndsWith("<"))
                {
                    from = from.Remove(from.Length - 1);
                }
                string to = entry.Substring(toStart + 1);
                Port   p1 = new Port(from);
                Port   p2 = new Port(to);
                sm.Add(p1, p2);

                if (biDirectional && WireHelper.GetIncludeFlag(WireHelper.IncludeFlag.BiDirectionalPips))
                {
                    sm.Add(p2, p1);
                }
            }
            XDLTileParser.StoreAndShareSwitchMatrix(t, sm);
        }
        public void ParseTile(string line, XDLStreamReaderWithUndo sr)
        {
            int    yPos;
            int    xPos;
            string location;

            GetTileHeaderData(line, out yPos, out xPos, out location);

            TileKey key  = new TileKey(xPos, yPos);
            Tile    tile = new Tile(key, location);

            SwitchMatrix switchMatrix = new SwitchMatrix();

            //add tile to FPGA
            FPGA.FPGA.Instance.Add(tile);

            //read until end of tile
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Contains("pip"))
                {
                    // \t\t(pip TIOB_X1Y63 TIOB_DIFFO_OUT0 -> TIOB_DIFFO_IN1)
                    // scan for the first bracket in case \t is replaced by spaces!
                    int firstBracket = line.IndexOf('(', 0);
                    int firstBlank   = line.IndexOf(' ', firstBracket);
                    int secondBlank  = line.IndexOf(' ', firstBlank + 1);
                    int thirdBlank   = line.IndexOf(' ', secondBlank + 1);
                    int fourthBlank  = line.IndexOf(' ', thirdBlank + 1);

                    //String tileStr = line.Substring(firstBlank + 1, secondBlank - firstBlank);
                    string fromStr     = line.Substring(secondBlank + 1, thirdBlank - secondBlank - 1);
                    string pipOperator = line.Substring(thirdBlank + 1, fourthBlank - thirdBlank - 1);
                    string toStr       = line.Substring(fourthBlank + 1, line.Length - fourthBlank - 2);

                    if (toStr.Contains("(_ROUTE"))
                    {
                        toStr = toStr.Replace("(_ROUTE", "# (_ROUTE");
                    }

                    Port fromPort = new Port(fromStr);
                    Port toPort   = new Port(toStr);

                    // there are unidirectional and bidirectional wires
                    // save string comparison:
                    // if (pipAtoms[4].Equals("->"))
                    // else if (pipAtoms[4].Equals("=-"))

                    switchMatrix.Add(fromPort, toPort);
                    if (pipOperator.Equals("=-"))
                    {
                        switchMatrix.Add(toPort, fromPort);
                    }
                }
                else if (line.Contains("conn"))
                {
                }
                else if (line.Contains("wire"))
                {
                }
                else if (line.Contains("primitive_site"))
                {
                    InPortOutPortMapping nextPortMapping = new InPortOutPortMapping();
                    Slice nextSlice = XDLSliceParser.Parse(tile, nextPortMapping, line, sr);

                    // share in out port mappings
                    if (!FPGA.FPGA.Instance.Contains(nextPortMapping))
                    {
                        FPGA.FPGA.Instance.Add(nextPortMapping);
                    }
                    int hashCode = nextPortMapping.GetHashCode();
                    nextSlice.InPortOutPortMappingHashCode = hashCode;
                }
                else if (line.Contains("tile_summary"))
                {
                    StoreAndShareSwitchMatrix(tile, switchMatrix);

                    //consume closing bracket and exit
                    line = sr.ReadLine();
                    return;
                }
            }
        }