Professional Documents
Culture Documents
02_DSD_Presentation (1)
02_DSD_Presentation (1)
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Design Entry
Design entry process involves entering into the CAD system a
description of the circuit being designed.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Functional Simulation
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Physical Design
After logic synthesis the next step in the design flow is to determine
exactly how to implement the circuit on a given chip. This step is
often called physical design.
The physical design tools map a circuit specified in the form of
logic expressions into a realization that makes use of the
resources available on the target chip.
They determine the placement of specific logic elements,
which are not necessarily simple gates of the type we have
encountered so far.
They also determine the wiring connections that have to be
made between these elements to implement the desired circuit
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog HDL
Verilog was designed in early 1984 by Gateway Design Automation
and was initially used as a simulation and verification tool.
Gateway Design Automation and its Verilog-based tools were later
acquired by Cadence Design System.
Verilog became the IEEE standard, IEEE Std. 1364-1995, in 1995
and was updated in 2001, 2005.
The standard was superseeded by IEEE std. 1800-2009 which
included a unified standard for verilog and System-verilog.
Verilog has variety of constructs aimed at providing a functionally
tested and a verified design description for the target FPGA or
ASIC. Therefore, the language has two functions
1 Fulfil the need for design description
2 Fulfil the need for verifying the design for functionality and
timing constraints
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Module Instantiation
// Override default parameter: setting N = 13
MyModule #(13) MyModule1(Reset, Clk, Result);
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
General rules
Verilog is case sensitive and has built-in module features like the file
structure, data types, operators, and declarations.
Each Verilog assignment, definition, or declaration is terminated
with a semicolon (;).
Line wraps are allowed and do not signify the end of an
assignment, definition, or declaration. Line wraps can be used
to make Verilog more readable.
Comments in Verilog are supported in two ways.
Line comment is preceded with two slashes (i.e., //).
Everything after the slashes is considered a comment until the
end of the line.
The block comment begins with /* and ends with a */.
Everything between /* and */ is considered a comment. A
block comment can span multiple lines.
All user-defined names must start with an alphabetic letter, not a
number and are not allowed to be the same as any Verilog keyword
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Data types
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Vectors
// Examples
wire [7:0] Sum; // This defines an 8-bit vector called "Sum" of
// type wire. MSB index is 7 & LSB index is 0.
reg [15:0] Q; // Defines a 16-bit vector called "Q" of type reg.
Individual bits within the vector can be addressed using their index.
Ex: Sum[5] represents 6th bit of the vector Sum.
Groups of bits can be accessed using an index range. Ex: Q[15:8]
represents the upper 8-bits of the vector Q.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Arrays
// Examples
reg [7:0] Mem [0:15]; // Defines an array of 16, 8-bit vectors
// of type reg
integer A [1:100]; // Defines an array of 100 integers.
When accessing an array, the name of the array is given first,
followed by the index of the element and vector index
A[2] // accesses 2nd element of array A.
Mem [2][7] // MSB of 3rd element of array Mem}.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Expressing Numbers
Verilog supports defining numbers in other bases with optional bit
size and sign.
Without identifying syntax, number is treated as an integer.
Specifying size is optional. If it is omitted, the number will default
to a 32-bit vector with leading zeros added as necessary.
Values of numbers can be entered in either upper or lower case
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Numbers: Examples
When defining the value of arrays, the “ ” can be inserted between
numerals to improve readability.
Examples
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog Module
A Verilog design describes a single system in a single file.
The file has the extension *.v.
Within the file, the system description is contained within a
module.
A module is a block of verilog code that implements certain
functionality defining the circuit.
The module includes the interface to the system (i.e., the
inputs and outputs) and the description of the behaviour.
Modules can include instantiations of lower-level modules in
order to support hierarchical designs.
The keywords module and endmodule signify the beginning
and end of the system description.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog Module
module name is the identifier for the module and should best
describe what the system is doing.
It can be composed of letters, digits, dollar sign ($), and
underscore characters ( ) only.
It should start with a letter or “ ”.
No spaces are allowed inside an identifier.
Reserved keywords cannot be used as identifiers.
Examples: Counter BCD, ALU, TwoInputAnd.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog Module
A module has inputs and outputs, which are referred to as its ports.
Each port needs to have a user-defined name, a direction, and
a type.
The user-defined port names are case sensitive and must begin
an alphabetic character.
The port directions are declared to be one of the three types:
input, output, and inout.
A port can take on any of the previously described data types,
but only wires, registers, and integers are synthesizable.
Port names with the same type and direction can be listed on
the same line separated by commas.
Starting with the Verilog-2001, the port directions and types
could be included alongside the port names within the
parenthesis after the module name.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog Module
A signal that is used for internal connections within a system is
declared within the module before its first use.
Each signal must be declared by listing its type followed by a
user-defined name.
Signal names of like type can be declared on the same line
separated with a comma.
All of the legal data types can be used for signals; however, only
types net, reg, and integer will synthesize directly.
Verilog supports a hierarchical design approach, thus signal names
can be the same within a subsystem as those at a higher level
without conflict
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog Module
A parameter, or constant, is useful for representing a quantity that
will be used multiple times in the architecture.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Verilog Module
A compiler directive provides additional information to the
simulation tool on how to interpret the Verilog model.
A compiler directive is placed before the module definition and is
preceded with a backtick (‘)
Example
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
When simulated, the following three lines of Verilog will make three
separate signal assignments at the exact same time.
assign X = A;
assign Y = B;
assign Z = C;
In the following example the signal assignments of C to B and B to
A will take place at the same time. Hence during synthesis, the
signal B will be eliminated from the design since this functionality
describes two wires in series.
assign A = B;
assign B = C;
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Logical Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Logical Operators
A reduction operator uses each bit of a vector as individual inputs
into a logic operation and produces a single-bit output.
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Relational Operators
A relational operator is one that returns a value of TRUE (1) or
FALSE (0) based on a comparison of two inputs
Example:
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Conditional Operators
Verilog contains a conditional operator that can be used to model
logic statements. The keyword is ? with the following syntax:
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Numerical Operator
Example:
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Numerical Operators
DSDV
CAD Tools for Digital Design
Unit-I Verilog HDL: An Introduction
Verilog Constructs, Modules and Operators
Operator precedence
Verilog operators have a fixed order of precedence.
If two operators of the same type appear in an expression without
parenthesis to dictate the order of precedence, the precedence will
be determined by executing from the operations from left to right.
DSDV