//--------------------------------------------------------------------------------------- //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); } }
/// <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; }
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); }
/// <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) { }
/// <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; }
/// <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; }
/// <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; }
/// <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)) { }
/// <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; }
/// <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; }
//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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
/// <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; }
public DefaultVhdlObject(string identifier, SubtypeIndication type) { this.identifier = identifier; this.type = type; this.mode = ModeEnum.NONE; }
/// <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; }
/// <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; }