Vous êtes sur la page 1sur 8

A Comparative analysis of Verilog HDL over VHDL

Gurprasad Srivastava
Final Year B. Sc. Engineering, Faculty of Engineering, Dayalbagh Educational Institute, Agra
gurprasad@email.com

Introduction Cadence bought Gateway in 1989 and


Hardware description languages (HDLs) opened Verilog to the public domain in
were developed as a means to provide 1990. It became IEEE standard 1364 in
varying levels of abstraction to designers. December 1995.
Integrated circuits are too complex for an Verilog HDL
engineer to create by specifying the The Designer’s Choice
individual transistors and wires. HDLs allow
the performance to be described at a high Lexical Elements
level and simulation synthesis programs
The language is case sensitive and all the
can then take the language and generate
keywords are lower case. White space,
the gate level description. The search for
namely, spaces, tabs and new-lines are
the perfect HDL is like the search for the
ignored. Verilog has two types of
perfect car which probably doesn't exist.
comments:
With HDLs, it is no different. The decision
of which language to choose is based on a • One line comments start with //
number of important baseline requirements and end at the end of the line.
(factors), particularly for the first time user. • Multi-line comments start with /*
For the most part, the use of an HDL based and end with */
design strategy should improve the first Variable names have to start with an
time user's productivity. There are now two alphabetic character or underscore
industry standard hardware description followed by alphanumeric or underscore
languages, VHDL and Verilog. The characters. The only exception to this is the
complexity of ASIC and FPGA designs has system tasks and functions which start with
meant an increase in the number of a dollar sign. Escaped identifiers (identifier
specialized design tools and their own whose first character is a backslash ( \ ))
libraries of macro and mega cells written in permit non alphanumeric characters in
either VHDL or Verilog. As a result, it is Verilog name. The escaped name includes
important that designers know both VHDL all the characters following the backslash
and Verilog and that EDA tools vendors until the first white space character.
provide tools that provide an environment Integer Literals
allowing both languages to be used in
unison. For example, a designer might Integer literals can have underscores
have a model of a USB interface written in embedded in them for improved readability.
VHDL, but wants to use it in a design with For example,
macros written in Verilog. Binary literal 2’b1Z
Octal literal 2’O17
History Decimal literal 9 or ’d9
Hexadecimal literal 3’h189
VHDL became IEEE standard 1076 in
Decimal literal 24_000
1987. It was updated in 1993 and is known
today as "IEEE standard 1076 1993". The Data Types
Verilog HDL has been used far longer than
VHDL and has been used extensively The values z and Z stand for high
since it was launched by Gateway in 1983. impedance and x and X stand for
uninitialized variables or nets with stronger driver. If two drivers of equal
conflicting drivers. String symbols are strength have different values, then the
enclosed within double quotes wire resolves to x. A trireg net behaves
(“string”).and cannot span multiple lines. like a wire except that when all the drivers
Real number literals can be either in fixed of the net are in high impedance (z) state,
notation or in scientific notation. then the net retains its last driven value.
real a, b, c ; // a,b,c to be real trireg’s are used to model capacitive
integer j, k ; // integer variable
integer i[1:32] ; // array of
networks.
integer variables A wand net or triand net operates as a
time newtime ;
/* time and integer are similar in wired and(wand), and a wor net or trior
functionality, time is an unsigned net operates as a wired or (wor), tri0 and
64-bit used for time variables */
reg [8*14:1] string ; /* This tri1 nets model nets with resistive pulldown
defines a vector with range
[msb_expr: lsb_expr] */
or pullup devices on them. When a tri0 net
initial begin is not driven, then its value is 0. When a
a = 0.5 ; // same as 5.0e-1. real
variable tri1 net is not driven, then its value is 1.
b = 1.2E12 ; supply0 and supply1 model nets that are
c = 26.19_60_e-11 ; /* _’s are
used for readability */ connected to the ground or power supply.
string = “ string example ” ;
newtime =$time; Memories are declared using register
end statements with the address range
specified as in the following example, The
keyword scalared allows access to bits
and parts of a bus and vectored allows the
Registers and Nets
vector to be modified only collectively.
A register stores its value from one wire vectored [5:0] neta;
assignment to the next and is used to /* a 6-bit vectored net */
tri1 vectored [5:0] netb;
model data storage elements. /* a 6-bit vectored tri1 */

