Professional Documents
Culture Documents
VDS Unit 5 UE19EC352 Org
VDS Unit 5 UE19EC352 Org
Sumanth Sakkara
Department of Electronics and Communication Engineering.
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces:
Example: A chip may have multiple configurations. In one, the pins might
drive a USB bus, whereas in another the same pins may drive an I2C serial
bus. In these cases you can use a virtual interface so you can decide at run
time which drivers to run in your testbench.
Virtual Interfaces:
Virtual interfaces are the only mechanism that can bridge the dynamic
world of objects with the static world of modules and interfaces.
Virtual interface concept comes into the picture to use signals of interface. It is most
often used in classes to provide a connection point to allow classes to access the
signals in the interface through the virtual interface.
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
The Testbench with Just Physical Interfaces: ATM interfaces for the receive
directions
The Testbench with Just Physical Interfaces: ATM interfaces for the Transmit
Directions
Tx interface with clocking block:
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
The top module does not pass a clock to the testbench; instead the tests
synchronize with clocking blocks in the interfaces, thus allowing you to work at a
higher level of abstraction.
Example connects the DUT and test using an interface in the port list.
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
Example program block Test with an two interfaces in the port list
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
Test needs to connect to the physical interface in the harness , so use a cross
module reference (XMR) and a virtual interface in the program block.
Use a virtual interface (virtual bus_ifc bus) so you can assign it the
physical interface in the top level module (top.bus).
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
If you add a new interface to your design, the test harness changes,
but existing tests don’t have to change
If you add a new interface to your design, the test program.
You won’t have to modify existing tests, even if the design changes., hence reusable
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
To verifying a design is that it may have several configurations. You could make a
separate testbench for each configuration, instead use virtual interfaces to
dynamically connect to the optional interfaces.
A Mesh Design:
Consider an 8-bit counter. This resembles a DUT that has a device such as a
network chip or processor that is instantiated repeatedly in a mesh
configuration.
The key idea is that the top-level module creates an array of interfaces and
counters.
The testbench can connect its array of virtual interfaces to the physical
ones.
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
Top-level module
A class contains both variables and routines, similarly an interface can contain code
(procedural code) such as routines (task), assertions, and initial and always blocks .
Interface includes the signals and functionality of the communication between two blocks.
(modport, task, etc)
The inner workings of these routines are hidden from the external blocks
Access to these routines is controlled using the modport statement, just as with signals. A
task or function is imported into a modport so that it is then visible to any block that uses the
modport .
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
These routines can be used by both the design and the testbench. Hence same protocol.
If only one person implements the interface protocol for both parts, who checks it? You can
verify a protocol with assertions in an interface.
An assertion can check for illegal combinations, such as protocol violations and unknown
values.
Functional coverage code uses this type of assertion to trigger the gathering of coverage
information also.
VERIFICATION OF DIGITAL SYSTEMS
Virtual Interfaces with the ATM Router
An interface cannot have private data. Any code for verification needs
maximum flexibility and configurability, and so should go in classes that run in a
program block.
An interface can have routines that drive the signals and assertions to check
the protocol, but put the test in a program block, not an interface.
VERIFICATION OF DIGITAL SYSTEMS
A Complete SystemVerilog Testbench
Testbench program
The testbench program passes
the interfaces and signals
through the port list.
Testbench Blocks
The environment class:
Inside this class lies the blocks of your layered testbench, such as generators, drivers,
monitors, and scoreboard.
The environment class controls the sequencing of the four testbench steps: generate a
random configuration, build the testbench environment, run the test and wait for it to
complete, and a wrap_up phase to shut down the system and generate reports.
VERIFICATION OF DIGITAL SYSTEMS
A Complete SystemVerilog Testbench
Environment class
The environment class controls the sequencing
of the four testbench steps: generate a random
configuration, build the testbench environment,
run the test and wait for it to complete, and a
wrap_up phase to shut down the system and
generate reports.
56
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
57
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Layered Testbench
58
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
DUT: Half Adder Example (output s,c, input a,b)
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Packet class is also known as transaction class
Packet
We declare all the input and output signals available in the design in
the packet class
The inputs will be declared as rand
60
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Packet
61
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Generator: 1) The generator will randomize the input signals
2) The randomized inputs are put into the mailbox using the put method .put()
62
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Generator
63
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Mailbox: Used to pass the information from one class to another class
Driver: The Driver drives the stimulus into the DUT through interface
64
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Virtual Interface
65
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Driver
vif is a handle of virtual interface
66
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Monitor
The DUT receives the stimulus & generates the outputs
The outputs are sampled/collected in the monitor
67
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Monitor
68
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Reference Model
The RM is similar to DUT (Design Team) but created by the verification team
Sometimes RM will be written inside the score board
69
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Scoreboard
It is a comparator used to compare the output from the RM and the DUT
70
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
Scoreboard
71
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
72
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
73
VERIFICATION OF VLSI CIRCUITS USING SYSTEMVERILOG
SV Testbench Environment
74
VERIFICATION OF DIGITAL SYSTEMS
UNIT-5
Topic : Interfacing with C/C++
In Verilog, you can communicate with C routines using the Programming Language Interface
(PLI).
If you just want to connect a simple C routine using the PLI, you need to write dozens of lines
of code and it overheads your simulation as it copies data between the Verilog.
It allows the designer to easily call C functions from SystemVerilog and to export
SystemVerilog functions, so that they can be called from C.
Currently SystemVerilog only supports an interface to the C language. C++ code has to be
wrapped to look like C.
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
32-bit signed values are passed using the SystemVerilog int data type that maps
directly to the C int type.
The SystemVerilog int is always 32 bits, whereas the width of an int in C is operating
system dependent. The C function takes an integer as an input and so the DPI passes
the argument by value.
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
You can import routines anywhere in your SystemVerilog code where you can declare a routine
including inside programs, modules, interfaces, packages, and $unit , the compilation-unit space.
The imported routine will be local to the declaration space in which it is declared.
If you need to call an imported routine in several locations in your code, put the import
statement in a package which you import where it is needed. Any changes to the import
statements are localized to the package.
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
Argument Directions :
Imported C routines can have zero or more arguments.
By default the argument direction is input (data goes from SystemVerilog to C), but can also be
output and inout .
A function can return a simple value such as an integer or real number, or have no return value if
you make it void .
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
Argument Directions :
A function can return a simple value such as an integer or real number, or have no return value if
you make it void .
Argument Directions :
C factorial routine with const argument
You can reduce the chances of bugs in your C code by declaring any input arguments as const as
shown in below example, so the C compiler will give an error for any write to an input. .
Argument Types
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
Argument Types
Example:
Create a C function, shift_c, that has two input arguments: a 32-bit unsigned input value i
and an integer for the shift amount n. The input i is shifted n places. When n is positive,
values are shifted left, when n is negative, shifted right, and when n is 0, no shift is
performed. The function returns the shifted value. Create a SystemVerilog module that
calls the C function and tests each feature. Provide the output.
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
Example:
Create a C function, shift_c, that has two input arguments: a 32-bit unsigned input value i and an
integer for the shift amount n. The input i is shifted n places. When n is positive, values are shifted
left, when n is negative, shifted right, and when n is 0, no shift is performed. The function returns
the shifted value. Create a SystemVerilog module that calls the C function and tests each feature.
Provide the output.
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
VERIFICATION OF DIGITAL SYSTEMS
Interfacing with C/C++
THANK YOU
Sumanth Sakkara
Department of Electronics and Communication
sumanthsakkara@pes.edu
+91 80 6666 3333 Ext 741
THANK YOU
Sumanth Sakkara
Department of Electronics and Communication
sumanthsakkara@pes.edu
+91 80 6666 3333 Ext 741