4-Value Logic Values

A scalar logic net can be one of four possible values:

Verilog logic values.
Value Description
0 Zero, low, or false.
1 One, high, or true.
x Unknown or uninitialized.
z Undriven (floating).


Simple integers are numbers constructed from digits and possibly underscores. Underscores are ignored in numbers, so 42_839 is equivalent to 42839.


Simple integers are signed unsized numbers. A simple integer specification may not contain an x or z.

Except in Verilog-A, integer numbers can be explicitly expressed in decimal, hexadecimal, octal, or binary notation. To do so, use s’bn; where s is an optional decimal number that indicates the size of the constant in bits; b is the base format and n is the number in the specified base. The base format is a one or two character code that signifies the following types of numbers:

b unsigned binary
o unsigned octal
d unsigned decimal
h unsigned hexadecimal
sb signed binary
so signed octal
sd signed decimal
sh signed hexadecimal

In hexadecimal numbers the letters a through f represent the digits 10 through 15. Letters in integer constants can be either lower or upper case.

63 — unsized unsigned decimal number
'd63 — unsized unsigned decimal number
'h3f — unsized unsigned hexadecimal number
'o77 — unsized unsigned octal number
'b11_1111 — unsized unsigned binary number
12'h3f — 12 bit unsigned hexadecimal number
5'sd0 — 5 bit signed decimal number

The letters x and z can be given to denote unknown and high impedance digits in all numbers that use a base format, and _ is ignored. Sized constants for which the size is larger than the given number are padded on the left with zeros unless the first digit of the given number is an x or z, which are padded with the x or z. The number is truncated on the left if the size is smaller than the given number.

64'o0 — a 64 bit octal 0 (zero padded)
8'hx — equivalent to 8'bxxxx_xxxx (x padded)
12'hfx — equivalent to 12'b0000_1111_xxxx (zero padded)
8'hfffx — equivalent to 8'b1111_xxxx (truncated)

Real Numbers

Real numbers must either include a decimal point or a scale factor. If a decimal point is present, there must be digits on both sides. So .12, 9., 4.eE3, and .2e-7 are not valid numbers. Underscores are ignored in real numbers. Scale factors are given in the table below. These scale factors are available in Verilog-A and Verilog-AMS, but not in Verilog.

Scale factors for real numbers.
Multiplier Name Symbol
1012 tera T
109 giga G
106 mega M
103 kilo K or k
10-3 milli m
10-6 micro u
10-9 nano n
10-12 pico p
10-15 fempto f
10-18 atto a
10d exponent e d or E d


Predefined numbers in the form of compiler directives are included in the file constants.vams and listed in the table below (only available in Verilog-A and Verilog-AMS). The would be included with:

`include "constants.vams"

Mathematical constants are denoted with a `M_ prefix.

Predefined mathematical constants in constants.vams
`M_PI π 3.14159265358979323846
`M_TWO_PI 6.28318530717958647693
`M_PI_2 π/2 1.57079632679489661923
`M_PI_4 π/4 0.78539816339744830962
`M_1_PI 1/π 0.31830988618379067154
`M_2_PI 2/π 0.63661977236758134308
`M_2_SQRTPI 2/√π 1.12837916709551257390
`M_E e 2.7182818284590452354
`M_LOG2E log2 e 1.4426950408889634074
`M_LOG10E log10 e 0.43429448190325182765
`M_LN2 loge 2 0.69314718055994530942
`M_LN10 loge 10 2.30258509299404568402
`M_SQRT2 √2 1.41421356237309504880
`M_SQRT1_2 1/√2 0.70710678118654752440

Physical constants use the `P_ prefix.

Predefined physical constants in constants.vams
`P_Q charge of an electron 1.602176462 × 10 -19 C
`P_C speed of light 2.99792458 × 10 8 m/s
`P_K Boltzmann’s constant 1.3806503 × 10 -23 J/K
`P_H Planck’s constant 6.626076 × 10 -34 J-s
`P_EPS0 permittivity of a vacuum 8.854187817 × 10 -12 F/m
`P_U0 permeability of a vacuum 4π10 -7 H/m
`P_CELSIUS0 0 Celsius 273.15 K