IEEE
THE VERILOG
¨
HARDWARE DESCRIPTION LANGUAGE Std 1364-1995
Section 2 7
The Þrst token, a size constant, shall specify the size of the constant in terms of its exact number of bits. It shall be
speciÞed as an unsigned decimal number. For example, the size speciÞcation for two hexadecimal digits is 8, because
one hexadecimal digit requires 4 bits.
The second token, a base_format, shall consist of a letter specifying the base for the number, preceded by the single
quote character (Õ). Legal base speciÞcations are d, D, h, H, o, O, b, or B, for the bases decimal, hexadecimal, octal,
and binary respectively.
The use of x and z in deÞning the value of a number is case insensitive.
The single quote and the base format character shall not be separated by any white space.
The third token, an unsigned number, shall consist of digits that are legal for the speciÞed base format. The unsigned
number token shall immediately follow the base format, optionally preceded by white space. The hexadecimal digits
a to f shall be case insensitive.
Simple decimal numbers without the size and the base format shall be treated as signed integers, whereas the numbers
speciÞed with the base format shall be treated as unsigned integers.
A plus or a minus operator preceding the size constant is a sign for the constant number; the size constant does not
take a sign. A plus or minus operator between the base format and the number is an illegal syntax.
Negative numbers shall be represented in 2Õs complement form.
An x represents the unknown value in hexadecimal, octal, and binary constants. A z represents the high-impedance
value. See 3.1 for a discussion of the Verilog HDL value set. An x shall set 4 bits to unknown in the hexadecimal base,
3 bits in the octal base, and 1 bit in the binary base. Similarly, a z shall set 4 bits, 3 bits, and 1 bit, respectively, to the
high-impedance value.
If the size of the unsigned number is smaller than the size speciÞed for the constant, the unsigned number shall be
padded to the left with zeros. If the leftmost bit in the unsigned number is an x or a z, then an x or a z shall be used
to pad to the left respectively.
When used in a number, the question-mark (?) character is a Verilog HDL alternative for the z character. It sets 4
bits to the high-impedance value in hexadecimal numbers, 3 bits in octal, and 1 bit in binary. The question mark can
be used to enhance readability in cases where the high-impedance value is a donÕt-care condition. See the discussion
of casez and casex in 9.5.1. The question-mark character is also used in user-deÞned primitive state table. See 8.1.4.
The underscore character (_) shall be legal anywhere in a number except as the Þrst character. The underscore charac-
ter is ignored. This feature can be used to break up long numbers for readability purposes.
Examples:
Unsized constant numbers
Sized constant numbers
659 // is a decimal number
Õh 837FF // is a hexadecimal number
Õo7460 // is an octal number
4af // is illegal (hexadecimal format requires Õh)
Authorized licensed use limited to: BEIJING INSTITUTE OF TECHNOLOGY. Downloaded on March 27,2020 at 11:07:04 UTC from IEEE Xplore. Restrictions apply.