コード例 #1
0
        public override void Observe(VHDLCompilerInterface compiler)
        {
            compiler.TypeDictionary.AddItem(type, type.Identifier);

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

            ISubtypeIndication si       = type.SubtypeIndication;
            string             typeName = type.Identifier;

            if (si is RangeSubtypeIndication)
            {
                RangeSubtypeIndication rangeSI = si as RangeSubtypeIndication;
                ISubtypeIndication     baseSI  = rangeSI.BaseType;
                if (baseSI is VHDL.type.IntegerType)
                {
                    ObserveIntegerSubType(compiler, rangeSI, typeName);
                }

                if (baseSI is VHDL.type.RealType)
                {
                    ObserveRealSubType(compiler, rangeSI, typeName);
                }
            }
        }
コード例 #2
0
 public override void Observe(VHDLCompilerInterface compiler)
 {
     if (statement is ProcessStatement)
     {
         ObserveProcess(compiler, statement as ProcessStatement);
     }
 }
コード例 #3
0
        public static string GenerateFloatingPointSubType(VHDLCompilerInterface compiler, string typeName, string baseType, double rangeLeft, double rangeRight, RangeDirection rangeRirection)
        {
            FloatPointSubTypeTemplate template = new FloatPointSubTypeTemplate(typeName, baseType, rangeLeft, rangeRight, rangeRirection);
            string text = template.TransformText();

            return(text);
        }
コード例 #4
0
        public static string GetNotOperand(Not expression, VHDLCompilerInterface compiler)
        {
            string destination            = GetOperand(expression.Expression, compiler);
            FunctionCallTemplate template = new FunctionCallTemplate(destination, "Not");

            return(template.TransformText());
        }
コード例 #5
0
        public static string GetRealLiteralOperand(RealLiteral expression, VHDLCompilerInterface compiler)
        {
            string value = expression.RealValue.ToString(CultureInfo.InvariantCulture);
            NewStatementTemplate template = new NewStatementTemplate("VHDLFloatingPointValue", value);

            return(template.TransformText());
        }
コード例 #6
0
        private string GetSequentialCode(VHDLCompilerInterface compiler, SequentialStatement st)
        {
            SequentialStatementObserver observer = new SequentialStatementObserver(st, logger);

            observer.Observe(compiler);
            return(observer.code);
        }
コード例 #7
0
        public void ObserveIfStatement(VHDLCompilerInterface compiler, IfStatement statement)
        {
            string        condition      = VHDLOperandGenerator.GetOperand(statement.Condition, compiler);
            List <string> statements     = new List <string>();
            List <string> elseStatements = new List <string>();
            List <IfTemplateElsifStatement> elsifParts = new List <IfTemplateElsifStatement>();

            foreach (var st in statement.Statements)
            {
                statements.Add(GetSequentialCode(compiler, st));
            }

            foreach (var st in statement.ElseStatements)
            {
                elseStatements.Add(GetSequentialCode(compiler, st));
            }

            foreach (var elsif in statement.ElsifParts)
            {
                elsifParts.Add(GetElsifObject(compiler, elsif));
            }

            IfTemplate template   = new IfTemplate(condition, statements, elsifParts, elseStatements);
            string     resultCode = template.TransformText();

            code = resultCode;
        }
コード例 #8
0
        public void ObserveProcess(VHDLCompilerInterface compiler, ProcessStatement process)
        {
            ProcessObserver po = new ProcessObserver(process, logger);

            po.Observe(compiler);
            method = new ProcesRoutineInfo(po.MethodName, po.Method);
        }
コード例 #9
0
        public static string GetEqualsOperand(Equals expression, VHDLCompilerInterface compiler)
        {
            string left  = GetOperand(expression.Left, compiler);
            string right = GetOperand(expression.Right, compiler);
            FunctionCallTemplate template = new FunctionCallTemplate(left, "Equals", right);

            return(template.TransformText());
        }
