344
Advanced Verification Features
Session delivered by:
Padmanaban K .
Session-09
345
Session Objectives
• To learn the concept of Direct Programming interface
• To understand the concept of System Verilog regions
• To learn the concept of Program and Clocking blocks
346
Session Topics
• Direct Programming interface
• Programming Language Interface
• System Verilog regions
• Program and Clocking Blocks
347
Verilog PLI
• The Verilog Programming Language Interface (PLI) provides
a mechanism for Verilog code to call functions written in the
C programming language.
• The venerable Verilog PLI is one of the reasons the Verilog
language has been so successful for hardware design.
• Using the PLI companies and end-users can extend the
capabilities of commercial Verilog simulators.
• Recently a new ―SystemVerilog‖, an extension to the IEEE
Verilog standard, which includes a new way for Verilog code
to call C and C++ functions.
• This interface eliminates the complexity of the earlier PLI
(programming language interface) that required users to
access HDL objects through a set of API and setup-explicit
callback methods.
• With earlier methods such as PLI, the user must setup an
explicit table to link HDL with C.
348
System Verilog DPI
• SystemVerilog DPI eliminates all this by allowing HDL
compiler to create the C interface and data access.
• DPI is an interface between System Verilog and a foreign
programming language.
• These Foreign languages can be a System C, C, C++ as well
as others.
• It consists of two separate layers: the System Verilog layer
and a foreign language layer.
• Both the layers are isolated from each other.
• Different programming languages can be used and supported
with the same intact System Verilog layer.
349
System Verilog DPI
• However, System Verilog defines a foreign language layer
only for the C programming language.
• The methodological requirement is that the interface should
allow a diversified system to be built (a design or a testbench)
in which some components can be written in a language (or
more
• languages) other than System Verilog, hereinafter called the
foreign language.
• On a practical aspect for an easy and efficient way to connect
existing code is to write in C or C++, without the knowledge
and the overhead of PLI or VPI.
350
Two layers of the DPI
• DPI consists of two separate layers: the SystemVerilog layer
and a foreign language layer.
• The SystemVerilog layer does not depend on which
programming language is actually used as the foreign
language.
• SystemVerilog code shall look identical and its semantics
shall be unchanged for any foreign language layer.
• Different SystemVerilog requires only that its
implementation shall support C protocols and linkage.
351
SystemVerilog layer
• The SystemVerilog side of DPI does not depend on the
foreign programming language.
• In the function call protocol and argument passing
mechanisms used in the foreign language are transparent and
irrelevant to SystemVerilog.
• SystemVerilog code shall look identical to the foreignside of
the interface.
• This clause does not constitute a complete interface
specification.
• It only describes the functionality, semantics, and syntax of
the SystemVerilog layer of the interface.
352
Foreign language layer
• The foreign language layer of the interface specifies how
actual arguments are passed and how they can be accessed
from the foreign code and are represented.
• It reveals how they are translated to and from some
predefined C-like types.
• The data types allowed for formal arguments and results of
imported functions or exported functions are generally
SystemVerilog types.
• Software tools, like a SystemVerilog compiler, can facilitate
the mapping of SystemVerilog types onto foreign native
types by generating the appropriate function headers.
• The same SystemVerilog code (compiled accordingly) shall
be usable with different foreign language layers, regardless of
the data access method assumed in a specific layer.
353
Example DPI
Example:- import "DPI" function void myInit();
// from standard math library
import "DPI" pure function real sin(real);
// from standard C library: memory
management
import "DPI" function chandle malloc(int size);
// standard C function
import "DPI" function void free(chandle ptr); //
standard C function
354
Disabling DPI tasks and functions
• It is possible for a disable statement to disable a block that is
currently executing a mixed language call chain.
• When a DPI import task or function is disabled, the C code is
required to follow a simple disable protocol.
• The protocol gives the C code the opportunity to perform any
necessary resource cleanup, such as closing open file handles,
closing open VPI handles, or freeing heap memory.
355
Advantages and Limitations of DPI
• The ability to import a C function and then directly call the
function using the DPI is much simpler than the Verilog PLI.
• Using the DPI, the Verilog code can directly call the sin
function from the C math library, directly pass inputs to the
function, and directly receive value from the C function.
• Using the PLI, several steps are required to create a user
defined system task that indirectly calls and passes values to
the sin function.
Eg:- import "DPI" function real sin(real in);
always @(posedge clock)
begin slope <= sin(angle);
end
356
Advantages and Limitations of DPI
• DPI applications cannot schedule writing values into
simulation at a later stages simulation time.
• Verilog PLI applications can schedule value changes to
transpire at any future time.
• DPI task or function can have is limited types of formal
arguments data type that can have logic value.
• Where in verilog PLI can have function/task arguments with
both verilog and system verilog variables, net data types,
module instance and null arguments.
357
Advantages and Limitations of DPI
• DPI receives values directly from C functions as a functions
returns value.
• Other programming languages indirectly.
• C function can call verilog functions and task. No other
programmer has this facility.
• Concurrent calls to task use the C stack.
• The DPI import declaration contains a prototype of the
imported function arguments.
• The PLI does not define prototypes of system tasks and
functions.
358
Features
• The SystemVerilog Direct Programming Interface provides
an ideal solution for integratingVerilog models with System
C models.
• The DPI import declarations allow Verilog code to directly
call C code without the complexity and overhead of the
Verilog PLI.
• As DPI is a standard integrating model, Interfacing of
Verilog and SystemC becomes a simple and straightforward
process.
• To overcome the disadvantages of the Verilog PLI, DPI has
been introduced has got many advantages as listed.
• On the new era of system verilog DPI will replace PLI as it
has got many advanced features over PLI.
359
System Verilog Regions
360
IEEE Std 1800-2005 regions
361
IEEE Std 1800-2005 regions
362
SystemVerilog Event Regions and Advantages
• Active and NBA regions are designed for correct RTL
functionality.
• Preponed, Reactive, Re-Inactive and Postponed regions for
correct verification execution.
• Preponed, Observed, and Reactive regions for concurrent
assertion checking.
363
Preponed Events Region
• This region is to sample values that are used by concurrent
assertions.
• The Preponed region is executed only once in each timestep,
immediately after advancing simulation time.
• Concurrent assertions means the values of variables that are
used in assertions are sampled in the Preponed region of a
time slot, and the assertions are evaluated during the
Observed region.
• For a simulator its not necessary to know about any future
events, it only needs to ensure that the values present in the
• Preponed region are available to the sampling constructs,
when the clocking expression is actually triggered and while
processing the later regions.
364
Active Events Region
• Execute all module blocking assignments
• Evaluate the Right-Hand-Side (RHS) of all nonblocking
assignments and schedule updates into the NBA region.
• Execute all module continuous assignments
• Evaluate inputs and update outputs of Verilog primitives.
• Execute the $display and $finish commands.
365
Inactive Events Region
• Inactive region is where #0 blocking assignments are
scheduled.
• We should not make #0 RTL procedural assignments as per
the guideline.
• If we continue to use #0 assignments then we are trying to
defeat a race condition that might exist in the code due to
assignments made to the same variable from more than one
always block, which cause violation of Race Avoidance
Guideline #6.
• For good coding practices there are no need for #0 RTL
assignments and hence, the Inactive region will be deleted
from the rest of the events.
366
Nonblocking Assignment Region (BA).
• The main principal function of NBA region is to execute the
updates to the Left-Hand-Side (LHS) variables that were
scheduled in the Active region for all currently executing
nonblocking assignments.
• As Race Avoidance Guideline #1(for sequential logic use
non blocking assignment) dictates that all RTL clocked logic
modeled using an always block should be coded using
nonblocking assignments to ensure that the sequential logic
will execute in the NBA region and correctly model the
pipelined nature of sequential elements.
367
Observed Region
• This region evaluates the concurrent assertions using the
values sampled in the Preponed region.
• Assertions that execute a pass or fail action block, actually
schedule a process associated with the pass and fail code into
the Reactive region, not in the Observed region.
• This is because concurrent assertions are designed to behave
strictly as monitors and are not allowed to modify the state of
the design
368
Reactive Region
• Reactive region is to execute the verification processes call
forth by program blocks.
• The Reactive region is located towards the end of the time
step; at the same time will have an access to three key pieces
of information:
• The current set of steady-state values – at the start of the
current time step.
• The next set of steady-state values, after clock and signal
propagation.
• The disposition of all concurrent assertions triggered in this
timestep.
369
Re-Inactive Region
• Re-Inactive region run with the Reactive region until all
Reactive/Re-Inactive events have completed.
• RTL regions (Active-Inactive-NBA) will re-trigger if the
program execution scheduled any events in those regions in
the same timestep.
• Events are scheduled into the Re-Inactive region by
executing #0 in a program process.
• Re-Inactive region is the dual of the Inactive RTL region
which is not recommended.
370
Postponed Region
• Postponed Region execute the $strobe and $monitor
commands that will show the final updated values for the
current timestep.
• This region is also used to collect functional coverage for
items that use strobe sampling.
• There is no feedback path from the Postponed region back
into the RTL or Reactive-loop regions, so the values
displayed and the coverage collected will be the final values
for that timestep.
371
Clocking Blocks
• In Verilog, the communication between blocks is specified
using module ports.
• SystemVerilog adds the interface, a key construct that
encapsulates the communication between blocks, thereby
enabling users to easily change the level of abstraction at
which the inter-module communication is to be modeled.
• An interface can specify the signals or nets through which a
test bench communicates with a device under test.
• However, an interface does not explicitly specify any timing
disciplines, synchronization requirements, or clocking
paradigms.
372
Clocking Blocks
• SystemVerilog adds the clocking block that identifies clock
signals, and captures the timing and synchronization
requirements of the blocks being modeled.
• A clocking block assembles signals that are synchronous to a
particular clock, and makes their timing explicit.
• The clocking block is a key element in a cycle-based
methodology, which enables users to write test benches at a
higher level of abstraction.
• Rather than focusing on signals and transitions in time, the
test can be defined in terms of cycles and transactions.
• Depending on the environment, a test bench can contain one
or more clocking blocks, each containing its own clock plus
an arbitrary number of signals.
373
Example for Clocking Block
clocking ck1 @(posedge clk);
default input #1step output negedge; // legal
// outputs driven on the negedge clk
input ... ;
output ... ;
endclocking
clocking ck2 @(clk); // no edge specified!
default input #1step output negedge; // legal
input ... ;
output ... ;
endclocking
374
Example for Clocking Block
clocking bus @(posedge clock1);
default input #10ns output #2ns;
input data, ready, enable = top.mem1.enable;
output negedge ack;
input #1step addr;
endclocking
375
Program Block
• The module is the basic building block in Verilog. Modules
can contain hierarchies of other modules, wires, task and
function declarations, and procedural statements within
always and initial blocks.
• This construct works extremely well for the description of
hardware.
• However, for the test bench, the emphasis is not in the
hardware-level details such as wires, structural hierarchy, and
interconnects, but in modeling the complete environment in
which a design is verified.
• A lot of effort is spent getting the environment properly
initialized and synchronized, avoiding races between the
design and the test bench, automating the generation of input
stimuli, and reusing existing models and other infrastructure.
376
Program Block
• The program block serves three basic purposes:
1) It provides an entry point to the execution of testbenches.
2) It creates a scope that encapsulates program-wide data.
3) It provides a syntactic context that specifies scheduling in the
Reactive region.
377
Program Block
• The program construct serves as a clear separator between
design and testbench, and, more importantly, it specifies
specialized execution semantics in the Reactive region for all
elements declared within the program.
• Together with clocking blocks, the program construct
provides for race-free interaction between the design and the
testbench, and enables cycle and transaction level
abstractions.
378
Example
program test (input clk, input [16:1] addr, inout
[7:0] data);
initial ...
endprogram
or
program test ( interface device_ifc );
initial ...
endprogram
379
Summary
• SystemVerilog DPI eliminates all this by allowing HDL
compiler to create the C interface and data access
• The main principal function of NBA region is to execute the
updates to the Left-Hand-Side (LHS) variables that were
scheduled in the Active region for all currently executing
nonblocking assignments
• The SystemVerilog Direct Programming Interface provides
an ideal solution for integratingVerilog models with System
C models.