reg [5:0] din ; /* a 6-bit


vector register: individual
bits din[5],.... din[0] */ Compiler Directives

Nets correspond to physical wires that Verilog has compiler directives which affect
connect instances. The default range of a the processing of the input files. The
wire or reg is one bit. Nets do not store directives start with a grave accent ( ‘ )
values and have to be continuously driven. followed by some keyword. A directive
If a net has multiple drivers (for example takes effect from the point that it appears in
two gate outputs are tied together), then the file until either the end of all the files, or
the net value is resolved according to its until another directive that cancels the
type. effect of the first one is encountered. For
wire tri
example,
wand triand ‘define OPCODEADD 00010
wor trior
tri0 tri1
supply0 supply1 This defines a macro named
trireg
OPCODEADD. When the text
‘OPCODEADD appears in the text, then it

For a wire, if all the drivers have the same is replaced by 00010. Verilog macros are
value then the wire resolves to this value. If simple text substitutions and do not permit
all the drivers except one have a value of z arguments.
then the wire resolves to the non z value. If ‘ifdef SYNTH <Verilog code>
‘endif
two or more non z drivers have different
drive strength, then the wire resolves to the
If ‘‘SYNTH’’ is a defined macro, then the A list of standard system tasks and
Verilog code until ‘endif is inserted for the functions are listed below:
next processing phase. If ‘‘SYNTH’’ is not $display, $write - utility to
defined macro then the code is discarded. display information
$fdisplay, $fwrite - write to
`include <Verilog file> file
$strobe, $fstrobe -
display/write simulation data
The code in <Verilog file> is inserted for $monitor, $fmonitor - monitor,
the next processing phase. Other standard display/write information to
file
compiler directives are listed below: $time, $realtime - current
simulation time
$finish - exit the simulator
‘resetall - resets all $stop - stop the simulator
compiler directives to default $setup - setup timing check
values $hold, $width- hold/width timing
‘define - text-macro check
substitution $setuphold - combines hold and
‘timescale 1ns / 10ps - setup
specifies time unit/precision $readmemb/$readmemh - read
‘ifdef, ‘else, ‘endif - stimulus patterns into memory
conditional compilation $sreadmemb/$sreadmemh - load
‘include - file inclusion data into memory
‘signed, ‘unsigned - operator $getpattern - fast processing of
selection (OVI 2.0 only) stimulus patterns
‘celldefine, ‘endcelldefine - $history - print command history
library modules $save, $restart, $incsave
‘default_nettype wire - - saving, restarting,
default net types incremental saving
‘unconnected_drive $scale - scaling timeunits from
pull0|pull1, another module
‘nounconnected_drive - pullup $scope - descend to a particular
or down unconnected ports hierarchy level
‘protect and ‘endprotect - $showscopes - complete list of
encryption capability named blocks, tasks, modules...
‘protected and ‘endprotected - $showvars - show variables at
encryption capability scope
‘expand_vectornets,
‘noexpand_vectornets,
‘autoexpand_vectornets -
vector expansion options
‘remove_gatename,
‘noremove_gatenames
- remove gate names for more
than one instance
‘remove_netname,
‘noremove_netnames
Reserved Keywords
- remove net names for more The following lists the reserved words of
than one instance
Verilog hardware description language, as
of OVI LRM 2.0.
and always assign attribute
begin buf bufif0 bufif1
case cmos deassign default
defparam disable else
endattribute end endcase
endfunction endprimitive
System Tasks and Functions endmodule endtable endtask
System tasks are tool specific tasks and event for force
forever fork function highz0
functions. highz1 if initial inout
input integer join large
$display( “Example of using medium module nand negedge
function”); /* display to screen nor not notif0 notif1
*/ nmos or output parameter
$monitor($time, “a=%b, clk = %b, pmos posedge primitive
add=%h”,a,clk,add); // monitor pulldown pullup pull0 pull1
signals rcmos reg release repeat
$setuphold( posedge clk, datain, rnmos rpmos rtran rtranif0
setup, hold); // setup and hold rtranif1 scalared small specify
checks specparam strong0 strong1
supply0 supply1 table task
tran tranif0 tranif1 time tri vectored or scalared nets, registers, bit-
triand trior trireg tri0 tri1
vectored wait wand weak0 weak1
selects, part selects, function
while wire wor calls or concatenations thereof.
• Unary Expression
Structures and Hierarchy <operator> <operand>
a=!b;
Hierarchical HDL structures are achieved • Binary and Other Expressions
by defining modules and instantiating <operand> <operator> <operand>
modules. Nested module definitions (i.e.
one module definition within another) are if (a < b ) // if (<expression>)
not permitted. {c,d} = a + b ;
// concatenate and add operator
Module Declarations
• Parentheses can be used to change the
The module name must be unique and no precedence of operators. For example,
other module or primitive can have the ((a+b) * c)
same name. The port list is optional. A
module without a port list or with an empty • All operators associate left to right, except
port list is typically a top level module. A for the ternary operator “?:” which
macromodule is a module with a flattened associates from right to left.
hierarchy and is used by some simulators
for efficiency. Verilog or VDHL
module dff (q,qb,clk,d,rst); There are two aspects to modelling
input clk,d,rst ; // input
signals hardware that any HDL facilitates; True
output q,qb ; // output Abstract Behaviour and Hardware
definition
//inout for bidirectionals Structure. This means modelled hardware
// Net type declarations behaviour is not prejudiced by structural or
wire dl,dbl ;
// parameter value assignment design aspects of hardware intent and that
paramter delay1 = 3,
delay2 = delay1 + 1; // delay2
hardware structure is capable of being
// shows parameter dependance modelled irrespective of the design's
/* Hierarchy primitive
instantiation, port
behaviour. Here we compare the two HDLs
connection in this section is by for their various similarities and differences.
ordered list */
nand #delay1 n1(cf,dl,cbf), Capability
n2(cbf,clk,cf,rst);
nand #delay2 n3(dl,d,dbl,rst), Hardware structure can be modelled
n4(dbl,dl,clk,cbf),
n5(q,cbf,qb), equally effectively in both VHDL and
n6(qb,dbl,q,rst); Verilog. When modelling abstract
/***** for debuging model
initial begin hardware, the capability of VHDL can
#500 force dff_lab.rst = 1 ; sometimes only be achieved in Verilog
#550 release dff_lab.rst;
// upward path referencing when using the PLI. The choice of which to
end ********/ use is not therefore based solely on
endmodule
technical capability but on:
• personal preferences
• EDA tool availability
• commercial, business and marketing
Expressions and Operators issues
The modelling constructs of VHDL and
Arithmetic and logical operators are used Verilog cover a slightly different spectrum
to build expressions. Expressions across the levels of behavioural
perform operation on one or more abstraction.
operands, the operands being
hardware structure as opposed to abstract
hardware modelling. Unlike VHDL, all data
types used in a Verilog model are defined
by the Verilog language and not by the
user. There are net data types, for example
wire, and a register data type called reg. A
model with a signal whose type is one of
the net data types has a corresponding
electrical wire in the implied modelled
circuit. Objects that are signals of type reg
hold their value over simulation delta
Comparative capabilities of Verilog & VHDL cycles and should not be confused with the
modelling of a hardware register. Verilog
Compilation may be preferred because of its simplicity.
VHDL - Multiple design–units which reside Design Reusability
in the same system file may be separately
compiled if so desired. However, it is good VHDL - Procedures and functions may be
design practice to keep each design unit in placed in a package so that they are avail
its own system file in which case separate able to any design-unit that wishes to use
compilation should not be an issue. them.
Verilog - The Verilog language is still Verilog - There is no concept of packages
rooted in its native interpretative mode. in Verilog. Functions and procedures used
Compilation is a means of speeding up within a model must be defined in the
simulation, but has not changed the module. To make functions and procedures
original nature of the language. As a result generally accessible from different module
care must be taken with both the statements the functions and procedures
compilation order of code written in a single must be placed in a separate system file
file and the compilation order of multiple and included using the `include compiler
files. Simulation results can change by directive.
simply changing the order of compilation.
Easiest to Learn
Data Types
Starting with zero knowledge of either
VHDL - A multitude of language or user language, Verilog is probably the easiest to
defined data types can be used. This may grasp and understand. This assumes the
mean dedicated conversion functions are Verilog compiler directive language for
needed to convert objects from one type to simulation and the PLI language is not
another. The choice of which data types to included. If these languages are included
use should be considered wisely, they can be looked upon as two additional
especially enumerated (abstract) data languages that need to be learned. VHDL
types. This will make models easier to may seem less intuitive at first for two
write, clearer to read and avoid primary reasons. First, it is very strongly
unnecessary conversion functions that can typed; a feature that makes it robust and
clutter the code. VHDL may be preferred powerful for the advanced user after a
because it allows a multitude of language longer learning phase. Second, there are
or user defined data types to be used. many ways to model the same circuit,
especially those with large hierarchical
Verilog - Compared to VHDL, Verilog data structures.
types a re very simple, easy to use and
very much geared towards modelling
Forward & back annotation more likely, a Verilog tool vendor, can
specify user defined tasks or functions in
A spin-off from Verilog is the Standard the C programming language, and then call
Delay Format (SDF). This is a general them from the Verilog source description.
purpose format used to define the timing Use of such tasks or functions make a
delays in a circuit. The format provides a Verilog model non-standard and so may
bidirectional link between, chip layout tools, not be usable by other Verilog tools. Their
and either synthesis or simulation tools, in use is not recommended.
order to provide more accurate timing
representations. The SDF format is now an Libraries
industry standard in it's own right. VHDL - A library is a store for compiled
High Level Constructs entities, architectures, packages and
configurations; useful for managing
VHDL - There are more constructs and multiple design projects.
features for high-level modelling in VHDL
Verilog - There is no concept of a library in
than there are in Verilog. Abstract data
Verilog. This is due to it's origins as an
types can be used along with the following
interpretive language.
statements:
• package statements for model reuse, Low Level Constructs
• configuration statements for configuring
design structure, VHDL - Simple two input logical operators
• generate statements for replicating are built into the language, they are: NOT,
structure, AND, OR, NAND, NOR, XOR and XNOR.
Any timing must be separately specified
• generic statements for generic models
using the after clause. Separate constructs
that can be individually characterized, for
defined under the VITAL language must be
example, bit width.
used to define the cell primitives of ASIC
All these language statements are useful in and FPGA libraries.
synthesizable models. Verilog - The Verilog language was
Verilog - Except for being able to originally developed with gate level
parameterize models by overloading modelling in mind, and so has very good
parameter constants, there is no equivalent constructs for modelling at this level and for
to the high-level VHDL modelling modelling the cell primitives of ASIC and
statements in Verilog. FPGA libraries. Examples include User
Defined Primitive s (UDP), truth tables and
Language Extensions the specify block for specifying timing
delays across a module.
The use of language extensions will make
a model non standard and most likely not
Managing large designs
portable across other design tools.
However, sometimes they are necessary in VHDL - Configuration, generate, generic
order to achieve the desired results. and package statements all help manage
large design structures.
VHDL - Has an attribute called 'foreign
that allows architectures and subprograms Verilog - There are no statements in
to be modelled in another language. Verilog that help manage large designs.
Verilog - The Programming Language Operators
Interface (PLI) is an interface mechanism
between Verilog models and Verilog The majority of operators are the same
software tools. For example, a designer, or between the two languages. Verilog does
have very useful unary reduction operators
that are not in VHDL. A loop statement can unit or some sub part of a design, and
be used in VHDL to perform the same connects it appropriately.
operation as a Verilog unary reduction
Verilog - There is no equivalent to the
operator. VHDL has the mod operator that
generate statement in Verilog.
is not found in Verilog.
Test harnesses
Parameterizable models
Designers typically spend about 50% of
VHDL - A specific bit width model can be
their time writing synthesizable models and
instantiated from a generic n-bit model
the other 50% writing a test harness to
using the generic statement. The generic
verify the synthesizable models. Test
model will not synthesize until it is
harnesses are not restricted to the
instantiated and the value of the generic
synthesizable subset and so are free to
given.
use the full potential of the language.
Verilog - A specific width model can be VHDL has generic and configuration
instantiated from a generic n-bit model statements that are useful in test
using overloaded parameter values. The harnesses, which are not found in Verilog.
generic model must have a default
parameter value defined. This means two Verboseness
things. In the absence of an overloaded VHDL - Because VHDL is a very strongly
value being specified, it will still synthesize, typed language models must be coded
but will use the specified default parameter precisely with defined and matching data
value. Also, it does not need to be types. This may be considered an
instantiated with an overloaded parameter advantage or disadvantage. However, it
value specified, before it will synthesize. does mean models are often more
Procedures and tasks verbose, and the code often longer, than its
Verilog equivalent.
VHDL allows concurrent procedure calls;
Verilog - Signals representing objects of
Verilog does not allow concurrent task
different bits widths may be assigned to
calls.
each other. The signal representing the
Readability smaller number of bits is automatically
padded out to that of the larger number of
This is more a matter of coding style and bits, and is independent of whether it is the
experience than language feature. VHDL is assigned signal or not. Unused bits will be
a concise and verbose language; its roots automatically optimized away during the
are based on ADA. Verilog is more like C synthesis process. This has the advantage
because its constructs are based of not needing to model quite so explicitly
approximately 50% on C and 50% on ADA. as in VHDL, but does mean unintended
For this reason an existing C programmer modelling errors will not be identified by an
may prefer Verilog over VHDL. Although an analyzer.
existing programmer of both C and ADA
may find the mix of constructs somewhat Conclusion
confusing at first. Whatever HDL is used,
when writing or reading an HDL model to To summarize, VHDL was developed (for
be synthesized it is important to think about the US DOD) to provide a consistent
hardware intent. modelling language for the documentation
of digital hardware designs. The language
Structural replication was never intended to be used to do actual
design.
VHDL - The generate statement replicates
a number of instances of the same design-
However, to maintain a supposed the dominant solution. Almost every major
competitive advantage, individual EDA computer manufacturer, system developer,
companies exerted considerable influence, ASIC and semiconductor manufacturer
resources and dollars to force the language uses Verilog HDL as their modelling
to become a design language. These same language.
EDA companies implemented their own For the first time HDL user the selection of
semi-unique versions of the language at Verilog HDL as your modelling language
different stages during its development. will be a very wise decision. It will mean
This means VHDL models that were there are a number of tools available from
developed on one system, may not run on schematic entry to synthesis to simulation
a different system. at various price ranges and on numerous
The language is difficult to learn and even platforms from PCs to mainframes. There
more difficult to use. It is extremely are also numerous libraries available from
verbose, especially at the gate level, when a variety of sources that support full timing
timing information is specific and based models with all the necessary delay
considerable. VHDL's verbosity causes functionality required to meet any critical
severe memory problems when trying to design needs. There is also a vast
simulate medium to large designs. ASIC resource of Verilog HDL engineering talent
vendors have been very reluctant to that has had experience using the
provide VHDL gate level libraries that language for practical commercial design
include full timing because of the size of to provide critical assistance if it becomes
the models and the abnormally long necessary. There are many HDLs you can
simulation times associated with validating choose from but only one that has proven
a relatively simple design. time and time again that it is the only
The framers of VHDL were driven by the choice for real designs.
US DOD, which has no material interest in The reasons for the importance of being
design productivity. VHDL's complex able to model hardware in both VHDL and
syntax interferes with design productivity Verilog have been discussed. VHDL and
and does not offer any strategic advantage Verilog has been extensively compared
that would improve the quality of the and contrasted in a neutral manner. The
design. This essentially undermines the choice of HDL is shown not to be based on
basic strength of VHDL, productivity technical capability, but on: personal
achieved via a methodology based on top- preferences, EDA tool availability and
down-design. commercial, business and marketing
Verilog HDL has been developed and will issues.
continue to evolve to address the needs Reference
and commercial applications of the design
community that has made it the most [1] VHDL & Verilog Compared &
successful language in use today. The Contrasted Plus Modeled Example Written
design community has invested almost 20 in VHDL, Verilog and C.
billion dollars in Verilog HDL and related Douglas J. Smith
tools over the last 8 years. The ability to [2] Verilog HDL vs. VHDL for the First
address higher level language constructs Time User.
are well supported in the language, along Bill Fuchs
with its rock solid structural (gate and [3] Quick Reference for Verilog HDL.
switch level) strengths. As long as Rajeev Madhavan
designers and their companies have to get [4] Verilog-A Reference Manual
high quality innovative products to market Agilent Technologies
in the time sensitive world in which we all [5] Verilog Hardware Description
compete, Verilog HDL will continue to be Language Reference Manual.
Open Verilog International

Vous aimerez peut-être aussi