コード例 #10
0
 private void ObserveVariableDeclaration(VHDLCompilerInterface compiler, VariableDeclaration item)
 {
     foreach (VHDL.Object.Variable v in item.Objects)
     {
         VariableDeclarationObserver varObserver = new VariableDeclarationObserver(v, logger);
         varObserver.Observe(compiler);
         declarationText += varObserver.DeclarationText;
     }
 }
コード例 #11
0
        public string GetScheduledEvent(VHDLCompilerInterface compiler, VHDL.WaveformElement wfe)
        {
            string value = VHDLOperandGenerator.GetOperand(wfe.Value, compiler);
            string after = VHDLOperandGenerator.GetOperand(wfe.After, compiler);

            NewStatementTemplate template = new NewStatementTemplate("ScheduledEvent", value, after);

            return(template.TransformText());
        }
コード例 #12
0
        public override void Observe(VHDLCompilerInterface compiler)
        {
            ObserveDeclaration(compiler, process.Declarations);
            ObserveSequentialStatements(compiler, process.Statements);

            ProcessTemplate template = new ProcessTemplate(methodName, declarations, statements);

            method = template.TransformText();
        }
コード例 #13
0
        public static string GenerateFloatingPointSubType(VHDLCompilerInterface compiler, string typeName, RangeSubtypeIndication rangeSubtype)
        {
            string         baseType       = compiler.TypeDictionary[rangeSubtype.BaseType];
            double         rangeLeft      = ((rangeSubtype.Range as VHDL.Range).From as VHDL.literal.RealLiteral).RealValue;
            double         rangeRight     = ((rangeSubtype.Range as VHDL.Range).To as VHDL.literal.RealLiteral).RealValue;
            RangeDirection rangeRirection = ((rangeSubtype.Range as VHDL.Range).Direction == VHDL.Range.RangeDirection.TO) ? RangeDirection.To : RangeDirection.DownTo;

            return(GenerateFloatingPointSubType(compiler, typeName, baseType, rangeLeft, rangeRight, rangeRirection));
        }
コード例 #14
0
        public static string GetPhysicalLiteralOperand(PhysicalLiteral expression, VHDLCompilerInterface compiler)
        {
            string unitName = string.Format("\"{0}\"", expression.Unit);
            Int64  val      = (expression.Value as IntegerLiteral).IntegerValue;
            string physType = compiler.TypeDictionary[expression.GetPhysicalType()];
            NewStatementTemplate template = new NewStatementTemplate(physType, val, unitName);

            return(template.TransformText());
        }
コード例 #15
0
        public override void Observe(VHDLCompilerInterface compiler)
        {
            IList <IPackageDeclarativeItem> declarations = packageDeclaration.Declarations;

            foreach (IPackageDeclarativeItem item in declarations)
            {
                ObservePackageDeclarativeItem(compiler, item);
            }
        }
コード例 #16
0
        public static void FormRange(DiscreteRange range, VHDLCompilerInterface compiler, out string RangeType, out List <string> Parameters)
        {
            if (range is Range)
            {
                FormIntegerRange(range as Range, compiler, out RangeType, out Parameters);
                return;
            }

            throw new NotImplementedException();
        }
コード例 #17
0
        private void ObservePackageDeclarativeItem(VHDLCompilerInterface compiler, IPackageDeclarativeItem item)
        {
            if (item is VHDL.type.Type)
            {
                ObserveTypeDeclaration(compiler, item as VHDL.type.Type);
            }

            if (item is Subtype)
            {
                ObserveSubTypeDeclaration(compiler, item as Subtype);
            }
        }
コード例 #18
0
 public void ObserveDeclaration(VHDLCompilerInterface compiler, IList <IProcessDeclarativeItem> items)
 {
     foreach (IProcessDeclarativeItem i in items)
     {
         ProcessDeclarationObserver blockObserver = new ProcessDeclarationObserver(i, logger);
         blockObserver.Observe(compiler);
         if (string.IsNullOrEmpty(blockObserver.DeclarationText) == false)
         {
             declarations.Add(blockObserver.DeclarationText);
         }
     }
 }
