Beruflich Dokumente
Kultur Dokumente
.
Logic Synthesis pushed the HDLs into the forefront of
digital design.
VERILOG
VHDL
Simulation
test benches
Will be
covered in
VLSI Subject
1.Any design can be
designed in 4 ways
Behavior or
data flow, 0r
Gate level or
switch level.
(units 1,2,3, advanced
4)
2.In simulation
the design is tested
Using test benches 0r
Formal verification or
Assertions (unit 5)
3.Then design is
synthesized and
converted into net list .
(Hardware model from
software description)
LEVELS OF DESIGN DESCRIPTION
The components of the target design can be described at different levels with the
help of the constructs in Verilog
At the circuit level, a switch is the basic element with which digital circuits are
built. Switches can be combined to form inverters and other gates at the next
higher level of abstraction.
Verilog has the basic MOS switches built into its constructs, which can be
used to build basic circuits like inverters, basic logic gates, simple 1-bit dynamic
and static memories.
They can be used to build up larger designs to simulate at the circuit level, to
design performance critical circuits.
Gate Level / structural
At the next higher level of abstraction, design is carried out in terms of basic
gates. All the basic gates are available as ready modules called “Primitives.”
Each such primitive is defined in terms of its inputs and outputs. Primitives
can be incorporated into design descriptions directly.
Just as full physical hardware can be built using gates, the primitives can be
used repeatedly and judiciously to build larger systems
Data flow is the next higher level of abstraction. All possible operations on signals
and variables are represented here in terms of assignments.
All logic and algebraic operations are accommodated. The assignments define the
continuous functioning of the concerned block.
At the data flow level, signals are assigned through the data manipulating
equations. All such assignments are concurrent in nature.
The design descriptions are more compact than those at the gate level.
Behavioral Level
In some cases the circuit itself may demand sequential operation as with data
transfer and memory-based operations. Only in such cases sequential operation is
ensured by the appropriate usage of sequential constructs from Verilog HDL
Simulation
The design descriptions are tested for their functionality at every level –
behavioral, data flow, and gate.
One has to check here whether all the functions are carried out as expected
and rectify them. All such activities are carried out by the simulation tool.
The tool also has an editor to carry out any corrections to the source code.
Simulation involves testing the design for all its functions, functional
sequences, timing constraints, and specifications.
Normally testing and simulation at all the levels – behavioral to switch level –
are carried out by a single tool;
Synthesis
The design that is specified and entered as described earlier is simulated for
functionality and fully debugged.
The tools available for synthesis relate more easily with the gate level and data
flow level modules .The circuits realized from them are essentially direct
translations of functions into circuit elements.
In contrast many of the behavioral level constructs are not directly
synthesizable; even if synthesized they are likely to yield relatively redundant or
wrong hardware.
The way out is to take the behavioral level modules and redo each of them at
lower levels. The process is carried out successively with each of the behavioral
level modules until practically the full design is available as a pack of modules at
gate and data flow levels (more commonly called the “RTL level”).
Always
inst1 Synthesis
inst2
inst3
Testing is an essential ingredient of the VLSI design process as with any hardware
circuit. It has two dimensions to it – functional tests and timing tests. Both can be
carried out with Verilog.
Once a proper design is done, it has to be tested for all its functional aspects. The
system has to carry out all the expected activities and not falter. Further, it should not
malfunction under any set of input conditions. Functional testing is carried out to
check for such requirements.
Often testing or functional verification is carried out by setting up a “test bench” for
the design.
The test bench will have the design instantiated in it; it will generate necessary
test signals and apply them to the instantiated design. The outputs from the design
are brought back to the test bench for further analysis.
The input signal combinations, waveforms and sequences required for testing
are all to be decided in advance and the test bench configured based on the same.
The test benches are mostly done at the behavioral level. The constructs there
are flexible enough to allow all types of test signals to be generated. In the process
of testing a module, one may have to access variables buried inside other modules
instantiated within the master module. Such variables can be accessed through
suitable hierarchical addressing.
PROGRAMMING LANGUAGAE INTERFACE :
PLI provides an active interface to a compiled Verilog module. The interface adds
a new dimension to working with Verilog routines from a C platform. The key
functions of the interface are as follows:
One can read data from a file and pass it to a Verilog module as input. Such data
can be test vectors or other input data to the module. Similarly, variables
in Verilog modules can be accessed and their values written to output devices.
Delay values, logic values, etc., within a module can be accessed and altered.
Blocks written in C language can be linked to Verilog modules.
Any Verilog program begins with a keyword – called a “module.” A module
is the name given to any system considering it as a black box with
input and output terminals as shown in Figure . The terminals of the
module are referred to as ‘ports’. The ports attached to a module can
be of three types:
Input Ports through which one gets
entry into the module; they signify the
input signal terminals of the module.
Modules begin with the module keyword and end with end module.
Immediately following the module keyword, port list of the module appears
enclosed in parenthesis.
Declaration of mode, type, and size of ports can either appear in the port list
or as separate declarations.
module’s
name
module DFlipFlop (preset, reset, din, clk, qout);
port list
input preset, reset, din, clk;
output qout;
reg qout; 20
The delay values (15 ns) used in this example are chosen so that
inputs remain stable while a change is propagating through the
circuit.
Port Connection Rules
One can visualize a port as consisting of two units, one unit that is internal to
the module and another that is external to the module. The internal and
external units are connected.
There are rules governing port connections when modules are instantiated
within other modules.
Inputs
Internally, input ports must always be of the type net.
Externally, the inputs can be connected to a variable which is a reg or a net.
Outputs
Internally, outputs ports can be of the type reg or net.
Externally, outputs must always be connected to a net. They cannot be connected to a
reg.
Inouts
Internally, inout ports must always be of the type net.
Externally, inout ports must always be connected to a net.
Width matching
It is legal to connect internal and external items of different sizes when making
intermodule
port connections. However, a warning is typically issued that the widths do not
match.
Unconnected ports
Verilog allows ports to remain unconnected
Keywords
Keywords are special identifiers reserved to define the language constructs.
Keywords are in lowercase. The programmer cannot use the keyword for any
other purpose than it is intended for .
Escaped identifiers
Escaped identifiers begin with the backslash ( \ ) character and end with
whitespace (space, tab, or newline). All characters between backslash and
whitespace are processed literally. Any printable ASCII character can be included
in escaped identifiers. Neither the backslash nor the terminating whitespace is
considered to be a part of the identifier.
\a+b-c
\**my_name**
Whitespace
Blank spaces (\b) , tabs (\t) and newlines (\n) comprise the whitespace.
A multiple-line comment starts with "/*" and ends with "*/". Multiple-line
comments cannot be nested.
Sized numbers
Sized numbers are represented as <size> '<base format> <number>.
<size> is written only in decimal and specifies the number of bits in the number.
Legal base formats are decimal ('d or 'D), hexadecimal ('h or 'H), binary ('b or 'B) and
octal ('o or 'O).
X or Z values
Verilog has two symbols for unknown and high impedance values. These values
are very important for modeling real circuits. An unknown value is denoted by an
x. A high impedance value is denoted by z.
A question mark "?" is the Verilog HDL alternative for z in the context of
numbers. The ? is used to enhance readability in the casex and casez statements
Negative numbers
Negative numbers can be specified by putting a minus sign before the size for a
constant number. Size constants are always positive. It is illegal to have a minus
sign between <base format> and <number>. An optional signed specifier can be
added for signed arithmetic.
\n newline
\t tab
%% %
\\ \
\“ "
\ooo Character written in 1?3 octal digits
Value Set
Verilog supports four values and eight strengths to model the functionality of
real hardware. The four value levels are listed in
Verilog allows signals to have logic values and strength values. Logic values are 0, 1,
x, and z.
Logic strength values are used to resolve combinations of multiple signals and to
represent behavior of actual hardware elements as accurately as possible. Several
logic strengths are available.
Table A-1 shows the strength levels for signals. Driving strengths are used for
signal values that are driven on a net. Storage strengths are used to model charge
storage in trireg type nets
Supply zero is
as strong
as supply one
and so on …….
Signal Contention
Logic strength values can be used to resolve signal contention on nets that have
multiple drivers. There are many rules applicable to resolution of contention.
However, two cases of interest that are most commonly used are described below.
NETS
Variable
Integer
An integer is a general purpose register data type used for manipulating quantities.
Integers are declared by the keyword integer. Although it is possible to use reg as a
general-purpose variable, it is more convenient to declare an integer variable for
purposes such as counting.
The default width for an integer is the host-machine word size, which is
implementation-specific but is at least 32 bits. Registers declared as data type reg
store values as unsigned quantities, whereas integers store values as signed
quantities.
They can be specified in decimal notation (e.g., 3.14) or in scientific notation (e.g.,
3e6, which is 3 x 106 ). Real numbers cannot have a range declaration, and their
default value is 0. When a real value is assigned to an integer, the real number is
rounded off to the nearest integer.
A special time register data type is used in Verilog to store simulation time. A time
variable is declared with the keyword time.
The width for time register data types is implementation-specific but is at least 64
bits.
The system function $time is invoked to get the current simulation time.
The starting bit of the part select can be varied, but the width has to be constant.
Arrays of nets can also be used to connect ports of generated instances. Each
element of the array can be used in the same fashion as a scalar or vector net.
port_id [0]
reg [4:0] port_id [0:7];
port_id [1]
Identifier/
variable name
port_id 7
Vector i.e each Array i.e.
Port_ids is 5 bits 8 Port_ids are created
Memories
In digital simulation, one often needs to model register files, RAMs, and ROMs.
Memories are modeled in Verilog simply as a one-dimensional array of registers.
reg mem1bit[0:1023]; // Memory mem1bit with 1K 1-bit words //array of 1 bit registers
reg [7:0] membyte[0:1023]; // Memory membyte with 1K 8-bit words(bytes)
//array of 8 bit registers.
Displaying information
$display is the main system task for displaying values of variables or strings or
expressions. This is one of the most useful tasks in Verilog.
Usage: $display(p1, p2, p3,....., pn);
p1, p2, p3,..., pn can be quoted strings or variables or expressions.
A $display inserts a newline at the end of the string by default. A $display without
any arguments produces a newline.
Format Display
%d or %D Display variable in decimal both small and
%b or %B Display variable in binary capital letters
%s or %S Display string can be used as
%h or %H Display variable in hex specifier
%c or %C Display ASCII character
Verilog provides a mechanism to monitor a signal when its value changes. This facility
is provided by the $monitor task.
Usage: $monitor(p1,p2,p3,....,pn);
The parameters p1, p2, ... , pn can be variables, signal names, or quoted strings. A
format similar to the $display task is used in the $monitor task.
$monitor continuously monitors the values of the variables or signals specified in the
parameter list and displays all parameters in the list whenever the value of any one
variable or signal changes. Unlike $display, $monitor needs to be invoked only once.
Only one monitoring list can be active at a time. If there is more than one $monitor
statement in your simulation, the last $monitor statement will be the active statement.
The earlier $monitor statements will be overridden.
Two tasks are used to switch monitoring on and off.
Usage:
$monitoron;
$monitoroff;
The $monitoron tasks enables monitoring, and the $monitoroff task disables
monitoring during a simulation. Monitoring is turned on by default at the
beginning of the simulation and can be controlled during the simulation with
the $monitoron and $monitoroff tasks.
Stopping and finishing in a simulation
The $stop task puts the simulation in an interactive mode. The designer can then
debug the design from the interactive mode. The $stop task is used whenever the
designer wants to suspend the simulation and examine the values of signals in
the design.