Top Banner
SystemVerilog Interfaces 1 Gi-Yong Song Chungbuk National University, Korea
62

SystemVerilog Interface

Jan 08, 2016

Download

Documents

Ranadheer Reddy

SystemVerilog Interface
SystemVerilog Interface
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 1/62

SystemVerilog Interfaces

1

Gi-Yong SongChungbuk National University, Korea

Page 2: SystemVerilog Interface

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

Page 3: SystemVerilog Interface

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

Page 4: SystemVerilog Interface

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

Page 5: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 5/62

5

Page 6: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 6/62

6

Page 7: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 7/62

7

Page 8: SystemVerilog Interface

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

Page 9: SystemVerilog Interface

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

Page 10: SystemVerilog Interface

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

Page 11: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 11/62

11

Page 12: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 12/62

12

Page 13: SystemVerilog Interface

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

Page 14: SystemVerilog Interface

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

Page 15: SystemVerilog Interface

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

Page 16: SystemVerilog Interface

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

Page 17: SystemVerilog Interface

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

Page 18: SystemVerilog Interface

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

Page 19: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 19/62

19

Page 20: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 20/62

20

Page 21: SystemVerilog Interface

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

Page 22: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 22/62

Explicitly named interface ports

22

Page 23: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 23/62

Generic interface ports

23

Page 24: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 24/62

24

Page 25: SystemVerilog Interface

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

Page 26: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 26/62

26

Page 27: SystemVerilog Interface

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

Page 28: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 28/62

28

Page 29: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 29/62

29

Page 30: SystemVerilog Interface

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

Page 31: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 31/62

31

Page 32: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 32/62

32

Page 33: SystemVerilog Interface

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

Page 34: SystemVerilog Interface

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

Page 35: SystemVerilog Interface

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

Page 36: SystemVerilog Interface

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

Page 37: SystemVerilog Interface

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

Page 38: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 38/62

Import using a task or function

name

38

Page 39: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 39/62

Import using a task or function

prototype

39

Page 40: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 40/62

40

Page 41: SystemVerilog Interface

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

Page 42: SystemVerilog Interface

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

Page 43: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 43/62

43

Page 44: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 44/62

44

R i i i k

Page 45: SystemVerilog Interface

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

Page 46: SystemVerilog Interface

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

Page 47: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 47/62

47

Page 48: SystemVerilog Interface

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

Page 49: SystemVerilog Interface

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

Page 50: SystemVerilog Interface

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

Page 51: SystemVerilog Interface

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

Page 52: SystemVerilog Interface

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

Page 53: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 53/62

53

Page 54: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 54/62

54

Transaction level models via

Page 55: SystemVerilog Interface

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

Page 56: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 56/62

56

Page 57: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 57/62

57

Page 58: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 58/62

58

Page 59: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 59/62

59

Page 60: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 60/62

60

Page 61: SystemVerilog Interface

7/17/2019 SystemVerilog Interface

http://slidepdf.com/reader/full/systemverilog-interface 61/62

61

Page 62: SystemVerilog Interface

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