コード例 #19
0
 public void ObserveSequentialStatements(VHDLCompilerInterface compiler, IList <SequentialStatement> statements)
 {
     methodName = process.Label;
     foreach (SequentialStatement statement in statements)
     {
         SequentialStatementObserver stObserver = new SequentialStatementObserver(statement, logger);
         stObserver.Observe(compiler);
         if (string.IsNullOrEmpty(stObserver.Code) == false)
         {
             this.statements.Add(stObserver.Code);
         }
     }
 }
コード例 #20
0
        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);
        }
コード例 #21
0
        private IfTemplateElsifStatement GetElsifObject(VHDLCompilerInterface compiler, IfStatement.ElsifPart elsif)
        {
            string        condition  = VHDLOperandGenerator.GetOperand(elsif.Condition, compiler);
            List <string> statements = new List <string>();

            foreach (var st in elsif.Statements)
            {
                statements.Add(GetSequentialCode(compiler, st));
            }
            IfTemplateElsifStatement res = new IfTemplateElsifStatement(condition, statements);

            return(res);
        }
コード例 #22
0
        public override void Observe(VHDLCompilerInterface compiler)
        {
            if (statement is ReportStatement)
            {
                ObserveReportStatement(compiler, statement as ReportStatement);
                return;
            }

            if (statement is VariableAssignment)
            {
                ObserveVariableAssignmentStatement(compiler, statement as VariableAssignment);
                return;
            }

            if (statement is SignalAssignment)
            {
                ObserveSignalAssignmentStatement(compiler, statement as SignalAssignment);
                return;
            }

            if (statement is IfStatement)
            {
                ObserveIfStatement(compiler, statement as IfStatement);
                return;
            }

            if (statement is ForStatement)
            {
                ObserveForStatement(compiler, statement as ForStatement);
                return;
            }

            if (statement is WhileStatement)
            {
                ObserveWhileStatement(compiler, statement as WhileStatement);
                return;
            }

            if (statement is LoopStatement)
            {
                ObserveLoopStatement(compiler, statement as LoopStatement);
                return;
            }

            if (statement is WaitStatement)
            {
                return;
            }

            throw new NotImplementedException();
        }
コード例 #23
0
        public static string GenerateIntegerSubType(VHDLCompilerInterface compiler, string typeName, RangeSubtypeIndication rangeSubtype)
        {
            string         baseType       = compiler.TypeDictionary[rangeSubtype.BaseType];
            Int64          rangeLeft      = ((rangeSubtype.Range as VHDL.Range).From as VHDL.literal.IntegerLiteral).IntegerValue;
            Int64          rangeRight     = ((rangeSubtype.Range as VHDL.Range).To as VHDL.literal.IntegerLiteral).IntegerValue;
            RangeDirection rangeRirection = ((rangeSubtype.Range as VHDL.Range).Direction == VHDL.Range.RangeDirection.TO) ? RangeDirection.To : RangeDirection.DownTo;

            IntegerSubTypeTemplate template = new IntegerSubTypeTemplate(typeName, baseType, rangeLeft, rangeRight, rangeRirection);
            string code = template.TransformText();

            //compiler.TypeRangeDictionary.AddItem(rangeSubtype, "IntegerRange", template.RangeLeft, template.RangeRight, template.Direction);

            return(code);
        }
コード例 #24
0
        public static string GenerateIntegerType(VHDLCompilerInterface compiler, VHDL.type.IntegerType typeDeclaration)
        {
            string         typeName       = typeDeclaration.Identifier;
            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 rangeRirection = ((typeDeclaration.Range as VHDL.Range).Direction == VHDL.Range.RangeDirection.TO) ? RangeDirection.To : RangeDirection.DownTo;

            IntegerTypeTemplate template = new IntegerTypeTemplate(typeName, rangeLeft, rangeRight, rangeRirection);
            string text = template.TransformText();

            compiler.TypeRangeDictionary.AddItem(typeDeclaration, "IntegerRange", template.RangeLeft, template.RangeRight, template.Direction);

            return(text);
        }
