Esempio n. 1
0
        private bool ParseNewFile()
        {
            if (this.sr == null)
            {
                return(false);
            }
            while (true)
            {
                Token currToken = tok.Next();
                if (currToken.Value == "module")
                {
                    bkmrks          = DFFModule.ParseModuleHeader(tok);
                    this.moduleName = bkmrks[0].Value;
                    bkmrks.RemoveAt(0);
                }
                if (currToken.Kind == TokenKind.EOF)
                {
                    break;
                }
                if (currToken.Kind == TokenKind.EOL)
                {
                    while (currToken.Kind == TokenKind.EOL)
                    {
                        currToken = tok.Next();
                    }

                    string currWord = currToken.Value;
                    if (currWord == "module")
                    {
                        bkmrks          = DFFModule.ParseModuleHeader(tok);
                        this.moduleName = bkmrks[0].Value;
                        bkmrks.RemoveAt(0);//Remove module name bookmark
                    }
                    else if (currWord.StartsWith("dff"))
                    {
                        DFFModule dff = DFFModule.ParseDFF(tok);
                        numDffsTopModule += dff.numDFFs;
                        dffs.Add(dff);
                    }
                    else
                    {
                        foreach (VerilogFile subModule in this.subModules)
                        {
                            if (currWord == subModule.moduleName)
                            {
                                subPortBkmrks.Add(ParseSubmodule(tok, subModule));
                            }
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        static public DFFModule ParseDFF(StringTokenizer tok)
        {
            DFFModule dff = new DFFModule();

            while (true)
            {
                Token  currToken = tok.Next();
                string word      = currToken.Value;

                if (word == "#")
                {
                    tok.Next();
                    currToken   = tok.Next();
                    word        = currToken.Value;
                    dff.numDFFs = Convert.ToInt32(word);

                    tok.Next();
                    currToken = tok.Next();
                    dff.name  = currToken.Value;
                    continue;
                }
                else
                {
                    dff.name = word;
                }

                if (word == ".")
                {
                    currToken = tok.Next();
                    if (currToken.Value == "q")
                    {
                        tok.Next();
                        currToken = tok.Next();
                        dff.qName = currToken.Value;
                        if (currToken.Value == "{")
                        {
                            while (currToken.Value != "}")
                            {
                                currToken  = tok.Next();
                                dff.qName += currToken.Value;
                            }
                        }
                        break;
                    }
                }
            }
            if (dff.numDFFs == 0)
            {
                dff.numDFFs = 1;
            }
            return(dff);
        }
Esempio n. 3
0
        private bool WriteShadowDffs(StreamWriter sw, StreamReader sr)
        {
            string fileText;

            fileText = sr.ReadToEnd();
            StringTokenizer tok = new StringTokenizer(fileText);

            tok.IgnoreWhiteSpace = true;

            int totalDFFs           = 0;
            List <DFFModule> dffs   = new List <DFFModule>();
            List <Token>     bkmrks = new List <Token>();

            while (true)
            {
                Token currToken = tok.Next();
                if (currToken.Value == "module")
                {
                    bkmrks = DFFModule.ParseModuleHeader(tok);
                }
                if (currToken.Kind == TokenKind.EOF)
                {
                    break;
                }
                if (currToken.Kind == TokenKind.EOL)
                {
                    while (currToken.Kind == TokenKind.EOL)
                    {
                        currToken = tok.Next();
                    }
                    string currWord = currToken.Value;

                    if (currWord == "module")
                    {
                        bkmrks = DFFModule.ParseModuleHeader(tok);
                    }

                    if (currWord.StartsWith("dff"))
                    {
                        DFFModule dff = DFFModule.ParseDFF(tok);
                        totalDFFs += dff.numDFFs;
                        dffs.Add(dff);
                        progressBar1.PerformStep();
                    }
                }
            }

            logBox.Text += "Total DFFs Detected: " + dffs.Count() + "\r\n";
            logBox.Text += "Total DFF bits detected: " + totalDFFs + "\r\n";
            logBox.Text += "DFF Output Names:" + "\r\n";
            foreach (DFFModule dff in dffs)
            {
                logBox.Text += "\t" + dff.numDFFs + ":    " + dff.qName + "\r\n";
                progressBar1.PerformStep();
            }

            bool writeSuccess = WriteShadowFile(sw, fileText, bkmrks, dffs, totalDFFs);


            return(writeSuccess);
        }