Esempio n. 1
0
        public static ModellingType CreateType(ISubtypeIndication si)
        {
            if (si is ResolvedSubtypeIndication)
            {
                ModellingType res = CreateType((si as ResolvedSubtypeIndication).BaseType);
                res.Constraints.Add(new ResolvedTypeConstraint(si as ResolvedSubtypeIndication));
                return(res);
            }

            if (si is RangeSubtypeIndication)
            {
                ModellingType res = CreateType((si as RangeSubtypeIndication).BaseType);
                res.Constraints.Add(new RangeTypeConstraint(si as RangeSubtypeIndication));
                return(res);
            }

            if (si is IndexSubtypeIndication)
            {
                ModellingType res = CreateType((si as IndexSubtypeIndication).BaseType);
                res.Constraints.Add(new IndexTypeConstraint(si as IndexSubtypeIndication));
                return(res);
            }

            if (si is Subtype)
            {
                return(CreateType((si as Subtype).SubtypeIndication));
            }
            if (si is IntegerType)
            {
                return(ModellingType.CreateModellingType(si as IntegerType));
            }
            if (si is RealType)
            {
                return(ModellingType.CreateModellingType(si as RealType));
            }
            if (si is PhysicalType)
            {
                return(ModellingType.CreateModellingType(si as PhysicalType));
            }
            if (si is RecordType)
            {
                return(ModellingType.CreateModellingType(si as RecordType));
            }
            if (si is EnumerationType)
            {
                return(ModellingType.CreateModellingType(si as EnumerationType));
            }

            if (si is UnconstrainedArray)
            {
                return(ModellingType.CreateModellingType(si as UnconstrainedArray));
            }
            if (si is ConstrainedArray)
            {
                return(ModellingType.CreateModellingType(si as ConstrainedArray));
            }

            return(null);
        }
