Ejemplo n.º 1
0
        /// <summary>
        /// The $var section lists the names and identifier codes of all the variables.
        /// </summary>
        /// <param name="Words"></param>
        private void OnVar(string[] Words)
        {
            VCD_Variable var = VCD_Variable.Parse(Words);

            var.Variable.Idx = signalCounter;
            signalCounter++;
            var.Scope = CurrentVCDScope.ToArray();
            variables.Add(var);

            /*if (var.Size == 1)
             * //Простой тип данных
             * {
             *  My_Variable new_var = new My_Variable(var.Reference, var.FullName, new Schematix.Waveform.DataTypes.STD_LOGIC());
             *  var.Variable = new_var;
             *  CurrentScope.Variables.Add(new_var);
             * }
             * //векторный тип данных
             * else
             * {
             *  My_Variable new_var = new My_Variable(var.Reference, var.FullName, new Schematix.Waveform.DataTypes.STD_LOGIC_VECTOR(0, (int)var.Size));
             *  var.Variable = new_var;
             *  CurrentScope.Variables.Add(new_var);
             * }*/

            Signal new_var = var.Variable;

            var.Variable = new_var;
            CurrentScope.Variables.Add(new_var);
        }
Ejemplo n.º 2
0
        private void OnSimpleValueChange(string value)
        {
            string       identifier = value.Substring(1);
            string       newvalue   = new string(new char[] { value[0] });
            VCD_Variable vcd_var    = GetVCDVariableByIdentifier(identifier, true);

            vcd_var.AppendValue(CurrentTime, newvalue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Запись в дамп переменных (с одновременной инициализацией списка переменны[)
        /// </summary>
        /// <param name="scope"></param>
        private void WriteScopeVariables(SimulationScope scope)
        {
            if (scope.Parent != null)
            {
                writer.WriteLine(string.Format("$scope module {0}  $end", scope.Name));
            }

            string str_identifier = new string(new char[] { (char)identifier });

            foreach (ValueProvider var in scope.Variables)
            {
                if (var is Signal)
                {
                    VCD_Variable vcd_var = new VCD_Variable((var as Signal), str_identifier);
                    variables.Add(vcd_var);
                    identifier++;
                    StringBuilder newIdentf = new StringBuilder();

                    for (int i = identifier; i > 0; i /= 256)
                    {
                        newIdentf.Append((char)(i % 256));
                    }

                    str_identifier = newIdentf.ToString();
                    writer.WriteLine(string.Format("$var {0} $end", vcd_var.VCDVariableDeclaration));
                }
            }

            foreach (SimulationScope s in scope.Items)
            {
                WriteScopeVariables(s);
            }

            if (scope.Parent != null)
            {
                writer.WriteLine("$upscope $end");
            }
        }
Ejemplo n.º 4
0
        private void OnComplexValueChange(string value, string identifier)
        {
            VCD_Variable vcd_var = GetVCDVariableByIdentifier(identifier, false);

            vcd_var.AppendValue(CurrentTime, value);
        }
Ejemplo n.º 5
0
        public static VCD_Variable Parse(string[] Words)
        {
            VCD_Variable var = new VCD_Variable();

            // var.var_type
            switch (Words[1].ToLower())
            {
            case "event": var.var_type = VCDVariableType.Event; break;

            case "integer": var.var_type = VCDVariableType.Integer; break;

            case "parameter": var.var_type = VCDVariableType.Parameter; break;

            case "real": var.var_type = VCDVariableType.Real; break;

            case "reg": var.var_type = VCDVariableType.Reg; break;

            case "supply0": var.var_type = VCDVariableType.Supply0; break;

            case "supply1": var.var_type = VCDVariableType.Supply1; break;

            case "time": var.var_type = VCDVariableType.Time; break;

            case "tri": var.var_type = VCDVariableType.Tri; break;

            case "triand": var.var_type = VCDVariableType.Triand; break;

            case "trior": var.var_type = VCDVariableType.Trior; break;

            case "trireg": var.var_type = VCDVariableType.Trireg; break;

            case "tri0": var.var_type = VCDVariableType.Tri0; break;

            case "tri1": var.var_type = VCDVariableType.Tri1; break;

            case "wand": var.var_type = VCDVariableType.Wand; break;

            case "wire": var.var_type = VCDVariableType.Wire; break;

            case "wor": var.var_type = VCDVariableType.Wor; break;
            }

            var.size       = uint.Parse(Words[2]);
            var.identifier = Words[3];

            //Если встераем сложное имя переменной с учетом ее размерности
            if ((var.size != 1))
            {
                if (Words[4].Contains(":"))
                {
                    string[] temp = Words[4].Split(new char[] { ' ', '[', ']', ':' });
                    var.reference = temp[0];
                    bool parse_res = Int64.TryParse(temp[1], out var.startIndex);
                    parse_res = Int64.TryParse(temp[2], out var.endIndex);
                }
                else
                {
                    var.reference  = Words[4];
                    var.endIndex   = (int)var.size - 1;
                    var.startIndex = 0;
                }
            }
            else
            {
                var.reference = Words[4];
            }

            switch (var.VariableType)
            {
            case VCD_Variable.VCDVariableType.Integer:
                var.base_variable  = new Signal <VHDLIntegerValue>(new VHDLIntegerValue(0), var.Reference);
                var.appendFunction = VCDConvertor.Append_Integer_VALUE;
                break;

            case VCD_Variable.VCDVariableType.Real:
                var.base_variable  = new Signal <VHDLFloatingPointValue>(new VHDLFloatingPointValue(0), var.Reference);
                var.appendFunction = VCDConvertor.Append_Real_VALUE;
                break;

            case VCD_Variable.VCDVariableType.Time:
                break;

            case VCD_Variable.VCDVariableType.Event:
            case VCD_Variable.VCDVariableType.Parameter:
            case VCD_Variable.VCDVariableType.Reg:
            case VCD_Variable.VCDVariableType.Supply0:
            case VCD_Variable.VCDVariableType.Supply1:
            case VCD_Variable.VCDVariableType.Tri:
            case VCD_Variable.VCDVariableType.Tri0:
            case VCD_Variable.VCDVariableType.Tri1:
            case VCD_Variable.VCDVariableType.Triand:
            case VCD_Variable.VCDVariableType.Trior:
            case VCD_Variable.VCDVariableType.Trireg:
            case VCD_Variable.VCDVariableType.Wand:
            case VCD_Variable.VCDVariableType.Wire:
            case VCD_Variable.VCDVariableType.Wor:
            {
                if (var.Size == 1)
                {
                    new Signal <VHDLRuntime.Values.BuiltIn.BIT>(new VHDLRuntime.Values.BuiltIn.BIT(VHDLRuntime.Values.BuiltIn.BIT_Enum.item_0), var.Reference);
                    var.appendFunction = VCDConvertor.Append_BIT_VALUE;
                }
                else
                {
                }
            }
            break;
            }

            return(var);
        }