systemverilog interface
DESCRIPTION
SystemVerilog Interface SystemVerilog InterfaceTRANSCRIPT
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 1/62
SystemVerilog Interfaces
1
Gi-Yong SongChungbuk National University, Korea
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 2/62
SystemVerilog
SystemVerilog extends the Verilog language with apowerful interface construct. Interfaces offer a new
paradigm for modeling abstraction. The use ofinterfaces can simplify the task of modeling and
verifying large, complex designs.
2
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 3/62
Interface concepts
The Verilog language connects modules togetherthrough module ports. This is a detailed method ofrepresenting the connections between blocks of a
design that maps directly to the physicalconnections that will be in the actual hardware.
3
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 4/62
For large designs, however, using module ports toconnect blocks of a design together can become
tedious and redundant
4
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 8/62
Disadvantages of Verilog’s
module ports
Declarations must be duplicated in multiplemodules.
Communication protocols must be duplicated in
several modules. There is a risk of mismatched declarations in
different modules.
A change in the design specification can requiremodifications in multiple modules.
8
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 9/62
Advantages of SystemVerilog
interfaces
SystemVerilog adds a powerful new port type toVerilog, called an interface. An interface allows a
number of signals to be grouped together andrepresented as a single port. The declarations of
the signals that make up the interface arecontained in a single location.
9
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 10/62
Each module that uses these signals then has asingle port of the interface type, instead of many
ports with the discrete signals.
10
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 13/62
In example above, all the signals that are incommon between the major blocks of the design
have been encapsulated into a single location—theinterface declaration called main_bus
13
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 14/62
The top-level module and all modules that makeup these blocks do not repetitively declare these
common signals. Instead, these modules simplyuse the interface as the connection between them.
14
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 15/62
SystemVerilog interface contents
The discrete signal and ports for communicationcan be defined in one location, the interface
Communication protocols can be defined in theinterface.
Protocol checking and other verification routinescan be built directly into the interface.
15
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 16/62
Differences between modules andinterface(1)
Unlike a module, an interface cannot containinstances of modules or primitives that would
create a new level of implementation hierarchy.
16
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 17/62
Differences between modules andinterface(2)
An interface can be used as a module port, whichis what allows interfaces to represent
communication channels between modules. It isillegal to use a module in a port list.
17
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 18/62
Differences between modules andinterface(3)
An interface can contain modports, which alloweach module connected to the interface to see the
interface differently.
18
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 21/62
Using interface as module ports
With SystemVerilog, a port of a module can bedeclared as an interface type, instead of the
Verilog input output or inout port directions.
21
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 22/62
Explicitly named interface ports
22
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 23/62
Generic interface ports
23
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 25/62
Interface modports
SystemVerilog interfaces provide a means todefine different views of the interface signals that
each module sees on its interface port.The definition is made within the interface, usingthe
modport
keyword. Modport
is an abbreviation
for module port
25
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 27/62
Specifying which modport view to
use
As part of the interface connection to a moduleinstance
As part of the module port declaration in themodule definition
27
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 30/62
Using modports to different sets of
connections
In a more complex interface between severaldifferent modules, it may be that not every module
needs to see the same set of signals within theinterface.
Modports make it possible to create a customized
view of the interface for each module connected.
30
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 33/62
Interface methods
SystemVerilog allows tasks and functions to bedeclared within an interface. These tasks and
functions are referred to as interface methods
33
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 34/62
The code for communication between modules is
only written once, as interface methods, andshared by each module connected using theinterface.
34
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 35/62
Within each module, the interface methods arecalled, instead of implementing the communication
protocol functionality within the module.
35
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 36/62
Importing interface methods
If the interface is connected via a modport, themethod must be specified using the import
keyword. The import definition is specified withinthe interface, as part of a modport definition.
36
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 37/62
Import using just the task or function name
Import using a full prototype of the task or function
37
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 38/62
Import using a task or function
name
38
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 39/62
Import using a task or function
prototype
39
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 41/62
Exporting tasks and functions
SystemVerilog interfaces and modports provide amechanism to define a task or function in onemodule, and then export the task or functionthrough an interface to other modules.
41
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 42/62
Exporting a task or function to the
entire interface
A task or function can also be exported to aninterface without using a modport.
This is done by declaring an extern prototype ofthe task or function within the interface.
42
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 44/62
44
R i i i k
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 45/62
Restrictions on exporting tasks
and functions
It is illegal to export the same task name from twodifferent modules, or two instances of the samemodule, into the same interface, unless an
extern
forkjoin
declaration is used. The multiple export of
a task corresponds to a multiple response to abroadcast.
45
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 46/62
Parameterized interface
Parameters can be used in interfaces to makevector sizes and other declarations within theinterface reconfigurable using Verilog’s parameterredefinition constructs.
46
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 48/62
Behavioral and TransactionLevel Modeling
48
T ti l l d li i
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 49/62
Transaction level modeling in
SystemVerilog
Whereas behavior level modeling raises theabstraction of the block functionality, transactionlevel modeling raises the abstraction level ofcommunication between blocks and subsystems,
by hiding the details of both control and data flowacross interfaces.
49
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 50/62
In SystemVerilog, a key use of the interface
construct is to be able to separate the descriptionsof the functionality of modules and thecommunication between them.
50
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 51/62
Transaction level modeling is a concept, and not a
feature of a specific language,
51
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 52/62
A fundamental capability that is needed for TLMsis to be able to encapsulate the lower level detailsof information exchange into function and taskcalls across an interface. The caller only needs to
know what data is sent and returned, with thedetails of the transmission being hidden in the
function/task call.
52
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 54/62
54
Transaction level models via
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 55/62
Transaction level models via
interface
This broadcast request with single response can be
conveniently modeled with the extern forkjoin taskconstruct in SystemVerilog interfaces.
55
7/17/2019 SystemVerilog Interface
http://slidepdf.com/reader/full/systemverilog-interface 62/62
References Stuart Sutherland, Simon Davidmann and Peter Fla
ke, “SystemVerilog for Design (2nd Edition): A Guide to Using SystemVerilog for Hardware Design and Modeling”, Springer, 2006.
Chris Spear, “SystemVerilog for Verification (2nd E
dition): A Guide to Learning the Testbench Language Features”, Springer, 2008.
Mike Mintz, Robert Ekendahl, “Hardware Verification with SystemVerilog : An Object-Oriented Framew
ork”, Springer, 2007. Mark Zwolinski, “Digital System Design With
SystemVerilog”, Addision-Wesley,2010.
62