More Related Content

PDF
UVM Methodology Tutorial
PPTX
Introduction to System verilog
PDF
Coverage and Introduction to UVM
PDF
Session 8 assertion_based_verification_and_interfaces
PPTX
System verilog assertions
PDF
How to create SystemVerilog verification environment?
PPTX
SOC Verification using SystemVerilog
PDF
CPU Verification
UVM Methodology Tutorial
Introduction to System verilog
Coverage and Introduction to UVM
Session 8 assertion_based_verification_and_interfaces
System verilog assertions
How to create SystemVerilog verification environment?
SOC Verification using SystemVerilog
CPU Verification

What's hot (20)

PPTX
System verilog coverage
PDF
UVM TUTORIAL;
PDF
Challenges in Using UVM at SoC Level
PDF
System verilog important
PDF
Uvm presentation dac2011_final
PDF
verification_planning_systemverilog_uvm_2020
PPTX
ASIC design verification
PPTX
Verilog Tutorial - Verilog HDL Tutorial with Examples
ODP
axi protocol
PDF
Session 6 sv_randomization
PDF
Day2 Verilog HDL Basic
PDF
Verification challenges and methodologies - SoC and ASICs
DOCX
systemverilog-interview-questions.docx
PDF
Uvm cookbook-systemverilog-guidelines-verification-academy
PDF
System verilog verification building blocks
PDF
Functional verification techniques EW16 session
PDF
Verification Strategy for PCI-Express
ODP
APB protocol v1.0
PDF
Session 7 code_functional_coverage
PDF
UVM Update: Register Package
System verilog coverage
UVM TUTORIAL;
Challenges in Using UVM at SoC Level
System verilog important
Uvm presentation dac2011_final
verification_planning_systemverilog_uvm_2020
ASIC design verification
Verilog Tutorial - Verilog HDL Tutorial with Examples
axi protocol
Session 6 sv_randomization
Day2 Verilog HDL Basic
Verification challenges and methodologies - SoC and ASICs
systemverilog-interview-questions.docx
Uvm cookbook-systemverilog-guidelines-verification-academy
System verilog verification building blocks
Functional verification techniques EW16 session
Verification Strategy for PCI-Express
APB protocol v1.0
Session 7 code_functional_coverage
UVM Update: Register Package
Ad

