System Design Through Verilog: Rakesh Dasari
System Design Through Verilog: Rakesh Dasari
System Design Through Verilog: Rakesh Dasari
Through Verilog
(R16 - IV B.Tech.,I Sem, ECE)
Presented
by
RAKESH DASARI
UNIT – I
INTRODUCTION TO VERILOG:
Verilog as HDL
Levels of design Description
Concurrency
Simulation and Synthesis LANGUAGE CONSTRUCTS AND
Functional Verification CONVENTIONS:
System Tasks • Introduction, Keywords, Identifiers,
Programming Language Interface White Space Characters, Comments,
(PLI) • Numbers
Module • Strings
Simulation and Synthesis Tools • Logic Values
Test Benches. • Strengths
• Data Types
• Scalars and Vectors
• Parameters
• Operators.
INTRODUCTION TO VERILOG:
Verilog as HDL
Levels of design Description
Concurrency
Simulation and Synthesis
Functional Verification
System Tasks
Programming Language Interface (PLI)
Module
Simulation and Synthesis Tools
Test Benches.
Verilog as HDL
Verilog aimed at providing a functionally tested and a verified
Gate Level
Data Level
Behavioral Level
Circuit or Switch Level
At the circuit level, a switch is
An A-O-I gate in
psecdo code at
Behavioral Level
The overall design structure in verilog
The possibilities of design description statements and assignments at
Functional Verification
System Tasks
of operation.
All the activities scheduled at one time step are completed
The time step is kept small enough to be negligible compared with the
All the activities scheduled at one time step are completed and then the
In some cases the circuit itself may demand sequential operation as with data
tests.
Testing or functional verification is carried out by setting
debugging.
Constructs for modeling timing delays
Any basic gate has propagation delays and transmission delays
Gate Delay
Net Delay
Path Delay
Pin-to-Pin delay
Contd…
In addition, a design can be tested for setup time, hold time, clock-
time, fall time, path or propagation delays, etc., associated with real
digital circuits or systems.
The use of such constructs in the design helps simulate realistic
it.
Some tasks facilitate control and flow of the testing
process.
Contd…
A set of system functions add to the flexibility of test
format to another
Functions to generate random numbers with specific
distributions.
There are other numerous system tasks and functions
Programming Language Interface (PLI)
Programming Language Interface (PLI) is a way to
a Verilog code.
PLI is primarily used for doing the things which would
modules.
Module
Any Verilog program begins with a keyword – called a
“module.”
A module is the name given to any system considering it
Representation of a MODULE
as block box with its ports
Contd…
The ports attached to a module can be of three types:
input ports through which one gets entry into the module
Functional Description
end module
Contd…
• A module comprises a number of “lexical tokens” arranged
according to some predefined order.
• The possible tokens are of seven categories.
Keywords
Identifiers
White spaces
Comments
Numbers
Strings
Operators
Contd…
Part of the
circuit
diagram of a
typical digital
circuit
Contd…
The below table allows us to identify each type of IC to be used and put in its
proper place.
are noteworthy:
Each module can be defined only once.
- Modelsim and
- Leonardo Spectrum of Mentor Graphics.
Modelsim has been used to simulate the designs.
circuits
Contd…
Use of Modelsim SE 5.5
Simulation
Observing Waveforms
is the test for the static behavior of the circuit. A set of logic
input values are applied at selected points and the logic values
at another set of points observed.
Contd…
Check and ensure that all the functional sequences are carried out as
desired. It is one of the tests for the dynamic behavior of the circuit.
It may call for the generation of specific input sequences with
respect to time, applying them to the circuit and observing selected
outputs.
Check for the timing behavior: One tests for the propagation and
module tb_module_name ;
Input, output, inout declaration
Intermediate variable declarations
Stimulus (initial / always)
End module
Example of 2-i/p and gate
module test_and;
reg a1, a2;
wire b;
#3 a2 = 0;
Initial
#1 a2 = 1;
Begin
end
a1 = 0;
a2 = 0; and g1(b, a1, a2);
#3 a1 = 1; initial $monitor
#1 a1 = 0; ( $time, “a1 = %b, a2 = %b,
#2 a2 = 1; b = %b”’ a1, a2, b);
#4 a1 = 1; initial #100 $finish;
#3 a2 = 0; endmodule
#1 a2 = 1;
Contd…
The keyword initial is followed by a sequence of statements
simulation.
At 0 simulation time the logic variables a1 and a2 are
in simulation time.
The output obtained by running the module
0 a1 = 0 a2 = 0 b=0
3 a1 = 1 a2 = 0 b=0
4 a1 = 0 a2 = 0 b=0
6 a1 = 0 a2 = 1 b=0
10 a1 = 1 a2 = 1 b=1
13 a1 = 1 a2 = 0 b=0
14 a1 = 1 a2 = 1 b=1
Contd…
Summarizing testing constitutes three activities:
banner.
Application of the test signal to the circuit under test –
through instantiation.
Observing selected signal values – through the
$monitor statement
LANGUAGE CONSTRUCTS AND
CONVENTIONS:
Introduction, Keywords, Identifiers, White Space
Characters, Comments,
Numbers
Strings
Logic Values
Strengths
Data Types
Scalars and Vectors
Parameters
Operators.
Language Constructs and Conventions
INTRODUCTION :
The constructs and conventions make up a software language. A clear
Any source file in Verilog (as with any file in any other programming
KEYWORDS :
As such, a programmer cannot use a keyword for any purpose other than
first character.
Subsequent characters can be of alphanumeric type, or the
between the first backslash character and the first white space
encountered is treated as an identifier.
Examples
\b=c
\control-signal
\&logic
\abc // Here the combination “abc” forms the identifier.
WHITE SPACE CHARACTERS
Blanks (\b), tabs (\t), newlines (\n), and form feed form the white
inside strings.
COMMENTS
Comments are incorporated in two types :
Example s:
module d_ff (Q, dp, clk);
description.
Logic status of signal lines, buses, delay values, and numbers
Integer type
Real type.
Integer Numbers
Integers are represented in two ways.
In first case, it is a signed or unsigned Decimal number of 32 bits
wide.
Examples are
6
48
468
-582
The invalid representation of Integers are
8A
C6
-4D3
-5E1
Contd…
The alternate form of number representation is more specific –
though elaborate.
The number can be specified in binary, octal, decimal, or
hexadecimal form.
The representation has three tokens with an optional sign
preceding it.
Contd…
Contd…
The characters used to specify the base number, the sign or the
If the number size is smaller than the size specified, the size is made up by padding 0’s to
the left. However, if the leftmost bit is a x or z, the same is padded to the left.
Contd…
Contd…
If the number size is smaller than the size specified, the size is made up by padding
0’s to the left. However, if the leftmost bit is a x or z, the same is padded to the left.
Negative numbers are represented in 2’s complement form.
Real Numbers
Real numbers can be specified in decimal or scientific notation.
significance.
The fields a and b must be present in the number.
assigns the binary value 0110 1110 0111 0101 0110 1101 0110
0010 to P
n - 0110 1110,
u - 0111 0101,
m - 0110 1101 and
b -0110 0010
Logic Values
1 signifies the 1 or high or true level
Verilog has eight strength levels – four of these are of the driving
type, three are of capacitive type and one of the hi-Z type.
When a signal line is driven simultaneously from two sources of
WOR / 0 1 X Z Tri 0 1 X Z
TRIOR
1(0)
0 0 1 X 0
0 0 X X 0
1 1 1 1 1
1 X 1 X 1
X X 1 X X X X X X X
Z 0 1 X Z Z 0 1 X 1 (0)
VARIABLE DATA TYPE
A variable is an abstraction for a storage device.
It can be declared through the keyword reg and stores the value of
a logic level: 0, 1, x, or z.
A net or wire connected to a reg takes on the value stored in the
reg and can be used as input to other circuit elements.
But the output of a circuit cannot be connected to a reg.
The value stored in a reg is changed through a fresh assignment in
the program.
the other variable data types are: time, integer, real, and real
time.
SCALARS AND VECTORS
Entities representing single bits — whether the bit is stored,
changed, or transferred — are called “scalars.”
a group of regs stores a value, which may be assigned, changed, and
handled together are called as a “Vector”
Scalars
and Vectors
Representation
Contd…
Examples:
wire[3:0] a; /* a is a four bit vector of net type; the bits are
designated as a[3], a[2], a[1] and a[0]. */
reg[2:0] b; /* b is a three bit vector of reg type; the bits are
designated as b[2], b[1] and b[0]. */
reg[4:2] c; /* c is a three bit vector of reg type; the bits are
designated as c[4], c[3] and c[2]. */
wire[-2:2] d ; /* d is a 5 bit vector with individual bits designated
as d[-2], d[-1], d[0], d[1] and d[2]. */
Contd…
Whenever a range is not specified for a net or a reg, the same is
Examples :
wire signed[4:0] num; // num is a vector in the range -16 to +15.
the outset.
Typical Examples are Proportionality constants, frequency-scaling
side.
Such expressions can involve constants and other parameters
declared already;
Parameter word_size = 16, factor = word_size/2;
Contd…
However, a parameter that has been assigned a value in a
statement.
OPERATORS
Verilog has a number of operators akin to the C language.