|
VHDL Tutorial |
Characters and strings in VHDL | ||
|
Introduction Fundamental concepts Modelling concepts Elements of behaviour Elements of structure Analysis elaboration Lexical elements Identifiers Numbers Characters and strings Syntax descriptions Constants and variables Scalar type Integer types Floating point types Time type Enumeration types Character types Boolean type Bits type Standard logic Sequential statements Case statements Loop and exit statements Assertion statements Array types & array operations Architecture bodies Entity declarations Behavioral descriptions Wait statements Delta delays Process statements Conditional signal assignment Selected signal assigment Structural descriptions Library and library clauses Procedures Procedure parameters Signal parameters Default values Unconstrained array parameter Functions Package declarations and bodies Subprograms in package Use clauses Resolved signals and subtypes Resolved signals and ports Parameterizing behavior Parameterizing structure
|
. Characters
A character literal can be written in VHDL code by enclosing it in single quotation marks. Any of the printable characters in the standard character set (including a space character) can be written in this way. Some examples are
'A' – – uppercase letter 'z' – – lowercase letter ',' – – the punctuation character comma ''' – – the punctuation character single quote ' ' – – the separator character space
Strings
Want To have highly paid VLSI jobs ?? then you may contact at
Contact : webmaster@freehost7com
A string literal represents a sequence of characters and is written by enclosing the characters in double quotation marks. The string may include any number of charac- ters (including zero), but it must fit entirely on one line. Some examples are
"A string" "We can include any printing characters (e.g., &%@^*) in a string!!" "00001111ZZZZ" "" – – empty string
If we need to include a double quotation mark character in a string, we write two double quotation mark characters together. The pair is interpreted as just one char- acter in the string. For example:
"A string in a string: ""A string"". "
If we need to write a string that is longer than will fit on one line, we can use the concatenation operator (“&”) to join two substrings together. For example:
"If a string will not fit on one line, " & "then we can break it into parts on separate lines."
Bit Strings
VHDL includes values that represent bits (binary digits), which can be either ‘0’ or ‘1’. A bit-string literal represents a sequence of these bit values. It is represented by a string of digits, enclosed by double quotation marks and preceded by a character that specifies the base of the digits. The base specifier can be one of the following:
• B for binary,
• O for octal (base 8) and
• X for hexadecimal (base 16).
For example, some bitstring literals specified in binary are
B"0100011" B"10" b"1111_0010_0001" B""
Notice that we can include underline characters in bit-string literals to make the literal more readable. The base specifier can be in uppercase or lowercase. The last of the examples above denotes an empty bit string. If the base specifier is octal, the digits ‘0’ through ‘7’ can be used. Each digit rep- resents exactly three bits in the sequence. Some examples are
O"372" – – equivalent to B"011_111_010" o"00" – – equivalent to B"000_000"
If the base specifier is hexadecimal, the digits ‘0’ through ‘9’ and ‘A’ through ‘F’ or ‘a’ through ‘f’ (representing 10 through 15) can be used. In hexadecimal, each digit represents exactly four bits. Some examples are
X"FA" – – equivalent to B"1111_1010" x"0d" – – equivalent to B"0000_1101"
|