Viewers also liked (11)

PPT
Aldec overview 2011-10 revised
PPTX
System Verilog 2009 & 2012 enhancements
PDF
System Verilog Functional Coverage
PPT
Timing Analysis
PPTX
System Verilog Tutorial - VHDL
PPT
system verilog
PDF
FIFO Design
PPTX
Verilog HDL
PDF
Fifo first in first out powerpoint ppt slides.
PPTX
First In, First Out (FIFO); Last In, Last Out (LIFO)
PPTX
Divide by N clock
Aldec overview 2011-10 revised
System Verilog 2009 & 2012 enhancements
System Verilog Functional Coverage
Timing Analysis
System Verilog Tutorial - VHDL
system verilog
FIFO Design
Verilog HDL
Fifo first in first out powerpoint ppt slides.
First In, First Out (FIFO); Last In, Last Out (LIFO)
Divide by N clock
Ad

Similar to Session 9 advance_verification_features (20)

PPT
Verilog Pli
PPT
SystemVerilog_veriflcation and UVM for IC design.ppt
PPT
SystemVerilog_veriflcation system verilog concepts for digital vlsi.ppt
PPT
SystemVerilog_verification_documents.ppt
PPT
SystemVerilog-20041201165354.ppt
PDF
The Verilog Pli Handbook 2nd Edition Stuart Sutherland
PDF
ESL Anyone?
PPT
Verilog Lecture2 thhts
PDF
Basic Synthesis Flow and Commands, Logic Synthesis
PDF
Basic synthesis flow and commands in digital VLSI
PPTX
HDL_verilog_unit_1 for engagement subjects and technology
PDF
VLSI System Verilog Notes with Coding Examples
PDF
Sva.pdf
PDF
The mixed-signal modelling language VHDL-AMS and its semantics (ICNACSA 1999)
PDF
Kroening et al, v2c a verilog to c translator
PPTX
System design using HDL - Module 2
PDF
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
PDF
Platform-independent static binary code analysis using a meta-assembly language
PDF
A Formal Executable Semantics Of Verilog
Verilog Pli
SystemVerilog_veriflcation and UVM for IC design.ppt
SystemVerilog_veriflcation system verilog concepts for digital vlsi.ppt
SystemVerilog_verification_documents.ppt
SystemVerilog-20041201165354.ppt
The Verilog Pli Handbook 2nd Edition Stuart Sutherland
ESL Anyone?
Verilog Lecture2 thhts
Basic Synthesis Flow and Commands, Logic Synthesis
Basic synthesis flow and commands in digital VLSI
HDL_verilog_unit_1 for engagement subjects and technology
VLSI System Verilog Notes with Coding Examples
Sva.pdf
The mixed-signal modelling language VHDL-AMS and its semantics (ICNACSA 1999)
Kroening et al, v2c a verilog to c translator
System design using HDL - Module 2
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
Platform-independent static binary code analysis using a meta-assembly language
A Formal Executable Semantics Of Verilog

