Exemplo n.º 1
0
        //---------------------------------------------------------------------------------------
        //Subtype Indication parsing 27 - Apr - 2019

        SubtypeIndication ParseSubtypeIndication()
        {
            //SubTypeIndication: [ resolution_function_name ] type_mark [ constraint ]
            // $type($upper downto $lower) || $type range $lower to $upper
            string type = fCurrentToken.Value;

            ReadNextToken();
            //Either type X downto Y
            if (fCurrentToken.Equals(TokenType.Symbol, "("))
            {
                ReadNextToken();                  //Skip parenthesis since its only opening parenthesis.
                Node left = ParseExpression();
                fCurrentToken = fLexicalAnalyser.SkipExpected(TokenType.Word, "downto");
                Node right = ParseExpression();
                SubtypeIndication ParsedSubtype = new SubtypeIndication(type, left.Eval(), right.Eval());
                return(ParsedSubtype);
            }
            //Else range Y to X
            else
            {
                fCurrentToken = fLexicalAnalyser.SkipExpected(TokenType.Word, "range");
                Node left = ParseExpression();
                fCurrentToken = fLexicalAnalyser.SkipExpected(TokenType.Word, "to");
                Node right     = ParseExpression();
                var  bitsRight = Math.Log((right.Eval() + 1), 2);
                var  bitsLeft  = Math.Log((left.Eval() + 1), 2);
                SubtypeIndication ParsedSubtype = new SubtypeIndication(type, (int)Math.Ceiling(bitsLeft), 31);

                return(ParsedSubtype);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a signal with a mode and a default value.
 /// </summary>
 /// <param name="identifier">the identifier of the signal</param>
 /// <param name="mode">the mode of the signal</param>
 /// <param name="type">the type of the signal</param>
 /// <param name="defaultValue">the default value of the signal</param>
 public Signal(string identifier, ModeEnum mode, SubtypeIndication type, Expression defaultValue)
     : base(identifier, type)
 {
     this.defaultValue = defaultValue;
     Mode = mode;
     kind = KindEnum.DEFAULT;
 }
Exemplo n.º 3
0
        SubtypeDeclaration ParseSubtypeDeclaration()
        {
            ReadNextToken();              //skip subtype
            string identifier = fCurrentToken.Value;

            ReadNextToken();              //skip identifier
            fCurrentToken = fLexicalAnalyser.SkipExpected(TokenType.Word, "is");

            SubtypeIndication subtype = ParseSubtypeIndication();

            //Read until end of line
            fCurrentToken = fLexicalAnalyser.SkipExpected(TokenType.Symbol, ";");

            SubtypeDeclaration ParsedSubtype = new SubtypeDeclaration(identifier, subtype);

            SubtypeList.Add(ParsedSubtype);

            return(ParsedSubtype);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a file.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="type">the type</param>
 public FileObject(string identifier, SubtypeIndication type)
     : base(identifier, type)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a file.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="type">the type</param>
 /// <param name="logicalName">the logical name</param>
 public FileObject(string identifier, SubtypeIndication type, Expression logicalName)
     : base(identifier, type)
 {
     this.logicalName = logicalName;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a constant with a default value.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="type">the type</param>
 /// <param name="defaultValue">the default value</param>
 public Constant(string identifier, SubtypeIndication type, Expression defaultValue) : base(identifier, type)
 {
     this.defaultValue = defaultValue;
     Mode = ModeEnum.IN;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates a constant.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="type">the type</param>
 public Constant(string identifier, SubtypeIndication type) : base(identifier, type)
 {
     Mode = ModeEnum.IN;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a qualified expression.
 /// </summary>
 /// <param name="type">the type</param>
 /// <param name="operand">the operand</param>
 public QualifiedExpression(SubtypeIndication type, Expression operand) : this(type, new Aggregate(operand))
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a function declaration.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="returnType">the return type</param>
 /// <param name="parameters">the parameters</param>
 public FunctionDeclaration(string identifier, SubtypeIndication returnType, List <VhdlObjectProvider> parameters)
     : base(identifier, parameters)
 {
     this.returnType = returnType;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates a attribute declartion.
 /// </summary>
 /// <param name="identifier">the identifer</param>
 /// <param name="type">the type of this attribtue</param>
 public Attribute(string identifier, SubtypeIndication type)
 {
     this.identifier = identifier;
     this.type       = type;
 }
Exemplo n.º 11
0
 //TODO: link function body to declaration
 /// <summary>
 /// Creates a function body based on a function declaration.
 /// </summary>
 /// <param name="declaration">the base function declaration</param>
 public FunctionBody(FunctionDeclaration declaration)
     : base(declaration)
 {
     this.returnType = declaration.ReturnType;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Creates a function body.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="returnType">the return type</param>
 /// <param name="parameters">the parameters</param>
 public FunctionBody(string identifier, SubtypeIndication returnType, params VhdlObjectProvider[] parameters)
     : base(identifier, parameters)
 {
     this.returnType = returnType;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Creates a disconnection specification.
 /// </summary>
 /// <param name="signals">a list of guarded signals</param>
 /// <param name="type">the type of the signals</param>
 /// <param name="after">the disconnection delay</param>
 public DisconnectionSpecification(SignalList signals, SubtypeIndication type, Expression after)
 {
     this.signals = signals;
     this.type    = type;
     this.after   = after;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a signal with a mode.
 /// </summary>
 /// <param name="identifier">the identifier of the signal</param>
 /// <param name="mode">the mode of the signal</param>
 /// <param name="type">the type of the signal</param>
 public Signal(string identifier, ModeEnum mode, SubtypeIndication type)
     : base(identifier, type)
 {
     Mode = mode;
     kind = KindEnum.DEFAULT;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates an alias declartion.
 /// </summary>
 /// <param name="designator">the alias designator</param>
 /// <param name="subtypeIndication">the subtype indication</param>
 public Alias(string designator, SubtypeIndication subtypeIndication)
 {
     this.designator        = designator;
     this.subtypeIndication = subtypeIndication;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a variable.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="type">the type</param>
 public Variable(string identifier, SubtypeIndication type) : base(identifier, type)
 {
     Mode = ModeEnum.IN;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Creates an alias declaration.
 /// </summary>
 /// <param name="designator">the alias designator</param>
 /// <param name="subtypeIndication">the subtype indication</param>
 /// <param name="aliased">the identifier of the aliased object</param>
 public Alias(string designator, SubtypeIndication subtypeIndication, Name aliased)
 {
     this.designator        = designator;
     this.subtypeIndication = subtypeIndication;
     this.aliased           = aliased;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Creates a variable with a default value.
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="type">the type</param>
 /// <param name="defaultValue">the default value</param>
 public Variable(string identifier, SubtypeIndication type, Expression defaultValue) : this(identifier, type)
 {
     this.defaultValue = defaultValue;
 }
 /// <summary>
 /// Creates a subtype indication allocator.
 /// </summary>
 /// <param name="type"></param>
 public SubtypeIndicationAllocator(SubtypeIndication type)
 {
     this.type = type;
 }
Exemplo n.º 20
0
 public DefaultVhdlObject(string identifier, SubtypeIndication type)
 {
     this.identifier = identifier;
     this.type       = type;
     this.mode       = ModeEnum.NONE;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a subtype declaration.
 /// </summary>
 /// <param name="identifier">the identifier of this subtype declaration</param>
 /// <param name="subtypeIndication">the subtype indication</param>
 public Subtype(string identifier, SubtypeIndication subtypeIndication)
 {
     this.identifier        = identifier;
     this.subtypeIndication = subtypeIndication;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Creates a qualified expression.
 /// </summary>
 /// <param name="type">the type</param>
 /// <param name="operand">the operand</param>
 public QualifiedExpression(SubtypeIndication type, Aggregate operand)
 {
     this.type    = type;
     this.operand = operand;
 }