EN3542 - Digital System Design: Hardware Description Languages - I
EN3542 - Digital System Design: Hardware Description Languages - I
EN3542 - Digital System Design: Hardware Description Languages - I
Hardware Description
Languages - I
Ajith Pasqual
pasqual@ent.mrt.ac.lk
Dept. of Electronic & Telecommunication Engineering
B.Sc. Engineering
Semester 5 module
UNIVERSITY
OF MORATUWA
References
Verilog for Digital Design Frank Vahid
Verilog HDL A Guide to Digital Design and
Synthesis Samir Palnitkar
Examples taken from Digital Design by Morris
Mano
UNIVERSITY
OF MORATUWA
Section 1 : Contents
Introduction to HDL
Verilog
Combinational Logic Design
Digital Design with Verilog
UNIVERSITY
OF MORATUWA
HDL - Introduction
Could be an
ASIC, FPGA or
CPLD.
UNIVERSITY
OF MORATUWA
UNIVERSITY
Language.
OF MORATUWA
Advantages of HDL
Allows designers to talk about what the
hardware should do without actually designing
the hardware itself, or in other words HDLs
allow designers to separate behavior from
implementation at various levels of
abstraction
Designers can develop an executable functional
specification that documents the exact behavior of
all the components and their interfaces
Designers can make decisions about cost,
performance, power, and area earlier in the design
process
Designers can create tools which automatically
manipulate the design for verification, synthesis,
optimization, etc.
UNIVERSITY
OF MORATUWA
UNIVERSITY
OF MORATUWA
UNIVERSITY
OF MORATUWA
10
Logic Simulation
This is the representation of the structure and
behaviour of digital logic system through the
use of a computer.
A simulator interprets the HDL description and
produces a readable output, such as a timing
diagram, that predicts how the hardware will
behave before its is actually fabricated.
Simulation allows the detection of functional
errors in a design without having to physically
create the circuit.
Errors detected during simulation can be
corrected by modifying the appropriate HDL
statements.
UNIVERSITY
OF MORATUWA
11
UNIVERSITY
OF MORATUWA
12
Logic Synthesis
The process of automatically generating a
gate-level model from either a dataflow or a
behavioral model is called Logic Synthesis
This is the process of deriving a list of
components and their interconnections
(called a netlist) from the model of a digital
system described in HDL.
The gate-level netlist can be used to fabricate
an integrated circuit or to layout a printed
circuit board (PCB).
Logic Synthesis is similar to compiling a
program in a conventional high-level
language.
UNIVERSITY
OF MORATUWA
13
14
UNIVERSITY
OF MORATUWA
15
16
17
18
Typical
Design Flow
for
Designing
VLSI IC
UNIVERSITY
OF MORATUWA
19
Types of HDL
There are two standard HDLs that are supported
by IEEE.
UNIVERSITY
OF MORATUWA
20
A comparison of HDLs
UNIVERSITY
OF MORATUWA
21
Verilog
Verilog HDL has a syntax that describes
precisely the legal constructs that can be used
in the language.
It uses about 100 keywords pre-defined,
lowercase, identifiers that define the language
constructs.
Example of keywords: module, endmodule,
input, output, wire, and, or, not , etc.,
Any text between two slashes (//) and the end
of line is interpreted as a comment.
Blank spaces are ignored and names are case
sensitive.
UNIVERSITY
OF MORATUWA
22
Verilog - Module
A module is the building block in Verilog.
It is declared by the keyword module and is
always terminated by the keyword
endmodule.
Each statement is terminated with a
semicolon, but there is no semi-colon after
endmodule.
UNIVERSITY
OF MORATUWA
23
HDL Example
Keyword wire:
Nets represent connections between hardware elements.
They are continuously driven by output of connected
devices. They are declared using the keyword wire.
UNIVERSITY
OF MORATUWA
24
25
26
27
<size><base_format><number>
Size : Number of bits (always in
bits irrespective of Base Format)
4b1111
12HABC
6Hx [ x Uknown]
8bz [z High Impedance]
28
UNIVERSITY
OF MORATUWA
29
Verilog testbench
30
UNIVERSITY
OF MORATUWA
31
UNIVERSITY
OF MORATUWA
32
UNIVERSITY
OF MORATUWA
33
34
UNIVERSITY
OF MORATUWA
35
36
endmodule
UNIVERSITY
OF MORATUWA
37
UNIVERSITY
OF MORATUWA
38
Gate-Level Modeling
Here a circuit is specified by its logic gates
and their interconnections.
It provides a textual description of a
schematic diagram.
Verilog recognizes 12 basic gates as
predefined primitives.
39
UNIVERSITY
OF MORATUWA
40
UNIVERSITY
OF MORATUWA
41
Gate-level Modeling
UNIVERSITY
OF MORATUWA
42
Gate-level Modeling
A bottom-up hierarchical description of a 4-bit
adder is described in Verilog as
UNIVERSITY
OF MORATUWA
43
UNIVERSITY
OF MORATUWA
44
UNIVERSITY
OF MORATUWA
45
4 bit Full
Adder
46
UNIVERSITY
OF MORATUWA
47
Three-State Gates
UNIVERSITY
OF MORATUWA
48
Three-State Gates
UNIVERSITY
OF MORATUWA
49
Three-State Gates
The output of 3-state
gates can be connected
together to form a
common output line. To
identify such connections,
HDL uses the keyword tri
(for tristate) to indicate
that the output has
multiple drivers.
UNIVERSITY
OF MORATUWA
Three-State Gates
52
UNIVERSITY
OF MORATUWA
53
Dataflow Modeling
Dataflow modeling uses a number of
operators that act on operands to produce
desired results.
Verilog HDL provides about 30 operator types.
Dataflow modeling uses continuous
assignments and the keyword assign.
A continuous assignment is a statement that
assigns a value to a net.
The value assigned to the net is specified by
an expression that uses operands and
operators.
UNIVERSITY
OF MORATUWA
54
55
UNIVERSITY
OF MORATUWA
56
57
UNIVERSITY
OF MORATUWA
58
UNIVERSITY
OF MORATUWA
59
Writing a testbench
A testbench is an HDL program used for
applying stimulus to an HDL design in order to
test it and observe its response during
simulation.
In addition to the always statement, testbenches
use the initial statement to provide a stimulus to
the circuit under test.
The always statement executes repeatedly in a
loop. The initial statement executes only once
starting from simulation time=0 and may
continue with any operations that are delayed by
a given number of units as specified by the
symbol #.
UNIVERSITY
OF MORATUWA
60
initial
begin
A=0; B=0;
#10
A=1;
#20
A=0;
end
B=1;
begin
D = 3b000;
repeat (7);
#10
D = D + 3b001;
end
61
module testname
Declare local reg and wire identifiers
Instantiate the design module under test.
Generate stimulus using initial and always statements
Display the output response.
endmodule
62
63
64
UNIVERSITY
OF MORATUWA
66
Descriptions of Circuits
Structural Description This is directly
equivalent to the schematic of a circuit and is
specifically oriented to describing hardware
structures using the components of a circuit.
Dataflow Description This describes a
circuit in terms of function rather than
structure and is made up of concurrent
assignment statements or their equivalent.
Concurrent assignments statements are
executed concurrently, i.e. in parallel
whenever one of the values on the right hand
side of the statement changes.
UNIVERSITY
OF MORATUWA
67
UNIVERSITY
OF MORATUWA
68
4-to-1 Multiplexer
UNIVERSITY
OF MORATUWA
69
4-to-1 Multiplexer
UNIVERSITY
OF MORATUWA
70
UNIVERSITY
OF MORATUWA
71
4-to-1 Multiplexer
UNIVERSITY
OF MORATUWA
72
Hierarchical Modelling
A module can contain other modules through
module instantiation creating a module
hierarchy
Modules are connected together with nets
Ports are attached to nets either by position or by
name
UNIVERSITY
OF MORATUWA
73
Adder
UNIVERSITY
OF MORATUWA
74
4-bit Adder
UNIVERSITY
OF MORATUWA
75
4-bit-Adder
UNIVERSITY
OF MORATUWA
76