More from Nirav Desai (6)

PPTX
SATA Protocol
PPTX
AMBA 2.0 PPT
PDF
AMBA 2.0 REPORT
PDF
“Optimized AES Algorithm Core Using FeedBack Architecture”
PDF
List of vlsi companies in bangalore
PDF
Xilinx design flow -By BhargavTarpara
SATA Protocol
AMBA 2.0 PPT
AMBA 2.0 REPORT
“Optimized AES Algorithm Core Using FeedBack Architecture”
List of vlsi companies in bangalore
Xilinx design flow -By BhargavTarpara

Recently uploaded (20)

PDF
UiPath Agentic Automation session 1: RPA to Agents
PPT
What is a Computer? Input Devices /output devices
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Build Your First AI Agent with UiPath.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
Microsoft Excel 365/2024 Beginner's training
PPTX
The various Industrial Revolutions .pptx
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
STKI Israel Market Study 2025 version august
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Five Habits of High-Impact Board Members
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
2018-HIPAA-Renewal-Training for executives
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
UiPath Agentic Automation session 1: RPA to Agents
What is a Computer? Input Devices /output devices
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Build Your First AI Agent with UiPath.pptx
Zenith AI: Advanced Artificial Intelligence
Microsoft Excel 365/2024 Beginner's training
The various Industrial Revolutions .pptx
A review of recent deep learning applications in wood surface defect identifi...
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
STKI Israel Market Study 2025 version august
sustainability-14-14877-v2.pddhzftheheeeee
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Five Habits of High-Impact Board Members
sbt 2.0: go big (Scala Days 2025 edition)
2018-HIPAA-Renewal-Training for executives
Custom Battery Pack Design Considerations for Performance and Safety
The influence of sentiment analysis in enhancing early warning system model f...
Convolutional neural network based encoder-decoder for efficient real-time ob...