コード例 #25
0
 private void ObserveSignalDeclaration(VHDLCompilerInterface compiler, SignalDeclaration item)
 {
     if (item.Objects.Count != 0)
     {
         signalNames = new List <string>();
         foreach (VHDL.Object.Signal v in item.Objects)
         {
             SignalDeclarationObserver varObserver = new SignalDeclarationObserver(v, logger);
             varObserver.Observe(compiler);
             declarationText += varObserver.DeclarationText;
             signalNames.Add(v.Identifier);
         }
     }
 }
コード例 #26
0
        public static void FormIntegerRange(Range range, VHDLCompilerInterface compiler, out string RangeType, out List <string> Parameters)
        {
            string opFrom = VHDLOperandGenerator.GetOperand(range.From, compiler);
            string opTo   = VHDLOperandGenerator.GetOperand(range.To, compiler);

            VHDLRuntime.Range.RangeDirection dir = ((range.Direction == Range.RangeDirection.TO) ? VHDLRuntime.Range.RangeDirection.To : VHDLRuntime.Range.RangeDirection.DownTo);
            string dir_s = string.Format("RangeDirection.{0}", dir);

            RangeType  = "IntegerRange";
            Parameters = new List <string>()
            {
                opFrom, opTo, dir_s
            };
        }
コード例 #27
0
        public void ObserveVariableAssignmentStatement(VHDLCompilerInterface compiler, VariableAssignment statement)
        {
            IVariableAssignmentTarget interpretedTarget = statement.Target;

            if (interpretedTarget is Expression)
            {
                string target     = VHDLOperandGenerator.GetOperand(interpretedTarget as Expression, compiler, false);
                string targetType = VHDLExpressionTypeGenerator.GetExpressionType(interpretedTarget as Expression, compiler);
                string value      = VHDLOperandGenerator.GetOperand(statement.Value, compiler);

                VariableAssignTemplate template = new VariableAssignTemplate(target, value, targetType);
                code = template.TransformText();
                return;
            }
        }
コード例 #28
0
        public void ObserveWhileStatement(VHDLCompilerInterface compiler, WhileStatement statement)
        {
            string Condition = VHDLOperandGenerator.GetOperand(statement.Condition, compiler);

            List <string> Statements = new List <string>();

            foreach (var st in statement.Statements)
            {
                Statements.Add(GetSequentialCode(compiler, st));
            }

            WhileTemplate template = new WhileTemplate(Condition, Statements);

            code = template.TransformText();
        }
コード例 #29
0
        public static string GenerateEnumerationType(VHDLCompilerInterface compiler, VHDL.type.EnumerationType typeDeclaration)
        {
            string typeName     = typeDeclaration.Identifier;
            string enumTypeName = string.Format("{0}_Enum", typeDeclaration.Identifier);

            List <EnumBaseTypeInfo> parameters = FormEnumDictionary(typeDeclaration);
            EnumTypeTemplate        template   = new EnumTypeTemplate(typeName, parameters);
            string text = template.TransformText();

            foreach (EnumBaseTypeInfo i in parameters)
            {
                compiler.LiteralDictionary.AddItem(i, string.Format("{0}.{1}", enumTypeName, i.FieldName));
            }
            compiler.TypeRangeDictionary.AddItem(typeDeclaration, string.Format("EnumRange<{0}>", enumTypeName), string.Format("{0}.{1}", enumTypeName, parameters[0].FieldName), string.Format("{0}.{1}", enumTypeName, parameters[parameters.Count - 1].FieldName), "RangeDirection.To");

            return(text);
        }
コード例 #30
0
        public static string GetObjectOperand(VHDL.Object.VhdlObject expression, VHDLCompilerInterface compiler, bool GenerateGetOperandFunction = true)
        {
            string valueProviderName = compiler.ObjectDictionary[expression];

            if (string.IsNullOrEmpty(valueProviderName))
            {
                return(expression.Identifier);
            }
            else
            {
                if (GenerateGetOperandFunction)
                {
                    valueProviderName = GetValueFunctionCall(valueProviderName);
                }
                return(valueProviderName);
            }
        }