## Pages

### Literal

#### Formal Definition

A value that is directly specified in a description of a design.

#### Full Syntax:

literal ::= numeric_literal

| enumeration_literal

| string_literal

| bit_string_literal

| null

numeric_literal ::= abstract_literal | physical_literal

abstract_literal ::= decimal_literal | based_literal

decimal_literal ::= integer [ . integer ] [ exponent ]

integer ::= digit { [ underline ] digit }

exponent ::= E [ + ] integer | E - integer

based_literal ::= base # based_integer [ . based_integer ] # [ exponent ]

base ::= integer

based_integer ::= extended_digit { [underline] extended_digit }

extended_digit ::= digit | letter

physical_literal ::= [ abstract_literal ] unit_name

enumeration_literal ::= identifier | character_literal

character_literal ::= ' graphic_character '

string_literal ::= " { graphic_character } "

bit_string_literal ::= base_specifier " bit_value "

base_specifier ::= B | O | X

bit_value ::= extended_digit { [ underline ] extended_digit }

#### Description

There are five classes of literals: numeric literals, enumeration literals, string literals, bit string literals and the literal null.

###### Numeric literals

The class of numeric literals includes abstract literals (which include integer literals and real literals) and physical literals.

The difference between integer and real literals lies in the decimal point: a real literal includes a decimal point, while an integer literal does not. When a real or integer literal is written in the conventional decimal notation it is called a decimal literal. Example 1 presents several abstract literals - both integer and real.

If a number is written in the exponential form, the letter E of the exponent can be written either in lowercase or in uppercase. If the exponential form is used for an integer number then zero exponent is allowed.

Abstract literals can be written in the form of based literals as well. In such a case the base is specified explicitly (in decimal literals the base is implicitly ten). The base in based literal must be at least two and at most sixteen. The base is specified in decimal notation.

The digits used in based literals can be any decimal digits (0..9) or a letter (either in upper or lower case). The meaning of based notation is as in decimal literals, with the exception of base. Several based literals are presented in Example 1.

A Physical literal consists of an abstract numeric literal followed by an identifier that denotes the unit of the given physical quantity (example 1).

###### Enumeration literals

The enumeration literals are literals of enumeration types, used in type declaration and in expressions evaluating to a value of an enumeration type. They include identifiers and character literals. Reserved words may not be used in identifiers, unless they are a part of extended identifiers which start and end with a backslash. See identifiers for more information on identifiers. Example 2 presents several enumeration literals.

###### String Literals

String literals are composed as a sequence of graphic characters (letters, digits, special characters) enclosed between two quotation marks (double quotes). They are usually used for warnings or reports which are displayed during simulation (example 3).

###### Bit string literals

Bit string literals represent values of string literals that denote sequences of extended digits, range of which depends on the specified base.

The base specifier determines the base of the digits: letter B used as a base specifier denotes binary digits (0 or 1), letter O - octal digits (0 to 7) and letter X - hexadecimal (digits 0 to 9 and letters A to F, case insensitive). Underlines can be used to increase readability and have no impact on the value.

All values specified as bit string literals are converted into binary representation without underlines. Binary strings remain unchanged (only underlines are removed), each octal digit is converted into three bits and each hexadecimal into four bits (example 4).

#### Examples

Example 1

-- Decimal literals:
14
7755
156E7
188.993
88_670_551.453_909
44.99E-22
-- Based literals:
16#FE# -- 254
2#1111_1110# -- 254
8#376# -- 254
16#D#E1 -- 208
16#F.01#E+2 -- 3841.00
2#10.1111_0001#E8 -- 1506.00
-- Physical literals:
60 sec
100 m
kohm
177 A

Abstract literals written in different forms: as decimal, based and physical literals.

Example 2

State0 Idle
TEST \test\
\out\ \OUT\

This example presents several enumeration literals. Note that such literals are not specified in double quotes. Out is a reserved word and as such cannot be used as an identifier (enumeration literal). It may be, however, a part of an extended literal. Extended literals are case sensitive; therefore, \out\ and \OUT\ are different literals.

Example 3

"ERROR"
"Both S and Q equal to 1"
"X"
"BB\$CC"
"{LOW}"
"Quotation: ""REPORT..."""

A string literal may contain any number of characters (including special characters), as long as it fits on one line. It can also be a null string or a one-character long string. If a quotation sign has to be used in a string literal, it is denoted by two double quotes side by side.

Example 4

B"1111_1111" -- binary representation of a vector
B"11111111" -- binary representation of the same vector
X"FF" -- hexadecimal representation of the same vector
O"377" -- octal representation of the same vector

Four methods to denote decimal 255 with bit string literals. In all cases the literals will be converted into binary version, i.e. "11111111".

#### Important Notes

· Underline character can be used in decimal literals (inserted between adjacent digits) to improve readability. In such a case it has no other meaning than just a space.

· Abstract literals cannot contain any spaces, not even between constituents of the exponent.

· A string literal must fit on one line. If longer sequence of characters in required, it may be obtained by concatenating shorter literals.