コード例 #1
0
        internal static List <VarValue> VisitValueChangeStream(VCDLexer lexer, IDToVarDef idToVariable, SimPass pass, BitAllocator bitAlloc)
        {
            List <VarValue> changes = new List <VarValue>();

            while (!lexer.IsEmpty())
            {
                ReadOnlyMemory <byte> text     = lexer.NextWordAsMem();
                ReadOnlySpan <byte>   endToken = new byte[] { (byte)'$', (byte)'e', (byte)'n', (byte)'d' };
                if (text.Span.SequenceEqual(endToken))
                {
                    break;
                }

                VisitValueChange(lexer, text, idToVariable, pass, bitAlloc);
                if (pass.BinValue.HasValue)
                {
                    changes.Add(pass.BinValue);
                }
                else if (pass.RealValue.HasValue)
                {
                    changes.Add(pass.RealValue);
                }
                else
                {
                    throw new Exception("Expected to read a value change but found none.");
                }
            }

            pass.Reset();
            return(changes);
        }
コード例 #2
0
        internal static (List <IDeclCmd> declarations, IDToVarDef idToVariable) VisitDeclCmdStream(VCDLexer lexer)
        {
            List <IDeclCmd> declarations = new List <IDeclCmd>();
            IDToVarDef      idToVariable = new IDToVarDef();
            Stack <Scope>   scopes       = new Stack <Scope>();

            while (!lexer.IsEmpty())
            {
                IDeclCmd?decl = VisitDeclCmd(lexer, idToVariable, scopes);
                if (decl == null)
                {
                    break;
                }
                declarations.Add(decl);
            }

            if (scopes.Count != 0)
            {
                throw new Exception("Not all declaration scopes were closed.");
            }

            return(declarations, idToVariable);
        }