예제 #1
0
        public void ParseDumpVars()
        {
            Scope scope = new Scope(ScopeType.Module, "tester1");

            Scope[] scopes = { scope };

            IDeclCmd[] expectedDecls = new IDeclCmd[]
            {
                scope,
                new VarDef(VarType.Wire, 4, "'", "values_2/in", scopes),
                new VarDef(VarType.Wire, 4, "(", "values_1", scopes),
                new VarDef(VarType.Wire, 1, "-", "clock", scopes),
                new VarDef(VarType.Wire, 4, ".", "values_0", scopes),
                new UpScope()
            };

            ISimCmd[] expectedSimCmds = new ISimCmd[]
            {
                new DumpVars(new List <VarValue>()
                {
                    new BinaryVarValue(new BitState[] { BitState.Zero, BitState.Zero, BitState.Zero, BitState.Zero }, new List <VarDef>()
                    {
                        (VarDef)expectedDecls[1]
                    }, true),
                    new BinaryVarValue(new BitState[] { BitState.Zero, BitState.Zero, BitState.Zero, BitState.Zero }, new List <VarDef>()
                    {
                        (VarDef)expectedDecls[4]
                    }, true),
                    new BinaryVarValue(new BitState[] { BitState.Zero, BitState.Zero, BitState.Zero, BitState.Zero }, new List <VarDef>()
                    {
                        (VarDef)expectedDecls[2]
                    }, true),
                    new BinaryVarValue(new BitState[] { BitState.Zero }, new List <VarDef>()
                    {
                        (VarDef)expectedDecls[3]
                    }, true)
                })
            };

            string vcdString = @"
$scope module tester1 $end
$var wire 4 ' values_2/in $end
$var wire 4 ( values_1 $end
$var wire 1 - clock $end
$var wire 4 . values_0 $end
$upscope $end
$enddefinitions $end
$dumpvars
b0000 '
b0000 .
b0000 (
0-
$end";
            VCD    vcd       = Parse.FromString(vcdString);

            TestTools.VerifyDeclarations(expectedDecls, vcd.Declarations);
            TestTools.VerifySimCmds(expectedSimCmds, vcd.GetSimulationCommands().ToArray());
        }
        public void ParseVariable()
        {
            foreach (VarType varType in Enum.GetValues(typeof(VarType)))
            {
                IDeclCmd[] expectedHeader = new IDeclCmd[]
                {
                    new VarDef(varType, 6, "!", "_T_4", Array.Empty <Scope>())
                };

                string vcdString = @$ "
$var {varType.ToString().ToLower()} 6 ! _T_4 $end
$enddefinitions $end";
                VCD    vcd       = Parse.FromString(vcdString);

                TestTools.VerifyDeclarations(expectedHeader, vcd.Declarations);
            }
        }
예제 #3
0
        public void ParseVectorBinarySize2ValueChange()
        {
            IDeclCmd[] expectedDecls = new IDeclCmd[]
            {
                new VarDef(VarType.Wire, 2, "b1", "b1", Array.Empty <Scope>())
            };
            ISimCmd[] expectedSimCmds = new ISimCmd[]
            {
                new BinaryVarValue(new BitState[] { BitState.Zero, BitState.Zero }, new List <VarDef>()
                {
                    (VarDef)expectedDecls[0]
                }, true)
            };

            string vcdString = @$ "
$var wire 2 b1 b1 $end
$enddefinitions $end
b00 b1";
            VCD    vcd       = Parse.FromString(vcdString);

            TestTools.VerifyDeclarations(expectedDecls, vcd.Declarations);
            TestTools.VerifySimCmds(expectedSimCmds, vcd.GetSimulationCommands().ToArray());
        }