コード例 #1
0
        public static void AddTemplate(XDLContainer netlistContainer, string template, string location, int primitiveIndex)
        {
            StreamReader sr        = new StreamReader(template);
            string       wholeFile = sr.ReadToEnd();

            sr.Close();

            Tile            t = FPGA.FPGA.Instance.GetTile(location);
            MatchCollection instanceMatches = m_regExpInstance.Matches(wholeFile);

            foreach (Match match in instanceMatches)
            {
                string instanceCode = match.Groups[1].Value;

                instanceCode = instanceCode.Replace("_LOCATION_", t.Location);
                instanceCode = instanceCode.Replace("_SLICENAME_", t.Slices[primitiveIndex].SliceName);
                instanceCode = instanceCode.Replace("_SLICETYPE_", t.Slices[primitiveIndex].SliceType);

                // attach usage
                t.Slices[primitiveIndex].Usage = FPGATypes.SliceUsage.Blocker;
                netlistContainer.AddSliceCodeBlock(instanceCode);
            }

            MatchCollection netMatches = m_regExpNets.Matches(wholeFile);

            foreach (Match netMatch in netMatches)
            {
                string netCode = netMatch.Groups[1].Value;

                // DSP and BRAM templates only use _LOCATION_
                netCode = netCode.Replace("_LOCATION_", t.Location);
                // SLICEX templates only use _SLICENAME_
                netCode = netCode.Replace("_SLICENAME_", t.Slices[primitiveIndex].SliceName);

                netlistContainer.AddNetCodeBlock(netCode);
            }
        }
        private void RelocateInstancesForXDL(LibraryElement libElement, Tile anchorCLB, XDLContainer netlistContainer)
        {
            // reli
            foreach (Tuple <Instance, Tile> tileSliceTupel in libElement.GetInstanceTiles(anchorCLB, libElement))
            {
                int   sliceNumber = tileSliceTupel.Item1.SliceNumber;
                Slice slice       = tileSliceTupel.Item2.Slices[sliceNumber];

                string xdlCode = tileSliceTupel.Item1.ToString();

                /* in TODO init.goa auslagern
                 * @"placed.*SLICE_X\d+Y\d+";
                 * @"placed.*TIEOFF_X\d+Y\d+";
                 * @"placed.*RAMB16_X\d+Y\d+"
                 *
                 */

                if (IdentifierManager.Instance.IsMatch(tileSliceTupel.Item1.Location, IdentifierManager.RegexTypes.CLB))
                {
                    // replace placement information in: inst "right" "SLICEX", placed CLEXL_X9Y33 SLICE_X13Y33
                    string newPlacement = "placed " + tileSliceTupel.Item2.Location + " " + slice.SliceName;
                    string oldPlacement = @"placed.*SLICE_X\d+Y\d+";
                    xdlCode = Regex.Replace(xdlCode, oldPlacement, newPlacement);
                }
                else if (IdentifierManager.Instance.IsMatch(tileSliceTupel.Item1.Location, IdentifierManager.RegexTypes.Interconnect))
                {
                    string newPlacement = "placed " + tileSliceTupel.Item2.Location + " " + slice.SliceName;
                    string oldPlacement = @"placed.*TIEOFF_X\d+Y\d+";
                    xdlCode = Regex.Replace(xdlCode, oldPlacement, newPlacement);
                }
                else if (IdentifierManager.Instance.IsMatch(tileSliceTupel.Item1.Location, IdentifierManager.RegexTypes.DSP))
                {
                    int    underScoreLocation = tileSliceTupel.Item2.Location.IndexOf("_");
                    string locationPrefix     = tileSliceTupel.Item2.Location.Substring(0, underScoreLocation);

                    string newPlacement = "placed " + tileSliceTupel.Item2.Location + " " + slice.SliceName;
                    string oldPlacement = "placed.*" + locationPrefix + @"_X\d+Y\d+.*" + tileSliceTupel.Item1.SliceName;

                    xdlCode = Regex.Replace(xdlCode, oldPlacement, newPlacement);
                }
                else if (IdentifierManager.Instance.IsMatch(tileSliceTupel.Item1.Location, IdentifierManager.RegexTypes.BRAM))
                {
                    int    underScoreLocation = tileSliceTupel.Item2.Location.IndexOf("_");
                    string locationPrefix     = tileSliceTupel.Item2.Location.Substring(0, underScoreLocation);

                    string newPlacement = "placed " + tileSliceTupel.Item2.Location + " " + slice.SliceName;
                    string oldPlacement = "placed.*" + locationPrefix + @"_X\d+Y\d+.*" + tileSliceTupel.Item1.SliceName;
                    //String oldPlacement = @"placed.*RAMB16_X\d+Y\d+";
                    xdlCode = Regex.Replace(xdlCode, oldPlacement, newPlacement);
                }

                if (InsertPrefix)
                {
                    // insert instance prefix
                    // remove greedy between double quotes
                    MatchCollection matches         = Regex.Matches(xdlCode, "(\".*?\")");
                    string          oldInstanceName = matches[0].ToString();
                    oldInstanceName = Regex.Replace(oldInstanceName, "\"", "");
                    string newInstanceName = InstanceName + Regex.Replace(oldInstanceName, "\"", "");

                    // replace both the instance name AND slice configuration
                    xdlCode = xdlCode.Replace("\"" + oldInstanceName, "\"" + newInstanceName);

                    if (IdentifierManager.Instance.IsMatch(tileSliceTupel.Item1.Location, IdentifierManager.RegexTypes.BRAM))
                    {
                        xdlCode = xdlCode.Replace("RAMB16BWER:" + oldInstanceName, "RAMB16BWER:" + newInstanceName);
                    }

                    // XDL Shape??
                    xdlCode = xdlCode.Replace("Shape_", InstanceName + "Shape_");
                }

                netlistContainer.AddSliceCodeBlock(xdlCode);
            }
        }
