BACK

4.0 Lexical Conventions

 

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.

 

TOP

 

Identifiers

  • Must begin with alphabetic or underscore characters a-z A-Z _
  • May contain the characters a-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

adder

legal identifier name

XOR

uppercase identifier is unique from xor keyword

\reset*

an escaped identifier (must be followed by a white space)

 

TOP

 

Logic Values

The Verilog HDL has 4 logic values.

Logic Value

Description

0

zero, low, or false

1

one, high, or true

z or Z

high impedance (tri-stated or floating)

x or X

unknown or uninitialized

 

TOP

 

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

Su1

6

Strong Drive

strong0

strong1

St0

St1

5

Pull Drive

pull0

pull1

Pu0

Pu1

4

Large Capacitive

large

La0

La1

3

Weak Drive

weak0

weak1

We0

We1

2

Med. Capacitive

medium

Me0

Me1

1

Small Capacitive

small

Sm0

Sm1

0

High Impedance

highz0

highz1

HiZ0

HiZ1

 

 

TOP

 

Literal Integer Number

 

Syntax

size'base value Sized 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

b or B

0, 1, x, X, z, Z, ?, _

octal

o or O

0-7, x, X, z, Z, ?, _

decimal

d or D

0-9, _

hexadecimal

h or H

0-9, a-f, A-F, x, X, z, Z, ?, _
  • The ? is another way of representing the Z logic 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

1

8'Hc5

8 bits

hex

11000101

6'hF0

6 bits

hex

110000 (truncated)

6'hF

6 bits

hex

001111 (zero filled)

6'hZ

6 bits

hex

ZZZZZZ (Z filled)

TOP

 

Literal Real Number

 

Syntax

value.value decimal notation
baseEexponent scientific notation (the E is 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)

TOP

 BACK