Esempio n. 2
0
        public ResolvedDiscreteRange [] ResolveRange(SubtypeDiscreteRange range)
        {
            ModellingType modelType = TypeCreator.CreateType(range.SubtypeIndication);

            if (modelType != null)
            {
                return(modelType.ResolvedRange);
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Создание ModellingType
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ModellingType CreateModellingType(Type type)
        {
            foreach (ModellingType t in CreatedTypes)
            {
                if (t.type == type)
                {
                    return(t);
                }
            }
            ModellingType res = new ModellingType(type);

            CreatedTypes.Add(res);
            return(res);
        }
Esempio n. 4
0
        /// <summary>
        /// Создание ModellingType
        /// </summary>
        /// <param name="type"></param>
        /// <param name="constraints"></param>
        /// <returns></returns>
        public static ModellingType CreateModellingType(Type type, List <AbstractConstraint> constraints)
        {
            foreach (ModellingType t in CreatedTypes)
            {
                if ((t.type == type) && (ArraysEqual(t.constraints, constraints)))
                {
                    return(t);
                }
            }
            ModellingType res = new ModellingType(type, constraints);

            CreatedTypes.Add(res);
            return(res);
        }
Esempio n. 5
0
        /// <summary>
        /// Создание ModellingType
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ModellingType CreateModellingType(ArrayType type, List <AbstractConstraint> constraints, ResolvedDiscreteRange[] dimension)
        {
            foreach (ModellingType t in CreatedTypes)
            {
                if ((t.type == type) && (ArraysEqual(t.constraints, constraints)) && (ArraysEqual(t.dimension, dimension)))
                {
                    return(t);
                }
            }
            ModellingType res = new ModellingType(type, constraints, dimension);

            CreatedTypes.Add(res);
            return(res);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 /// <summary>
 /// Получение настроек генератора по заданному модельному типу данных
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static GeneratorSettings GetGeneratorSettings(ModellingType type)
 {
     if (type.type is IntegerType)
     {
         return(new GeneratorSettings(32, GeneratorSettings.GeneratedValue.IntegerValue | GeneratorSettings.GeneratedValue.DoubleValue | GeneratorSettings.GeneratedValue.BoolArray, GeneratorSettings.GeneratedValue.IntegerValue, new List <object>()));
     }
     if (type.type is RealType)
     {
         return(new GeneratorSettings(32, GeneratorSettings.GeneratedValue.DoubleValue, GeneratorSettings.GeneratedValue.IntegerValue | GeneratorSettings.GeneratedValue.DoubleValue | GeneratorSettings.GeneratedValue.BoolArray, new List <object>()));
     }
     if (type.type is EnumerationType)
     {
         return(new GeneratorSettings(1, GeneratorSettings.GeneratedValue.EnumerableValue, GeneratorSettings.GeneratedValue.EnumerableValue, new List <object>((type.type as EnumerationType).Literals)));
     }
     if ((type.type == VHDL.builtin.StdLogic1164.STD_LOGIC_VECTOR) || (type.type == VHDL.builtin.StdLogic1164.STD_ULOGIC_VECTOR) || (type.type == VHDL.builtin.Standard.BIT_VECTOR))
     {
         return(new GeneratorSettings((uint)type.Dimension[0].Length, GeneratorSettings.GeneratedValue.IntegerValue | GeneratorSettings.GeneratedValue.DoubleValue | GeneratorSettings.GeneratedValue.BoolArray, GeneratorSettings.GeneratedValue.BoolArray));
     }
     return(null);
 }
Esempio n. 8
0
        public static Signal CreateSignal(string name, ISubtypeIndication si)
        {
            if (si is ResolvedSubtypeIndication)
            {
                Signal res = CreateSignal(name, (si as ResolvedSubtypeIndication).BaseType);
                return(res);
            }

            if (si is RangeSubtypeIndication)
            {
                Signal res = CreateSignal(name, (si as RangeSubtypeIndication).BaseType);
                return(res);
            }

            if (si is IndexSubtypeIndication)
            {
                Signal res = CreateUnconstrainedArraySignal(name, si as IndexSubtypeIndication);
                return(res);
            }

            if (si is Subtype)
            {
                return(CreateSignal(name, (si as Subtype).SubtypeIndication));
            }
            if (si is IntegerType)
            {
                ModellingType resType = ModellingType.CreateModellingType(si as IntegerType);
                IntegerAbstractValueConvertor  conv    = new IntegerAbstractValueConvertor(resType);
                AbstractSimpleSignalDump <int> resDump = new AbstractSimpleSignalDump <int>(name, resType, conv);
                Signal resSignal = new Signal(resDump);
                return(resSignal);
            }
            if (si is RealType)
            {
                ModellingType resType = ModellingType.CreateModellingType(si as RealType);
                RealAbstractValueConvertor        conv    = new RealAbstractValueConvertor(resType);
                AbstractSimpleSignalDump <double> resDump = new AbstractSimpleSignalDump <double>(name, resType, conv);
                Signal resSignal = new Signal(resDump);
                return(resSignal);
            }
            if (si is PhysicalType)
            {
                ModellingType resType = ModellingType.CreateModellingType(si as PhysicalType);
                PhysicalAbstractValueConvertor             conv    = new PhysicalAbstractValueConvertor(resType);
                AbstractSimpleSignalDump <PhysicalLiteral> resDump = new AbstractSimpleSignalDump <PhysicalLiteral>(name, resType, conv);
                Signal resSignal = new Signal(resDump);
                return(resSignal);
            }
            if (si is RecordType)
            {
                RecordType    recType = si as RecordType;
                ModellingType resType = ModellingType.CreateModellingType(recType);

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

                foreach (var el in recType.Elements)
                {
                    foreach (string s in el.Identifiers)
                    {
                        Signal newSignal = CreateSignal(s, el.Type);
                        childrens.Add(newSignal);
                        dumps.Add(newSignal.Dump);
                    }
                }

                SignalScopeDump resDump   = new SignalScopeDump(name, resType, dumps);
                Signal          resSignal = new Signal(resDump);
                return(resSignal);
            }
            if (si is EnumerationType)
            {
                ModellingType resType = ModellingType.CreateModellingType(si as EnumerationType);
                EnumerationAbstractValueConvertor conv;

                if (si == StdLogic1164.STD_ULOGIC)
                {
                    conv = new STD_ULOGIC_AbstractValueConvertor(resType);
                }
                else
                {
                    if (si == StdLogic1164.STD_LOGIC)
                    {
                        conv = new STD_LOGIC_AbstractValueConvertor(resType);
                    }
                    else
                    {
                        conv = new EnumerationAbstractValueConvertor(resType);
                    }
                }

                AbstractSimpleSignalDump <EnumerationLiteral> resDump = new AbstractSimpleSignalDump <EnumerationLiteral>(name, resType, conv);
                Signal resSignal = new Signal(resDump);
                return(resSignal);
            }

            if (si is ConstrainedArray)
            {
                ConstrainedArray arrayType = si as ConstrainedArray;
                ModellingType    resType   = ModellingType.CreateModellingType(arrayType);

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

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

                SignalScopeDump resDump   = new SignalScopeDump(name, resType, dumps);
                Signal          resSignal = new Signal(resDump);
                return(resSignal);
            }

            return(null);
        }
Esempio n. 9
0
        /// <summary>
        /// Используется для объединения дельтациклов в один объект TimeStampInfo
        /// </summary>
        /// <param name="elements"></param>
        /// <returns></returns>
        public static TimeStampInfo CombineTimestamps(ModellingType groupModellingType, IList <TimeStampInfo> elements)
        {
            TimeStampInfo res = new TimeStampInfo();

            List <AbstractValue>         values    = new List <AbstractValue>();
            List <TimeStampInfoIterator> iterators = new List <TimeStampInfoIterator>();
            int currentDeltaCycle = int.MaxValue;

            foreach (TimeStampInfo inf in elements)
            {
                if (inf != null)
                {
                    values.Add(inf[0]);
                    iterators.Add(new TimeStampInfoIterator(inf));
                    if (inf.ElementAt(0).Key < currentDeltaCycle)
                    {
                        currentDeltaCycle = inf.ElementAt(0).Key;
                    }
                }
            }

            bool IsDone = false;

            while (IsDone == false)
            {
                IsDone = true;
                foreach (TimeStampInfoIterator i in iterators)
                {
                    if (i.IsDone == false)
                    {
                        IsDone = false;
                        break;
                    }
                }

                if (IsDone == true)
                {
                    break;
                }

                currentDeltaCycle = int.MaxValue;

                foreach (TimeStampInfoIterator i in iterators)
                {
                    if ((i.IsDone == false) && (i.Current.Key < currentDeltaCycle))
                    {
                        currentDeltaCycle = i.Current.Key;
                    }
                }

                CompositeValue compValue = CompositeValue.CreateCompositeValue(groupModellingType, values);
                res.info.Add(currentDeltaCycle, compValue);

                for (int i = 0; i < iterators.Count; i++)
                {
                    TimeStampInfoIterator iter = iterators[i];
                    if (iter.Current.Key == currentDeltaCycle)
                    {
                        iter.MoveNext();
                        values[i] = iter.Current.Value;
                    }
                }
            }

            return(res);
        }
Esempio n. 10
0
 /// <summary>
 /// Используется для объединения дельтациклов в один объект TimeStampInfo
 /// </summary>
 /// <param name="elements"></param>
 /// <returns></returns>
 public static TimeStampInfo CombineTimestamps(ModellingType groupModellingType, params TimeStampInfo[] elements)
 {
     return(CombineTimestamps(groupModellingType, new List <TimeStampInfo>(elements)));
 }
Esempio n. 11
0
        /// <summary>
        /// Используется для разделения информации о моменте времени составного типа
        /// на набор информаций об момоенте времени его составляющих
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static List <TimeStampInfo> SplitTimestamps(ModellingType groupModellingType, TimeStampInfo info)
        {
            if (groupModellingType.Type is VHDL.type.RecordType)
            {
                List <TimeStampInfo> res = new List <TimeStampInfo>();
                foreach (var el in (groupModellingType.Type as VHDL.type.RecordType).Elements)
                {
                    foreach (string s in el.Identifiers)
                    {
                        res.Add(new TimeStampInfo());
                    }
                }

                foreach (var val in info)
                {
                    if (val.Value is CompositeValue)
                    {
                        int index = 0;
                        foreach (AbstractValue v in (val.Value as CompositeValue).GetChilds())
                        {
                            if ((res[index].Count == 0) || (res[index].LastValue != v))
                            {
                                res[index].info.Add(val.Key, v);
                            }
                            index++;
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Invalid type", "info");
                    }
                }

                return(res);
            }

            if (groupModellingType.Type is VHDL.type.ArrayType)
            {
                List <TimeStampInfo> res = new List <TimeStampInfo>();
                for (int i = 0; i < groupModellingType.SizeOf; i++)
                {
                    res.Add(new TimeStampInfo());
                }

                foreach (var val in info)
                {
                    if (val.Value is CompositeValue)
                    {
                        int index = 0;
                        foreach (AbstractValue v in (val.Value as CompositeValue).GetChilds())
                        {
                            if ((res[index].Count == 0) || (res[index].LastValue != v))
                            {
                                res[index].info.Add(val.Key, v);
                            }
                            index++;
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Invalid type", "info");
                    }
                }

                return(res);
            }

            throw new ArgumentException("Invalid type", "groupModellingType");
        }