What Is Verilog: - Hardware Description Language (HDL) - Developed in 1984 - Standard: IEEE 1364, Dec 1995
What Is Verilog: - Hardware Description Language (HDL) - Developed in 1984 - Standard: IEEE 1364, Dec 1995
• Developed in 1984
• Concurrency
• Structure
Main Language Concepts (ii)
• Procedural Statements
• Time
User Identifiers
• Formed from {[A-Z], [a-z], [0-9], _, $}, but ..
• .. can’t begin with $ or [0-9]
– myidentifier
– m_y_identifier
– 3my_identifier
– $my_identifier
– _myidentifier$
• Case sensitive
– myid Myid
Comments
• /* Multiple line
comment */
No
Noofof Binary
Binary bbor
orBB Consecutive
Consecutivechars
chars
bits
bits Octal
Octal ooor
orOO 0-f,
0-f,x,x,zz
Decimal
Decimal ddor
orDD
Hexadecimal
Hexadecimal hhororHH
– 8’h ax = 1010xxxx
– 12’o 3zx7 = 011zzzxxx111
Numbers in Verilog (ii)
• You can insert “_” for readability
– 12’b 000_111_010_100
– 12’b 000111010100 Represent the same number
– 12’o 07_24
• Bit extension
– MS bit = 0, x or z extend this
• 4’b x1 = 4’b xx_x1
– MS bit = 1 zero extension
• 4’b 1x = 4’b 00_1x
Numbers in Verilog (iii)
• If size is ommitted it
– is inferred from the value or
– takes the simulation specific number of bits or
– takes the machine specific number of bits
A wire Y; // declaration
Y
B assign Y = A & B;
Registers
• Variables that store values
• Do not represent real hardware but ..
• .. real hardware can be implemented with registers
• Only one type: reg
reg A, C; // declaration
// assignments are always done inside a procedure
A = 1;
C = A; // C gets the logical value 1
A = 0; // C is still 1
C = 0; // C is now 0
• No multi-dimentional arrays
reg var[1:10] [1:100]; // WRONG!!
• Escaped chars:
– \n newline
– \t tab
– %% %
– \\ \
– \“ “
Hierarchical Design
Top
TopLevel
Level E.g.
Module
Module
Full
FullAdder
Adder
Sub-Module
Sub-Module Sub-Module
Sub-Module
11 22
Half
HalfAdder
Adder Half
HalfAdder
Adder
Basic
BasicModule
Module Basic
BasicModule
Module Basic
BasicModule
Module
11 22 33
Module
module my_module(out1, .., inN);
in1 my_module out1 output out1, .., outM;
in2 out2 input in1, .., inN;
f .. // declarations
inN outM .. // description of f (maybe
.. // sequential)
endmodule
A S assign S = A ^ B;
Half assign C = A & B;
Half
B Adder
Adder C
endmodule
Example: Full Adder
in1 A S I1 A S sum
Half
Half Half
Half
Adder
Adder11 I2 Adder
Adder
in2 B C B C I3
ha1
ha1 ha2
ha2 cout
cin
module full_adder(sum, cout, in1, in2, cin);
output sum, cout;
input in1, in2, cin;
endmodule