Verilog HDL constructs that represent hierarchy scope are:
Each scope has its own name space. An identifier name defined within a scope is unique to that scope. References to an identifier name will search first in the local scope, and then search upward through the scope hierarchy up to a module boundary.
Introduction
Identifiers
Logic
Values
Logic
Strengths
Literal Integer
Number
Literal Real
Number
Introduction
4.1 White Space Characters
blanks, tabs, newlines (carriage return), formfeeds and EOF (end-of-file).
4.2 Comments
//begins a single line comment, terminated by a newline.
/*begins a multi-line comment, terminated by a*/.4.3 Case Sensitivity
Verilog is case sensitive.
Identifiers
Must begin with alphabetic or underscore charactersa-z A-Z _ May contain the charactersa-z A-Z 0-9 _and$ May use any character by escaping with a backslash (\) at the beginning of the identifier, and terminating with a white space.
Examples
Notes
adderlegal identifier name
XORuppercase identifier is unique from xor keyword
\reset*an escaped identifier (must be followed by a white space)
Logic Values
The Verilog HDL has 4 logic values.
Logic Value
Description
0zero, low, or false
1one, high, or true
zorZhigh impedance (tri-stated or floating)
xorXunknown or uninitialized
Logic Strengths
The Verilog HDL has 8 logic strengths: 4 driving, 3 capacitive, and high impedance (no strength).
Strength Level
Strength Name
Specification Keyword
Display Mnemonic
7
Supply Drive
supply0
supply1
Su0
Su16
Strong Drive
strong0
strong1
St0
St15
Pull Drive
pull0
pull1
Pu0
Pu14
Large Capacitive
large
La0
La13
Weak Drive
weak0
weak1
We0
We12
Med. Capacitive
medium
Me0
Me11
Small Capacitive
small
Sm0
Sm10
High Impedance
highz0
highz1
HiZ0
HiZ1
Literal Integer Number
Syntax
size 'base valueSized integer in a specific radix (base)
- size (optional) is the number of bits in the number. Unsized integers default to at least 32-bits.
'base (optional) represents the radix. The default base is decimal.
Base
Symbol
Legal Values
binary
orb
B0, 1, x, X, z, Z, ?, _ octal
oro
O0-7, x, X, z, Z, ?, _ decimal
ord
D0-9, _ hexadecimal
orh
H0-9, a-f, A-F, x, X, z, Z, ?, _
- The
?is another way of representing theZlogic value.- An
_(underscore) is ignored (used to enhance readability).- Values are expanded from right to left (lsb to msb).
- When size is less than value, the upper bits are truncated.
- When size is larger than value, and the left-most bit of value is 0 or 1, zeros are left-extended to fill the size.
- When size is larger than value, and the left-most bit of value is Z or X, the Z or X is left-extended to fill the size.
Examples
Size
Base
Binary Equivalent
10
unsized
decimal
0...01010(32-bits)'o7
unsized
octal
0...00111(32-bits)1'b1
1 bit
binary
18'Hc5
8 bits
hex
110001016'hF0
6 bits
hex
110000(truncated)6'hF
6 bits
hex
001111(zero filled)6'hZ
6 bits
hex
ZZZZZZ(Z filled)
Literal Real Number
Syntax
value .valuedecimal notation base Eexponentscientific notation (the Eis not case sensitive)
- Real numbers are limited to the values 0-9 and underscore.
- There must be a value on either side of the decimal point.
Examples
Notes
0.5
must have value on both sides of decimal point 3e4
3 times 104 (30000) 5.8E-3
5.8 times 10-3 (0.0058)