Session 9 advance_verification_features

  • 1. 344 Advanced Verification Features Session delivered by: Padmanaban K . Session-09
  • 2. 345 Session Objectives • To learn the concept of Direct Programming interface • To understand the concept of System Verilog regions • To learn the concept of Program and Clocking blocks
  • 3. 346 Session Topics • Direct Programming interface • Programming Language Interface • System Verilog regions • Program and Clocking Blocks
  • 4. 347 Verilog PLI • The Verilog Programming Language Interface (PLI) provides a mechanism for Verilog code to call functions written in the C programming language. • The venerable Verilog PLI is one of the reasons the Verilog language has been so successful for hardware design. • Using the PLI companies and end-users can extend the capabilities of commercial Verilog simulators. • Recently a new ―SystemVerilog‖, an extension to the IEEE Verilog standard, which includes a new way for Verilog code to call C and C++ functions. • This interface eliminates the complexity of the earlier PLI (programming language interface) that required users to access HDL objects through a set of API and setup-explicit callback methods. • With earlier methods such as PLI, the user must setup an explicit table to link HDL with C.
  • 5. 348 System Verilog DPI • SystemVerilog DPI eliminates all this by allowing HDL compiler to create the C interface and data access. • DPI is an interface between System Verilog and a foreign programming language. • These Foreign languages can be a System C, C, C++ as well as others. • It consists of two separate layers: the System Verilog layer and a foreign language layer. • Both the layers are isolated from each other. • Different programming languages can be used and supported with the same intact System Verilog layer.
  • 6. 349 System Verilog DPI • However, System Verilog defines a foreign language layer only for the C programming language. • The methodological requirement is that the interface should allow a diversified system to be built (a design or a testbench) in which some components can be written in a language (or more • languages) other than System Verilog, hereinafter called the foreign language. • On a practical aspect for an easy and efficient way to connect existing code is to write in C or C++, without the knowledge and the overhead of PLI or VPI.
  • 7. 350 Two layers of the DPI • DPI consists of two separate layers: the SystemVerilog layer and a foreign language layer. • The SystemVerilog layer does not depend on which programming language is actually used as the foreign language. • SystemVerilog code shall look identical and its semantics shall be unchanged for any foreign language layer. • Different SystemVerilog requires only that its implementation shall support C protocols and linkage.
  • 8. 351 SystemVerilog layer • The SystemVerilog side of DPI does not depend on the foreign programming language. • In the function call protocol and argument passing mechanisms used in the foreign language are transparent and irrelevant to SystemVerilog. • SystemVerilog code shall look identical to the foreignside of the interface. • This clause does not constitute a complete interface specification. • It only describes the functionality, semantics, and syntax of the SystemVerilog layer of the interface.
  • 9. 352 Foreign language layer • The foreign language layer of the interface specifies how actual arguments are passed and how they can be accessed from the foreign code and are represented. • It reveals how they are translated to and from some predefined C-like types. • The data types allowed for formal arguments and results of imported functions or exported functions are generally SystemVerilog types. • Software tools, like a SystemVerilog compiler, can facilitate the mapping of SystemVerilog types onto foreign native types by generating the appropriate function headers. • The same SystemVerilog code (compiled accordingly) shall be usable with different foreign language layers, regardless of the data access method assumed in a specific layer.
  • 10. 353 Example DPI Example:- import "DPI" function void myInit(); // from standard math library import "DPI" pure function real sin(real); // from standard C library: memory management import "DPI" function chandle malloc(int size); // standard C function import "DPI" function void free(chandle ptr); // standard C function
  • 11. 354 Disabling DPI tasks and functions • It is possible for a disable statement to disable a block that is currently executing a mixed language call chain. • When a DPI import task or function is disabled, the C code is required to follow a simple disable protocol. • The protocol gives the C code the opportunity to perform any necessary resource cleanup, such as closing open file handles, closing open VPI handles, or freeing heap memory.
  • 12. 355 Advantages and Limitations of DPI • The ability to import a C function and then directly call the function using the DPI is much simpler than the Verilog PLI. • Using the DPI, the Verilog code can directly call the sin function from the C math library, directly pass inputs to the function, and directly receive value from the C function. • Using the PLI, several steps are required to create a user defined system task that indirectly calls and passes values to the sin function. Eg:- import "DPI" function real sin(real in); always @(posedge clock) begin slope <= sin(angle); end
  • 13. 356 Advantages and Limitations of DPI • DPI applications cannot schedule writing values into simulation at a later stages simulation time. • Verilog PLI applications can schedule value changes to transpire at any future time. • DPI task or function can have is limited types of formal arguments data type that can have logic value. • Where in verilog PLI can have function/task arguments with both verilog and system verilog variables, net data types, module instance and null arguments.
  • 14. 357 Advantages and Limitations of DPI • DPI receives values directly from C functions as a functions returns value. • Other programming languages indirectly. • C function can call verilog functions and task. No other programmer has this facility. • Concurrent calls to task use the C stack. • The DPI import declaration contains a prototype of the imported function arguments. • The PLI does not define prototypes of system tasks and functions.
  • 15. 358 Features • The SystemVerilog Direct Programming Interface provides an ideal solution for integratingVerilog models with System C models. • The DPI import declarations allow Verilog code to directly call C code without the complexity and overhead of the Verilog PLI. • As DPI is a standard integrating model, Interfacing of Verilog and SystemC becomes a simple and straightforward process. • To overcome the disadvantages of the Verilog PLI, DPI has been introduced has got many advantages as listed. • On the new era of system verilog DPI will replace PLI as it has got many advanced features over PLI.
  • 19. 362 SystemVerilog Event Regions and Advantages • Active and NBA regions are designed for correct RTL functionality. • Preponed, Reactive, Re-Inactive and Postponed regions for correct verification execution. • Preponed, Observed, and Reactive regions for concurrent assertion checking.
  • 20. 363 Preponed Events Region • This region is to sample values that are used by concurrent assertions. • The Preponed region is executed only once in each timestep, immediately after advancing simulation time. • Concurrent assertions means the values of variables that are used in assertions are sampled in the Preponed region of a time slot, and the assertions are evaluated during the Observed region. • For a simulator its not necessary to know about any future events, it only needs to ensure that the values present in the • Preponed region are available to the sampling constructs, when the clocking expression is actually triggered and while processing the later regions.
  • 21. 364 Active Events Region • Execute all module blocking assignments • Evaluate the Right-Hand-Side (RHS) of all nonblocking assignments and schedule updates into the NBA region. • Execute all module continuous assignments • Evaluate inputs and update outputs of Verilog primitives. • Execute the $display and $finish commands.
  • 22. 365 Inactive Events Region • Inactive region is where #0 blocking assignments are scheduled. • We should not make #0 RTL procedural assignments as per the guideline. • If we continue to use #0 assignments then we are trying to defeat a race condition that might exist in the code due to assignments made to the same variable from more than one always block, which cause violation of Race Avoidance Guideline #6. • For good coding practices there are no need for #0 RTL assignments and hence, the Inactive region will be deleted from the rest of the events.
  • 23. 366 Nonblocking Assignment Region (BA). • The main principal function of NBA region is to execute the updates to the Left-Hand-Side (LHS) variables that were scheduled in the Active region for all currently executing nonblocking assignments. • As Race Avoidance Guideline #1(for sequential logic use non blocking assignment) dictates that all RTL clocked logic modeled using an always block should be coded using nonblocking assignments to ensure that the sequential logic will execute in the NBA region and correctly model the pipelined nature of sequential elements.
  • 24. 367 Observed Region • This region evaluates the concurrent assertions using the values sampled in the Preponed region. • Assertions that execute a pass or fail action block, actually schedule a process associated with the pass and fail code into the Reactive region, not in the Observed region. • This is because concurrent assertions are designed to behave strictly as monitors and are not allowed to modify the state of the design
  • 25. 368 Reactive Region • Reactive region is to execute the verification processes call forth by program blocks. • The Reactive region is located towards the end of the time step; at the same time will have an access to three key pieces of information: • The current set of steady-state values – at the start of the current time step. • The next set of steady-state values, after clock and signal propagation. • The disposition of all concurrent assertions triggered in this timestep.
  • 26. 369 Re-Inactive Region • Re-Inactive region run with the Reactive region until all Reactive/Re-Inactive events have completed. • RTL regions (Active-Inactive-NBA) will re-trigger if the program execution scheduled any events in those regions in the same timestep. • Events are scheduled into the Re-Inactive region by executing #0 in a program process. • Re-Inactive region is the dual of the Inactive RTL region which is not recommended.
  • 27. 370 Postponed Region • Postponed Region execute the $strobe and $monitor commands that will show the final updated values for the current timestep. • This region is also used to collect functional coverage for items that use strobe sampling. • There is no feedback path from the Postponed region back into the RTL or Reactive-loop regions, so the values displayed and the coverage collected will be the final values for that timestep.
  • 28. 371 Clocking Blocks • In Verilog, the communication between blocks is specified using module ports. • SystemVerilog adds the interface, a key construct that encapsulates the communication between blocks, thereby enabling users to easily change the level of abstraction at which the inter-module communication is to be modeled. • An interface can specify the signals or nets through which a test bench communicates with a device under test. • However, an interface does not explicitly specify any timing disciplines, synchronization requirements, or clocking paradigms.
  • 29. 372 Clocking Blocks • SystemVerilog adds the clocking block that identifies clock signals, and captures the timing and synchronization requirements of the blocks being modeled. • A clocking block assembles signals that are synchronous to a particular clock, and makes their timing explicit. • The clocking block is a key element in a cycle-based methodology, which enables users to write test benches at a higher level of abstraction. • Rather than focusing on signals and transitions in time, the test can be defined in terms of cycles and transactions. • Depending on the environment, a test bench can contain one or more clocking blocks, each containing its own clock plus an arbitrary number of signals.
  • 30. 373 Example for Clocking Block clocking ck1 @(posedge clk); default input #1step output negedge; // legal // outputs driven on the negedge clk input ... ; output ... ; endclocking clocking ck2 @(clk); // no edge specified! default input #1step output negedge; // legal input ... ; output ... ; endclocking
  • 31. 374 Example for Clocking Block clocking bus @(posedge clock1); default input #10ns output #2ns; input data, ready, enable = top.mem1.enable; output negedge ack; input #1step addr; endclocking
  • 32. 375 Program Block • The module is the basic building block in Verilog. Modules can contain hierarchies of other modules, wires, task and function declarations, and procedural statements within always and initial blocks. • This construct works extremely well for the description of hardware. • However, for the test bench, the emphasis is not in the hardware-level details such as wires, structural hierarchy, and interconnects, but in modeling the complete environment in which a design is verified. • A lot of effort is spent getting the environment properly initialized and synchronized, avoiding races between the design and the test bench, automating the generation of input stimuli, and reusing existing models and other infrastructure.
  • 33. 376 Program Block • The program block serves three basic purposes: 1) It provides an entry point to the execution of testbenches. 2) It creates a scope that encapsulates program-wide data. 3) It provides a syntactic context that specifies scheduling in the Reactive region.
  • 34. 377 Program Block • The program construct serves as a clear separator between design and testbench, and, more importantly, it specifies specialized execution semantics in the Reactive region for all elements declared within the program. • Together with clocking blocks, the program construct provides for race-free interaction between the design and the testbench, and enables cycle and transaction level abstractions.
  • 35. 378 Example program test (input clk, input [16:1] addr, inout [7:0] data); initial ... endprogram or program test ( interface device_ifc ); initial ... endprogram
  • 36. 379 Summary • SystemVerilog DPI eliminates all this by allowing HDL compiler to create the C interface and data access • The main principal function of NBA region is to execute the updates to the Left-Hand-Side (LHS) variables that were scheduled in the Active region for all currently executing nonblocking assignments • The SystemVerilog Direct Programming Interface provides an ideal solution for integratingVerilog models with System C models.