Featured post

Top 5 books to refer for a VHDL beginner

VHDL (VHSIC-HDL, Very High-Speed Integrated Circuit Hardware Description Language) is a hardware description language used in electronic des...

Tuesday 18 December 2012


Formal Definition

The string type is predefined in the package Standard as a standard one-dimensional array type with each element being of the type Character.


type String is array (positive range <>) of character;


The type string is an unconstrained vector of elements of the type Character. The size of a particular vector must be specified during its declaration (see example). The way the vector elements are indexed depends on the defined range - either ascending or descending (see range).

Assignment to an object of the type string can be performed in the same way as in case of any arrays, i.e. using single element assignments, concatenation, aggregates, slices or any combination of them.

The package Standard contains declarations of the predefined operators for the type String: "=", "/=", "<", "<=", ">", ">=" and "&". Relational operators allow to compare two strings, while the concatenation operator allows to concatenate two strings, a string and a character and two characters to create a string.


Example 1

constant Message1 : String(1 to 19) := "hold time violation";
signal Letter1 : character;
signal Message2 : string(1 to 10);
. . .
Message2 <= "Not" & Letter1;

Important Notes

· Unlike Bit_Vector, where the value of index is of the type Natural (from 0 up to maximum Integer), the index of String has a POSITIVE value, being an integer greater than 0. It would be an error, then, to declare a String with a range with zero as one of the boundary values.

· Strings are written in double quotes. Single elements, however, are of the type character, therefore values assigned to single elements (referred by the index) are specified in single quotes.

· Strings play supplementary role for system modeling as they do not reflect any particular feature of hardware. They are used mostly for issuing messages during simulation (see assertion statement)

No comments:

Post a Comment

Please provide valuable comments and suggestions for our motivation. Feel free to write down any query if you have regarding this post.