I read your code, and couldn't help playing VHDL lawyer. Your patch appears to
relate to what is a string representation of the value of something declared as
type BIT.
From 14.1 (VHDL-93):
(In applicable semantics for attributes in this case are marked by
strikethroughs. Additional white space is added for emphasis. Bold emphasis is
added to bring the reader's attention to various semantic requirements.)
T'VALUE(X)
Kind: Function.
Prefix: Any scalar type or subtype T.
Parameter: An expression of type String.
Result Type: The base type of T.
Result: The value of T whose string representation (as defined in Section 13)
is given by the parameter. Leading and trailing whitespace is allowed and
ignored.
If T is a numeric type or subtype, the parameter may be expressed either as a
decimal literal or as a based literal.
If T is a physical type or subtype, the parameter may be expressed using a
string representation of any of the unit names of T, with or without a leading
abstract literal. The parameter must have whitespace between any abstract
literal and the unit name. The replacement characters of 13.10 are allowed in
the parameter.
Restrictions: It is an error if the parameter is not a valid string
representation of a literal of type T or if the result does not belong to the
subtype implied by T.
From the Glossary, Annex B, VHDL-93:
B.211 scalar type: A type whose values have no elements. Scalar types consist
of enumeration types, integer types, physical types, and floating point types.
Enumeration types and integer types are called discrete types. Integer types,
floating point types,and physical types are called numeric types. All scalar
types are ordered; that is, all relational operators are predefined for their
values.(§3, § 3.1 )
B.84 enumeration literal: A literal of an enumeration type. An enumeration
literal may be either an identifier or a character literal.(§ 3.1.1 , § 7.3.1 )
B.85 enumeration type: A type whose values are defined by listing(enumerating)
them. The values of the type are represented by enumeration literals. (§ 3.1 ,
§ 3.1.1 )
From 14.2, Package STANDARD (VHDL-93):
type BIT is ('0', '1');
BIT is an enumeration type with two values. The string representations of a
literal of type BIT can be determined by using the T'IMAGE(X) attribute
(BIT'IMAGE('0') and BIT'IMAGE('1')).
This brings up the question of whether or not character literals for the two
values are "a valid string representation of a literal of type T (BIT)" when
using T'VALUE(X). This is supported by examining the preceding and mirror
attribute T'IMAGE(X).
Clearly '0' and '1' (three character sequences) are valid string
representations. NUL and SOH are not, however being enumeration literals for
type CHARACTER (14.2). Further we know that while numeric types are all
considered closely related for purposes of type conversion while enumerated
types are not (See VHDL-93 7.3.5, Type conversions, in particular "No other
types are closely related.").
The way to perform type conversion to allow the intended use is through the use
of the T'POS(X) and T'VAL(X) attributes (14.2). Where the index value in one
type can be extracted with 'POS and used to determine the value in the other
with 'VAL.
You appear to be mistaking positional number ( See T'POS(X), 14.2) for
enumeration value. I'm of the opinion that your patch is not IEEE Std
1076-1993 standard compliant.
String representations of literal expressions are elaborated in 5.7 in IEEE Std
1076-2008, which also notes "In each case where a string representation is
defined, the index range of the string representation is not specified by this
standard". The string representation rules for T'IMAGE(X) (See 16.2) remain
unchanged.
In other words the current version of the VHDL standard is still conforming to
the specification found in VHDL-93. No implicit CHARACTER to BIT type
conversion.
From 14.1 (VHDL-93):
T'IMAGE(X)
Kind:Function.
Prefix:Any scalar type or subtype T.
Parameter:An expression whose type is the base type of T.
Result Type:Type String.
Result:The string representation of the parameter value, without leading or
trailing whitespace.
If T is an enumeration type or subtype and the parameter value is either an
extended identifier or a character literal, the result is expressed with both a
leading and trailing reverse solidus (backslash) (in the case of an extended
identifier) or apostrophe (in the case of a character literal); in the case of
an extended identifier that has a backslash, the backslash is doubled in the
string representation.
If T is an enumeration type or subtype and the parameter value is a basic
identifier, then the result is expressed in lowercase characters.
If T is a numeric type or subtype, the result is expressed as the decimal
representation of the parameter value without underlines or leading or trailing
zeros (except as necessary to form the image of a legal literal with the proper
value); moreover, an exponent may (but is not required to) be present and the
language does not define under what conditions it is or is not present. If the
exponent is present, the "e" is expressed as a lowercase character.
If T is a physical type or subtype, the result is expressed in terms of the
primary unit of T unless the base type of T is TIME, in which case the result
is expressed in terms of the resolution limit(see 3.1.3.1 ); in either case, if
the unit is a basic identifier, the image of the unit is expressed in lowercase
characters.
If T is a floating point type or type, the number of digits to the right of the
decimal point corresponds to the standard form generated when the DIGITS
parameter to TextIO. Write for type REAL is set to 0 (see 14.3 ). The result
never contains the replacement characters described in 13.10 .
Restrictions:It is an error if the parameter value does not belong to the
subtype implied by the prefix.
_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss