Verification Academy

Search form

My Account Menu

  • Register
  • Log In
  • Topics
  • Courses
  • Forums
  • Patterns Library
  • Cookbooks
  • Events
  • More
  • All Topics
    The Verification Academy offers users multiple entry points to find the information they need. One of these entry points is through Topic collections. These topics are industry standards that all design and verification engineers should recognize. While we continue to add new topics, users are encourage to further refine collection information to meet their specific interests.
    • Languages & Standards

      • Portable Test and Stimulus
      • Functional Safety
      • Design & Verification Languages
    • Methodologies

      • UVM - Universal Verification Methodology
      • UVM Framework
      • UVM Connect
      • FPGA Verification
      • Coverage
    • Techniques & Tools

      • Verification IP
      • Simulation-Based Techniques
      • Planning, Measurement, and Analysis
      • Formal-Based Techniques
      • Debug
      • Clock-Domain Crossing
      • Acceleration
  • All Courses
    The Verification Academy is organized into a collection of free online courses, focusing on various key aspects of advanced functional verification. Each course consists of multiple sessions—allowing the participant to pick and choose specific topics of interest, as well as revisit any specific topics for future reference. After completing a specific course, the participant should be armed with enough knowledge to then understand the necessary steps required for maturing their own organization’s skills and infrastructure on the specific topic of interest. The Verification Academy will provide you with a unique opportunity to develop an understanding of how to mature your organization’s processes so that you can then reap the benefits that advanced functional verification offers.
    • Universal Verification Methodology (UVM)

      • Advanced UVM
      • Basic UVM
      • Introduction to UVM
      • UVM Connect
      • UVM Debug
      • UVMF - One Bite at a Time
    • Featured Courses

      • Introduction to ISO 26262
      • Introduction to DO-254
      • Clock-Domain Crossing Verification
      • Portable Stimulus Basics
      • Power Aware CDC Verification
      • Power Aware Verification
      • SystemVerilog OOP for UVM Verification
    • Additional Courses

      • Assertion-Based Verification
      • An Introduction to Unit Testing with SVUnit
      • Evolving FPGA Verification Capabilities
      • Metrics in SoC Verification
      • SystemVerilog Testbench Acceleration
      • Testbench Co-Emulation: SystemC & TLM-2.0
      • Verification Planning and Management
      • VHDL-2008 Why It Matters
    • Formal-Based Techniques

      • Formal Assertion-Based Verification
      • Formal-Based Technology: Automatic Formal Solutions
      • Formal Coverage
      • Getting Started with Formal-Based Technology
      • Handling Inconclusive Assertions in Formal Verification
      • Sequential Logic Equivalence Checking
    • Analog/Mixed Signal

      • AMS Design Configuration Schemes
      • Improve AMS Verification Performance
      • Improve AMS Verification Quality
  • All Forum Topics
    The Verification Community is eager to answer your UVM, SystemVerilog and Coverage related questions. We encourage you to take an active role in the Forums by answering and commenting to any questions that you are able to.
    • UVM Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • UVM Forum
    • SystemVerilog Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • SystemVerilog Forum
    • Coverage Forum

      • Active Questions
      • Solutions
      • Replies
      • No Replies
      • Search
      • Coverage Forum
    • Additional Forums

      • Announcements
      • Downloads
      • OVM Forum
  • Patterns Library
    The Verification Academy Patterns Library contains a collection of solutions to many of today's verification problems. The patterns contained in the library span across the entire domain of verification (i.e., from specification to methodology to implementation—and across multiple verification engines such as formal, simulation, and emulation).
    • Implementation Patterns

      • Environment Patterns
      • Stimulus Patterns
      • Analysis Patterns
      • All Implementation Patterns
    • Specification Patterns

      • Occurrence Property Patterns
      • Order Property Patterns
      • All Specification Patterns
    • Pattern Resources

      • Start Here - Patterns Library Overview
      • Whitepaper - Taking Reuse to the Next Level
      • Verification Horizons - The Verification Academy Patterns Library
      • Contribute a Pattern to the Library
  • All Cookbooks
    Find all the methodology you need in this comprehensive and vast collection. The UVM and Coverage Cookbooks contain dozens of informative, executable articles covering all aspects of UVM and Coverage.
    • UVM Cookbook

      • UVM Basics
      • Testbench Architecture
      • DUT-Testbench Connections
      • Configuring a Test Environment
      • Analysis Components & Techniques
      • End Of Test Mechanisms
      • Sequences
      • The UVM Messaging System
      • Other Stimulus Techniques
      • Register Abstraction Layer
      • Testbench Acceleration through Co-Emulation
      • Debug of SV and UVM
      • UVM Connect - SV-SystemC interoperability
      • UVM Versions and Compatibility
      • UVM Cookbook
    • Coding Guidelines & Deployment

      • Code Examples
      • UVM Verification Component
      • Package/Organization
      • Questa/Compiling UVM
      • SystemVerilog Guidelines
      • SystemVerilog Performance Guidelines
      • UVM Guidelines
      • UVM Performance Guidelines
    • Coverage Cookbook

      • Introduction
      • What is Coverage?
      • Kinds of Coverage
      • Specification to Testplan
      • Testplan to Functional Coverage
      • Bus Protocol Coverage
      • Block Level Coverage
      • Datapath Coverage
      • SoC Coverage Example
      • Requirements Writing Guidelines
      • Coverage Cookbook
  • All Events
    No one argues that the challenges of verification are growing exponentially. What is needed to meet these challenges are tools, methodologies and processes that can help you transform your verification environment. These recorded seminars from Verification Academy trainers and users provide examples for adoption of new technologies and how to evolve your verification process.
    • Upcoming & Featured Events

      • The Digital Twin: An Aerospace and Defense Revolution - March 9th
      • VIP solutions for Protocol and Memory Verification  - March 11th
      • Advance your Designs with Advances in CDC and RDC - March 23rd
      • Webinar Calendar
    • On Demand Seminars

      • The ABC of Formal Verification
      • I'm Excited About Formal...
      • 2020 Functional Verification Study
      • All On-Demand Seminars
    • Recording Archive

      • Improving Your SystemVerilog & UVM Skills
      • Should I Kill My Formal Run?
      • Visualizer Debug Environment
      • All Recordings
    • Conferences

      • DVCon 2020
      • DAC 2019
      • All Conferences
    • Mentor Learning Center

      • SystemVerilog Fundamentals
      • SystemVerilog UVM
      • View all Learning Paths
  • About Verification Academy
    The Verification Academy will provide you with a unique opportunity to develop an understanding of how to mature your organization's processes so that you can then reap the benefits that advanced functional verification offers.
    • Blog & News

      • Verification Horizons Blog
      • Academy News
      • Academy Newsletter
      • Technical Resources
    • Verification Horizons Publication

      • Verification Horizons - November 2020
      • Verification Horizons - July 2020
      • Verification Horizons - March 2020
      • Issue Archive
    • About Us

      • Verification Academy Overview
      • Subject Matter Experts
      • Contact Us
    • Training

      • Questa® & ModelSim®
      • Questa® inFact
      • Functional Verification Library
Ask a Question
UVM
  • Home
  • Forums
  • UVM
  • question on use_response_handler() and response_handler functions

question on use_response_handler() and response_handler functions

UVM 5577
puranik.sunil@tcs.com
puranik.sunil@tcs.com
Full Access
96 posts
January 20, 2021 at 4:09 am

Hello,
the UVM reference 1.1 states following :
"By default, responses from the driver are retrieved in the sequence by calling
get_response.
An alternative method is for the sequencer to call the response_handler function with
each response."

Assuming we want to use the response_handler function, which is a virtual method, how can it be used. Assuming that it needs to be extended to perform some additional functionality, how can we call the part of the method which actually reads the response item from response fifo. The signature of response_handler is :
virtual function void response_handler(uvm_sequence_item response)
Manual says method is called every time there is a response in response fifo, to keep the response fifo empty. If I need to extend this to say, count the total number of response items received and also get the response items for comparison with some members of request item class, how will the code look like? Do we need to call the original response_handler (of the base class) using super.response_handler() and retrieve the response items from the response fifo in extended method?
Can someone clarify please.
thanks,
-sunil puranik

Replies

Log In to Reply
chr_sue
chr_sue
Full Access
3254 posts
January 20, 2021 at 7:06 am

In reply to puranik.sunil@tcs.com:
Look here to see details of the response handler usage:
https://verificationacademy.com/cookbook/driver/pipelined

puranik.sunil@tcs.com
puranik.sunil@tcs.com
Full Access
96 posts
January 20, 2021 at 2:38 pm

Hello,
thanks for the reply and the link. My question was in fact referring to the same section from Cookbook given in the link.
The extended response_handler given there just increments the count and waits for count to go to 20 to ensure that sequence does not exit before 20 responses are collected in fifo. My question is if I need to read the response items also, how can I do it in the extended response_handler function? Do I need to call the version in base class, which will read the response items?
regards,
-sunil

chr_sue
chr_sue
Full Access
3254 posts
January 21, 2021 at 8:00 am

In reply to puranik.sunil@tcs.com:

You have 2 options to handle responses from the driver to the sequence:
(1) Sending back the response from the driver to the sequence using put or item_done: In the sequencer you have to execute get_response explicitly. This works perfectly with non-pipelined protocols.
(2) Using the response handler sends automatically a response to the sequence. You have to enable the response_handeler by calling use_response_handler(1); in the sequence (body task). And you have to override the function response_handler.
The implementation in the base class is doing nothing. One very simple implementation is to count the responses. This look like this:

function void response_handler(uvm_sequence_item response);
     count++;
endfunction: response_handler

It keeps also the reponse FIFO empty. Additionally you can add more functionality to this function. Using the response handler works with pipelined/out-of-order protocols.
puranik.sunil@tcs.com
puranik.sunil@tcs.com
Full Access
96 posts
January 21, 2021 at 9:24 pm

In reply to chr_sue:

Quote:
[i][=12]
The implementation in the base class is doing nothing. One very simple implementation is to count the responses. This look like this:
function void response_handler(uvm_sequence_item response);
     count++;
endfunction: response_handler

It keeps also the reponse FIFO empty. Additionally you can add more functionality to this function. Using the response handler works with pipelined/out-of-order protocols.

Hello,
thanks for the reply and information. If the implementation in base class is doing nothing as said above, how does one read the response items from the response fifo. The extended method you have given is only counting the response items. Can you please clarify. How are the response item read out of the response fifo by response_handler() method.
rgs,
-sunil puranik

chr_sue
chr_sue
Full Access
3254 posts
January 21, 2021 at 11:48 pm

In reply to puranik.sunil@tcs.com:

If you do not know what to do insert simply a diagnostic message like this:

function void response_handler(uvm_sequence_item response);
     count++;
     `uvm_info(get_type_name(), $sformatf("count = %0d, response = %p", count, response), UVM_MEDIUM)
endfunction: response_handler
puranik.sunil@tcs.com
puranik.sunil@tcs.com
Full Access
96 posts
January 22, 2021 at 7:11 pm

Hello,
my question is different:
If you are saying that "Using the response handler sends automatically a response to the sequence. You have to enable the response_handeler by calling use_response_handler(1)"

uvm_Reference manual says "By default, responses from the driver are retrieved in the sequence by calling get_response".
An alternative method is for the sequencer to call the response_handler function with
each response.

Now if the implementation of response_handler in base class is doing nothing as said above, how are the response items read out of the response fifo if response_handler() is used instead of get_Response(). I mean if resonse_handler() in base class is not doing anything, reading of the response items from response fifo needs to be performed in extended response_handler() method. But the response_handler() extended method above is just maintaining the count. Which portion of the code of the response_handler() is actually reading the response items from the response fifo.
rgs,
-sunil

chr_sue
chr_sue
Full Access
3254 posts
January 22, 2021 at 11:36 pm

In reply to puranik.sunil@tcs.com:

I have to precise my statement:
It is doing nothing with the response. But it is receiving the response, when enabled.
And the most simple action in the function is to print the response as I have proposed in my last post.

function void response_handler(uvm_sequence_item response);
     count++;
     `uvm_info(get_type_name(), $sformatf("count = %0d, response = %p", count, response), UVM_MEDIUM)
endfunction: response_handler

And don't forget to declare the count variable in your sequence.

puranik.sunil@tcs.com
puranik.sunil@tcs.com
Full Access
96 posts
January 23, 2021 at 6:34 pm

In reply to chr_sue:

Quote:
In reply to puranik.sunil@tcs.com:

I have to precise my statement:
It is doing nothing with the response. But it is receiving the response, when enabled.
And the most simple action in the function is to print the response as I have proposed in my last post.

Hi Thanks for the reply. If the response_handler() is a virtual function and function in base is receiving actual response, when we override response_handler() in extended sequence, we need to call the function in base IN ADDITION to the code which prints the response as given above. So it is necessary to add the statement super.response_handler() to call base implementation IN ADDITION to the code in extended sequence which overrides the base version.
I am not clear how this is done. Can you please clarify.
rgs,
-sunil

chr_sue
chr_sue
Full Access
3254 posts
January 24, 2021 at 12:09 am

In reply to puranik.sunil@tcs.com:

The response handler is a function without any functionality inside. It looks like this:

function void response_handler(uvm_sequence_item response);
endfunction: response_handler

If you want to use the response handler explicitly you have to write in your functionality, depending on your needs. It could look like this:

 class my_seq extends uvm_sequence  #(my_seq_item);
 `uvm_object_utils(my_seq)
 
   int my_addr = 0; // To save addresses
   int count; // To count the responses
 
 // Constructor
 function new (string name);
   super.new(name);
 endfunction: new
 
 // Task body()
 task body;
 
   my_seq_item req;
   my_seq_item rsp;
   req = my_seq_item::type_id::create("req", this);
   rsp = my_seq_item::type_id::create("rsp", this);
   use_response_handler(1); // Enable Response Handler
   count = 0;
 
   for(int i=0; i<10; i++) begin
     start_item(req);
     assert(req.randomize() with {addr == my_addr+2;});  
     finish_item(req);
   end
 
 // Wait till last seq item is over
   wait(count == 20);
 endtask: body
 
 /// This response_handler function is enabled to keep the sequence response FIFO empty
   function void response_handler(uvm_sequence_item response);
     $cast(rsp, response);
     `uvm_info(get_type_name(), $sformatf("count = %0d, rsp = %p", count, rsp), UVM_MEDIUM)
     my_addr = rsp.addr;
     count++;
   endfunction: response_handler
 
 endclass: my_seq
puranik.sunil@tcs.com
puranik.sunil@tcs.com
Full Access
96 posts
January 25, 2021 at 9:41 pm

Hello,
my question here is slightly different.
UVM reference states following :
"function void use_response_handler(bit enable)
When called with enable set to 1, responses will be sent to the response handler.
Otherwise, responses must be retrieved using get_response".

"By default, responses from the driver are retrieved in the sequence by calling
get_response.
An alternative method is for the sequencer to call the response_handler function with
each response.
"
Now responses are retrieved from resonse_queue by calling get_response. However, when we are not using get_response() and use the response_handler() by enabling it (by calling use_response_handler(1)), how are the responses read from response_queue. I mean which part of code of response_handler() is doing this. As you have said, implementation in base is doing nothing and extended response_handler() function is simply dispolaying some paratmeters of response. So my question is WHICH PART OF CODE IS ACTUALLY RETRIEIVING THE RESPONSE FROM RESONSE QUEUE IF THE GET_RESPONSE() IS NOT USED AND RESPONSE_HANDLER() IS USED INSTEAD.

regards,
-sunil puranik

chr_sue
chr_sue
Full Access
3254 posts
January 25, 2021 at 11:34 pm

In reply to puranik.sunil@tcs.com:

This is a theretical question you are asking. Look to the file uvm_sequence_base.svh in the UVM Class Library.

tez
tez
Forum Access
7 posts
January 31, 2021 at 9:23 am

In reply to puranik.sunil@tcs.com:
Hi puranik,
As mentioned by chr_sue,

function void use_response_handler(bit enable);
  m_use_response_handler = enable;
endfunction
set the variable inside the sequence_base and when the put_responses gets called from driver(we have to call it if want to return response), it calls
virtual function void response_handler(uvm_sequence_item response);
  return;
endfunction
if we set the use_response_handler(1). Hope this is helpful.
Siemens Digital Industries Software

Siemens Digital Industries Software

##TodayMeetsTomorrow

Solutions

  • Cloud
  • Mendix
  • Siemens EDA
  • MindSphere
  • Siemens PLM
  • View all portfolio

Explore

  • Digital Journeys
  • Community
  • Blog
  • Online Store

Siemens

  • About Us
  • Careers
  • Events
  • News and Press
  • Newsletter
  • Customer Stories

Contact Us

USA:

phone-office +1 800 547 3000

See our Worldwide Directory

  • Contact Us
  • Support Center
  • Give us Feedback
©2021 Siemens Digital Industries Software. All Rights Reserved.
Terms of Use Privacy Cookie Policy