예제 #1
0
        public ResolvedDiscreteRange ResolveSimpleRange(Range range)
        {
            int from = (int)(Evaluate(range.From) as IntegerValue).Value;
            int to   = (int)(Evaluate(range.To) as IntegerValue).Value;

            return(ResolvedDiscreteRange.FormIntegerIndexes(from, to));
        }
예제 #2
0
 private ResolvedDiscreteRange[] GetResolvedRange()
 {
     if (type is EnumerationType)
     {
         int count = (type as EnumerationType).Literals.Count;
         return(new ResolvedDiscreteRange[] { ResolvedDiscreteRange.FormIntegerIndexes(1, count) });
     }
     return(new ResolvedDiscreteRange[] { ResolvedDiscreteRange.Range1 });
 }
예제 #3
0
        private static Signal CreateUnconstrainedArraySignal(string name, IndexSubtypeIndication si)
        {
            if (si.BaseType is UnconstrainedArray)
            {
                UnconstrainedArray arrayType = si.BaseType as UnconstrainedArray;

                List <ResolvedDiscreteRange> resolvedRanges = new List <ResolvedDiscreteRange>();
                foreach (DiscreteRange r in si.Ranges)
                {
                    if (r is Range)
                    {
                        int from = (ExpressionEvaluator.DefaultEvaluator.Evaluate((r as Range).From) as IntegerValue).Value;
                        int to   = (ExpressionEvaluator.DefaultEvaluator.Evaluate((r as Range).To) as IntegerValue).Value;
                        ResolvedDiscreteRange newRange = ResolvedDiscreteRange.FormIntegerIndexes(from, to);
                        resolvedRanges.Add(newRange);
                    }
                }

                ModellingType resType = ModellingType.CreateModellingType(arrayType, resolvedRanges.ToArray());
                resType.Constraints.Add(new IndexTypeConstraint(si));


                List <AbstractSignalDump> dumps     = new List <AbstractSignalDump>();
                List <Signal>             childrens = new List <Signal>();

                int[,] resIndexes = ResolvedDiscreteRange.CombineRanges(resolvedRanges.ToArray());
                for (int i = 0; i < resIndexes.GetLength(0); i++)
                {
                    for (int j = 0; j < resIndexes.GetLength(1); j++)
                    {
                        Signal newSignal = CreateSignal(resolvedRanges[j][resIndexes[i, j]].ToString(), arrayType.IndexSubtypes[j]);
                        childrens.Add(newSignal);
                        dumps.Add(newSignal.Dump);
                    }
                }

                SignalScopeDump resDump   = new SignalScopeDump(name, resType, dumps);
                Signal          resSignal = new Signal(resDump);
                return(resSignal);
            }
            return(null);
        }
예제 #4
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 public ArrayValue(VHDL.type.UnconstrainedArray type, Dictionary <int[], AbstractValue> dictionary)
     : base(ModellingType.CreateModellingType(type, new ResolvedDiscreteRange[] { ResolvedDiscreteRange.FormIntegerIndexes(dictionary.Count) }))
 {
     _values = dictionary;
 }
예제 #5
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 public ArrayValue(VHDL.type.UnconstrainedArray type, IList <AbstractValue> _value)
     : base(ModellingType.CreateModellingType(type, new ResolvedDiscreteRange[] { ResolvedDiscreteRange.FormIntegerIndexes(_value.Count) }))
 {
     _values = CreateDictionary(_value);
 }
예제 #6
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 = int.TryParse(temp[1], out var.startIndex);
                    parse_res = int.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  = TypeCreator.CreateSignal(var.Reference, VHDL.builtin.Standard.INTEGER);
                var.appendFunction = VCDConvertor.Append_Integer_VALUE;
                break;

            case VCD_Variable.VCDVariableType.Real:
                var.base_variable  = TypeCreator.CreateSignal(var.Reference, VHDL.builtin.Standard.REAL);
                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)
                {
                    var.base_variable  = TypeCreator.CreateSignal(var.Reference, VHDL.builtin.StdLogic1164.STD_ULOGIC);
                    var.appendFunction = VCDConvertor.Append_STD_ULOGIC_VALUE;
                }
                else
                {
                    ResolvedDiscreteRange        range     = ResolvedDiscreteRange.FormIntegerIndexes(var.StartIndex, var.EndIndex);
                    VHDL.type.ISubtypeIndication arrayType = VHDL.builtin.StdLogic1164.Create_STD_ULOGIC_VECTOR(new Range(range.From, (range.RangeDirection == RangeDirection.To)?Range.RangeDirection.TO:Range.RangeDirection.DOWNTO, range.To));
                    var.base_variable  = TypeCreator.CreateSignal(var.Reference, arrayType);
                    var.appendFunction = VCDConvertor.Append_STD_ULOGIC_VECTOR_VALUE;
                }
            }
            break;
            }

            return(var);
        }