Exemple #1
0
 protected override void visitAttributeSpecification(AttributeSpecification specification)
 {
     writer.Append(KeywordEnum.ATTRIBUTE.ToString()).Append(' ');
     writer.AppendIdentifier(specification.Attribute).Append(' ');
     writer.Append(KeywordEnum.OF.ToString()).Append(' ');
     AttributeSpecification.EntityNameList entityNames = specification.Entities;
     if (entityNames == AttributeSpecification.EntityNameList.ALL)
     {
         writer.Append(KeywordEnum.ALL.ToString());
     }
     else if (entityNames == AttributeSpecification.EntityNameList.OTHERS)
     {
         writer.Append(KeywordEnum.OTHERS.ToString());
     }
     else
     {
         bool first = true;
         foreach (AttributeSpecification.EntityNameList.EntityDesignator designator in entityNames.Designators)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 writer.Append(", ");
             }
             appendEntityDesignator(designator);
         }
     }
     writer.Append(" : ").Append(specification.EntityClass.ToString()).Append(' ');
     writer.Append(KeywordEnum.IS.ToString()).Append(' ');
     output.writeExpression(specification.Value);
     writer.Append(';').NewLine();
 }
 public static void constantInterfaceSuffix(Constant constant, VhdlWriter writer, OutputModule output)
 {
     output.writeSubtypeIndication(constant.Type);
     if (constant.DefaultValue != null)
     {
         writer.Append(" := ");
         output.writeExpression(constant.DefaultValue);
     }
 }
 //TODO: add mode
 public static void variableInterfaceSuffix(Variable variable, VhdlWriter writer, OutputModule output)
 {
     output.writeSubtypeIndication(variable.Type);
     if (variable.DefaultValue != null)
     {
         writer.Append(" := ");
         output.writeExpression(variable.DefaultValue);
     }
 }
        protected override void visitBlockStatement(BlockStatement statement)
        {
            appendLabel(statement);
            writer.Append(KeywordEnum.BLOCK.ToString());
            if (statement.GuardExpression != null)
            {
                writer.Append("(");
                output.writeExpression(statement.GuardExpression);
                writer.Append(")");
            }

            OptionalIsFormat format = Annotations.getAnnotation <OptionalIsFormat>(statement);

            if (format != null && format.UseIs)
            {
                writer.Append(' ').Append(KeywordEnum.IS.ToString());
            }

            writer.NewLine().Indent();
            if (statement.Generic.Count != 0)
            {
                output.getMiscellaneousElementOutput().generic(statement.Generic);
                if (statement.GenericMap.Count != 0)
                {
                    writer.Append(KeywordEnum.GENERIC.ToString()).Append(KeywordEnum.MAP.ToString()).Append(" (").NewLine();
                    writer.Indent().BeginAlign();
                    output.getMiscellaneousElementOutput().genericMap(statement.GenericMap);
                    writer.EndAlign().Dedent();
                    writer.Append(");").NewLine();
                }
            }

            if (statement.Port.Count != 0)
            {
                output.getMiscellaneousElementOutput().port(statement.Port);
                if (statement.PortMap.Count != 0)
                {
                    writer.Append(KeywordEnum.PORT.ToString()).Append(KeywordEnum.MAP.ToString()).Append(" (").NewLine();
                    writer.Indent().BeginAlign();
                    output.getMiscellaneousElementOutput().portMap(statement.PortMap);
                    writer.EndAlign().Dedent();
                    writer.Append(");").NewLine();
                }
            }

            output.writeDeclarationMarkers(statement.Declarations);
            writer.Dedent().Append(KeywordEnum.BEGIN.ToString()).NewLine();
            writer.Indent();
            visit(statement.Statements);
            writer.Dedent();
            writer.Append(KeywordEnum.END.ToString()).Append(KeywordEnum.BLOCK.ToString());
            if (writer.Format.RepeatLabels)
            {
                writer.Append(' ').Append(statement.Label);
            }
            writer.Append(";").NewLine();
        }
 public void delayMechanism(DelayMechanism delayMechanism)
 {
     if (delayMechanism == DelayMechanism.INERTIAL)
     {
         writer.Append(KeywordEnum.INERTIAL.ToString());
     }
     else if (delayMechanism == DelayMechanism.TRANSPORT)
     {
         writer.Append(KeywordEnum.TRANSPORT.ToString());
     }
     else
     {
         writer.Append(KeywordEnum.REJECT.ToString()).Append(' ');
         output.writeExpression(delayMechanism.PulseRejectionLimit);
         writer.Append(' ').Append(KeywordEnum.INERTIAL.ToString());
     }
 }
        //TODO: write BUS keyword
        public static void signalInterfaceSuffix(Signal signal, VhdlWriter writer, OutputModule output)
        {
            output.writeSubtypeIndication(signal.Type);

            if (signal.Kind == Signal.KindEnum.BUS)
            {
                writer.Append(' ').Append(signal.Kind.ToString());
            }
            else if (signal.Kind == Signal.KindEnum.REGISTER)
            {
                throw new Exception("Signal kind register isn't allowed in an interface declaration");
            }

            if (signal.DefaultValue != null)
            {
                writer.Append(" := ");
                output.writeExpression(signal.DefaultValue);
            }
        }
        protected override void visitPhysicalType(PhysicalType type)
        {
            //TODO: implement repeated label
            appendTypePrefix(type);
            writer.Append(' ').Append(KeywordEnum.RANGE.ToString()).Append(' ');
            output.writeDiscreteRange(type.Range);
            writer.Append(' ').NewLine();
            writer.Indent().Append(KeywordEnum.UNITS.ToString()).NewLine();
            writer.Indent().Append(type.PrimaryUnit).Append(';').NewLine().BeginAlign();
            foreach (PhysicalType.Unit unit in type.Units)
            {
                writer.AppendIdentifier(unit).Align().Append(" = ");
                if (unit.Factor != null)
                {
                    output.writeExpression(unit.Factor);
                    writer.Append(' ');
                }
                writer.Append(unit.BaseUnit).Append(';').NewLine();
            }
            writer.EndAlign().Dedent();

            writer.Append(KeywordEnum.END.ToString()).Append(KeywordEnum.UNITS.ToString()).Append(';').Dedent().NewLine();
        }
Exemple #8
0
        public void visit(IndexedName name)
        {
            output.writeExpression(name.Prefix);
            writer.Append('(');
            bool first = true;

            foreach (Expression index in name.Indices)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.Append(", ");
                }
                output.writeExpression(index);
            }
            writer.Append(')');
        }
Exemple #9
0
        private void appendExitOrNextStatement(SequentialStatement statement, KeywordEnum keyword, LoopStatement loop, Expression condition)
        {
            appendLabel(statement);
            writer.Append(keyword.ToString());
            if (loop != null)
            {
                string label = loop.Label;

                if (label == null)
                {
                    //FIXME: unify handling of null values
                    throw new ArgumentNullException("Loop label is null");
                }

                writer.Append(' ').Append(label);
            }
            if (condition != null)
            {
                writer.Append(' ').Append(KeywordEnum.WHEN.ToString()).Append(' ');
                output.writeExpression(condition);
            }
            writer.Append(';').NewLine();
        }