Mobile
VHDL Online Help Prev Page Prev Page
Table of Contents
Access Type
Aggregate
Alias
Allocator
Architecture
Array
Assertion Statement
Attributes (predefined)
Attributes (user-defined)
Bit
Bit_Vector
Block Statement
Boolean
Case Statement
Character Type
Component Declaration
Component Instantiation
Composite Type
Concatenation
Configuration Declaration
Configuration Specification
Constant
Delay
Driver
Entity
Enumeration Type
Event
Exit Statement
Expression
File Declaration
File Type
Floating Point Type
Function
Generate Statement
Generic
Group
Guard
Identifier
If Statement
Integer Type
Library Clause
Literal
Loop Statement
Name
Next Statement
Null Statement
Operator Overloading
Operators
Package
Package Body
Physical Type
Port
Procedure
Process Statement
Range
Record Type
Report Statement
Reserved Word
Resolution Function
Resume
Return Statement
Scalar Type
Sensitivity List
Signal Assignment
Signal Declaration
Slice
Standard Package
Std_Logic
Std_Logic_1164 Package
Std_Logic_Vector
String
Subtype
Suspend
Testbench
Type
Type Conversion
Use Clause
Variable Assignment
Variable Declaration
Vector
VITAL
Wait Statement
Waveform

String

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.

Syntax:

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

Description

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.

Examples

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)

 

Powered by IXwebhosting