public static List <PhysicalTypeBaseInfo> FormPhysicalValueDictionary(VHDL.type.PhysicalType typeDeclaration)
        {
            List <PhysicalTypeBaseInfo> dict = new List <PhysicalTypeBaseInfo>();
            int counter = 0;

            foreach (var literal in typeDeclaration.Units)
            {
                dict.Add(GetPhysicalUnit(literal));
                counter++;
            }
            return(dict);
        }
        public static string GeneratePhysicalType(VHDLCompilerInterface compiler, VHDL.type.PhysicalType typeDeclaration)
        {
            Int64          rangeLeft  = ((typeDeclaration.Range as VHDL.Range).From as VHDL.literal.IntegerLiteral).IntegerValue;
            Int64          rangeRight = ((typeDeclaration.Range as VHDL.Range).To as VHDL.literal.IntegerLiteral).IntegerValue;
            RangeDirection direction  = ((typeDeclaration.Range as VHDL.Range).Direction == VHDL.Range.RangeDirection.TO) ? RangeDirection.To : RangeDirection.DownTo;

            List <PhysicalTypeBaseInfo> dict = FormPhysicalValueDictionary(typeDeclaration);

            PhysicalTypeTemplate template = new PhysicalTypeTemplate(typeDeclaration.Identifier, dict, rangeLeft, rangeRight, direction);
            string text = template.TransformText();

            return(text);
        }
Пример #3
0
        public override void Observe(VHDLCompilerInterface compiler)
        {
            compiler.TypeDictionary.AddItem(type, type.Identifier);

            if (BuiltInTypesDictionary.ContainsBuiltInType(type))
            {
                return;
            }

            if (type is VHDL.type.IntegerType)
            {
                VHDL.type.IntegerType intType = type as VHDL.type.IntegerType;
                ObserveIntegerType(compiler, intType);
                return;
            }

            if (type is VHDL.type.RealType)
            {
                VHDL.type.RealType realType = type as VHDL.type.RealType;
                ObserveFloatingPointType(compiler, realType);
                return;
            }

            if (type is VHDL.type.EnumerationType)
            {
                VHDL.type.EnumerationType enumType = type as VHDL.type.EnumerationType;
                ObserveEnumerationType(compiler, enumType);
                return;
            }

            if (type is VHDL.type.PhysicalType)
            {
                VHDL.type.PhysicalType physType = type as VHDL.type.PhysicalType;
                ObserveEnumerationType(compiler, physType);
                return;
            }
        }
Пример #4
0
        public void ObserveEnumerationType(VHDLCompilerInterface compiler, VHDL.type.PhysicalType physType)
        {
            string code = PhysicalTypeGeneratorHelper.GeneratePhysicalType(compiler, physType);

            compiler.SaveCode(code, physType.Identifier);
        }
Пример #5
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 public PhysicalValue(VHDL.type.PhysicalType type)
     : base(type)
 {
     this.doubleValue = 0;
 }
Пример #6
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="type"></param>
 public PhysicalValue(VHDL.type.PhysicalType type, PhysicalLiteral physicalValue)
     : base(type)
 {
     this._value = physicalValue;
 }