コード例 #3
0
        protected override void DoCommandAction()
        {
            FPGATypes.AssertBackendType(FPGATypes.BackendType.ISE);

            XDLContainer nlc = (XDLContainer)GetNetlistContainer();

            List <string> fixedSliceConfigurations = new List <string>();

            foreach (XDLInstance inst in nlc.Instances)
            {
                // A5LUT:Inst_PE/Mmult_OPA[31]_OPB[31]_MuLt_17_OUT_Madd10_cy<6>:#LUT -> A5LUT::#LUT
                string originalCode = inst.ToString();
                string fixedCode    = originalCode;
                if (!fixedCode.Contains("A5LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " A5LUT:(.+?):#LUT:", " A5LUT::#LUT:");
                }
                if (!fixedCode.Contains("B5LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " B5LUT:(.+?):#LUT:", " B5LUT::#LUT:");
                }
                if (!fixedCode.Contains("C5LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " C5LUT:(.+?):#LUT:", " C5LUT::#LUT:");
                }
                if (!fixedCode.Contains("D5LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " D5LUT:(.+?):#LUT:", " D5LUT::#LUT:");
                }
                if (!fixedCode.Contains("A6LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " A6LUT:(.+?):#LUT:", " A6LUT::#LUT:");
                }
                if (!fixedCode.Contains("B6LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " B6LUT:(.+?):#LUT:", " B6LUT::#LUT:");
                }
                if (!fixedCode.Contains("C6LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " C6LUT:(.+?):#LUT:", " C6LUT::#LUT:");
                }
                if (!fixedCode.Contains("D6LUT::#OFF"))
                {
                    fixedCode = Regex.Replace(fixedCode, " D6LUT:(.+?):#LUT:", " D6LUT::#LUT:");
                }
                // neu
                // A5FF:Inst_PE/Mmult_OPA[31]_OPB[31]_MuLt_18_OUT_OPA,OPB<20>_x_OPA,OPB<62>_mand1_FRB: -> A5FF::
                if (!fixedCode.Contains("A5FF::"))
                {
                    fixedCode = Regex.Replace(fixedCode, "A5FF:(.+?):", "A5FF::");
                }
                if (!fixedCode.Contains("B5FF::"))
                {
                    fixedCode = Regex.Replace(fixedCode, "B5FF:(.+?):", "B5FF::");
                }
                if (!fixedCode.Contains("C5FF::"))
                {
                    fixedCode = Regex.Replace(fixedCode, "C5FF:(.+?):", "C5FF::");
                }
                if (!fixedCode.Contains("D5FF::"))
                {
                    fixedCode = Regex.Replace(fixedCode, "D5FF:(.+?):", "D5FF::");
                }

                // BFF:Inst_PE/config_data_en_0:#FF --> BFF::#FF
                if (!fixedCode.Contains("AFF::#OFF") && !fixedCode.Contains("AFF::#FF"))
                {
                    fixedCode = Regex.Replace(fixedCode, "AFF:(.+?):", "AFF::");
                }
                if (!fixedCode.Contains("BFF::#OFF") && !fixedCode.Contains("BFF::#FF"))
                {
                    fixedCode = Regex.Replace(fixedCode, "BFF:(.+?):", "BFF::");
                }
                if (!fixedCode.Contains("CFF::#OFF") && !fixedCode.Contains("CFF::#FF"))
                {
                    fixedCode = Regex.Replace(fixedCode, "CFF:(.+?):", "CFF::");
                }
                if (!fixedCode.Contains("DFF::#OFF") && !fixedCode.Contains("DFF::#FF"))
                {
                    fixedCode = Regex.Replace(fixedCode, "DFF:(.+?):", "DFF::");
                }

                fixedSliceConfigurations.Add(fixedCode);
            }

            nlc.Remove(delegate(Instance i) { return(true); });
            foreach (string xdlCode in fixedSliceConfigurations)
            {
                nlc.AddSliceCodeBlock(xdlCode);
            }
        }