Verilog Datatypes Operators
Verilog Datatypes Operators
Other types include tri, wand, wor, triand, trior, supply0, supply1, tri0, tri1 and
trireg to enable more advanced modeling of hardware.
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
1 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
The rules for using nets and registers in ports of modules and primitives:
Variable type input output inout
net YES YES YES
register NO YES NO
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
2 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
A truth table is used to define the mapping of inputs to outputs for each of
these values.
A y
B
A 0 1 x z
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
3 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
Constants
Declared using the keyword parameter.
parameter byte_size = 8 ; // integer
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
4 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
Operators
Operators (Arithmetic)
Standard operators here include +, -, *, / and %
Bitwise Operators
Standard operations include ~, &, |, ^, ~^ (bitwise exclusive nor)
If the operands do not have the same size (in the case of a binary opera-
tion), the shorter word is extended with 0 padding.
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
5 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
Operators
Reduction Operators
These are unary operators which create a single bit value for a data word
of multiple bits.
Symbol Operator
&, ~& reduction and, nand
|, ~| reduction or, nor
^, ~^, ^~ reduction xor, xnor
Logical Operators
Symbol Operator
! Logical negation
&&, || Logical and, or
==, != Logical equality, inequality
===, !== Case equality, inequality
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
6 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
Operators
Logical Operators (cont):
Operate on Boolean operands. Operands may be a net, register or
expression and are treated as unsigned.
For example, if ((a < size -1) && (b != c) && (index != last_one)) ...
Relational Operators
The operators <, <=, > and >= compare operands and produce a Boolean
result (true or false).
If the operands are nets or registers, their values are treated as unsigned.
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
7 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
Operators
Shift Operators
Shift operators, >> and <<, are unary operators which perform left or
right shifts, zero filling vacated positions.
Conditional Operator:
conditional_expression ::= expression ? true_expression: false_expression
Concatenation Operator
Forms a single operand from two or more operands, and is useful for
forming logical buses.
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
8 (10/2/07)
RE COUNT
UN
1966
Programmable Logic Devices Data Types/Operators CMPE 415
Operators
Operator Precedence
Verilog evaluates expression left-to-right.
UMBC
YLAND BA
AR L
M
TI
U M B C
F
IVERSITY O
MO
9 (10/2/07)
RE COUNT
UN
1966