Pages

Wednesday, 16 October 2013

Dear Readers,

 Let us start looking at more UVM code examples going forward 


Let us print the  customary  "Hello World" example as the first step in learning UVM 
Use the same things which we used in Verilog programming

Please refer to the steps-1,2.. and the highlighted messages(in Blue)

-Happy Reading

Hash

//Step-1Take any dummymodule 

module dummy_helloworld;
//Step-2 Include the UVM Macros 
//If we dont include the UVM Macros the tool could not recognise
//the uvm_report_info and throws out an error message as below
//As UVM is a class based library and including the libraries for printing 
//uvm_report info would fix the issue
// Invalid argument. (errno = EINVAL)
// ** Error: F:/Hash/dummy_helloworld.sv(7): Failed to find 'uvm_report_info' in hierarchical name /uvm_report_info.
// Optimization failed
 import uvm_pkg::*;
initial
 begin
//Step-3 Print what you want
//Instead of our $display in Verilog we should use //uvm_report_info/warning/error/fatal 
//As this is just a message use "info",to display the string we wanted
//The main difference is this uvm_report_info/warning/error/fatal is it should be minimum //of  2 fields and a max of 5 fields
//Step-4Lets print  the strings "DUMMY_TEST" & "Hello World"  on the log file
 uvm_report_info("DUMMY_TEST","Hello_World");
 end
endmodule

*********************************************************************************

 QuestaSim vlog 10.0b Compiler 2011.05 May  5 2011
# -- Compiling module dummy_helloworld
# -- Importing package mtiUvm.uvm_pkg (uvm-1.0p1 Built-in)
# Top level modules:
# Loading sv_std.std
# Loading mtiUvm.uvm_pkg
# Loading work.dummy_helloworld(fast)
# Loading C:\questa_sim_10.0b\uvm-1.0p1\win32\uvm_dpi.dll
run
# ----------------------------------------------------------------
# UVM-1.0p1 
# (C) 2007-2011 Mentor Graphics Corporation
# (C) 2007-2011 Cadence Design Systems, Inc.
# (C) 2006-2011 Synopsys, Inc.
# ----------------------------------------------------------------
# UVM_INFO @ 0: reporter [DUMMY_TEST] Hello_World
********************************************************************************

Monday, 14 October 2013

Dear Readers

Lets take a look at a simple  objection mechanism which can be used to control the end of test
We are using the same template which is used for the first program "Hello world" to keep it simple 

-Happy Reading
Hash

*********************************************************************************
 program dummy_progrm;
 //Import the uvm_package
 import uvm_pkg::*;
`include "uvm_macros.svh"
class hello_world extends uvm_component;
//Factory registration
`uvm_component_utils(hello_world)
//Boiler plate code start
function new (string name,uvm_component parent);
super.new(name,parent);
endfunction
//Boiler plate code end 
virtual task run();
uvm_test_done.raise_objection(this);
uvm_report_info("Message","Hello World");
uvm_test_done.drop_objection(this);
global_stop_request();
//Print what all types are available in the factory
    factory.print();
    //Print the TB structure
   uvm_top.print_topology();
endtask
//standard phase methods
endclass
initial 
  begin
    run_test("hello_world");
      end
endprogram
*********************************************************************************

# Loading sv_std.std
# Loading mtiUvm.uvm_pkg
# Loading work.dummy_progrm(fast)
# Loading C:\questa_sim_10.0b\uvm-1.0p1\win32\uvm_dpi.dll
run
# ----------------------------------------------------------------
# UVM-1.0p1 
# (C) 2007-2011 Mentor Graphics Corporation
# (C) 2007-2011 Cadence Design Systems, Inc.
# (C) 2006-2011 Synopsys, Inc.
# ----------------------------------------------------------------
# UVM_INFO @ 0: reporter [RNTST] Running test hello_world...
# UVM_INFO @ 0: uvm_test_top [Message] Hello World
# 
#### Factory Configuration (*)
# 
#   No instance or type overrides are registered with this factory
# 
# All types registered with the factory: 37 total
# (types without type names will not be printed)
# 
#   Type Name
#   ---------
#   hello_world
# (*) Types with no associated type name will be printed as <unknown>
# 
####
# 
# UVM_INFO @ 0: reporter [UVMTOP] UVM testbench topology:
# --------------------------------------
# Name          Type         Size  Value
# --------------------------------------
# uvm_test_top  hello_world  -     @455 
# --------------------------------------
# 
# UVM_INFO verilog_src/uvm-1.0p1/src/base/uvm_objection.svh(1116) @ 0: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
# 
# --- UVM Report Summary ---
# 
# ** Report counts by severity
# UVM_INFO :    4
# UVM_WARNING :    0
# UVM_ERROR :    0
# UVM_FATAL :    0
# ** Report counts by id
# [Message]     1
# [RNTST]     1
# [TEST_DONE]     1
# [UVMTOP]     1
# ** Note: $finish    : C:/questa_sim_10.0b/win32/../verilog_src/uvm-1.0p1/src/base/uvm_root.svh(392)
#    Time: 0 ns  Iteration: 187  Instance: /dummy_progrm
# 1
# Break at C:/questa_sim_10.0b/win32/../verilog_src/uvm-1.0p1/src/base/uvm_root.svh line 392
Dear Readers

Lets discuss some more things about UVM agent.



  • Agents can be either active or passive
  • Agents provide all Verification logic for a DUT
  • An active agent is driven on an interface/device with all Sequencer/driver/Monitor being available
  • A passive agent has ONLY monitor available -Can do  checking & collect  coverage  
  • Any Bus protocol can have N no of devices each of which is represented as an agent 
  • An env has multiple agents which encapsulates and configures multiple agents, which is also known as UVC-Universal Verification component 
  • Encapsulation this UVCs makes it modular and easy to maintain and Virtual sequences enable control at System Level
Happy Reading
Hash
Dear Readers

Lets see how we can customize the factory and how you construct the agents
For constructing the agents we should use the create method,create checks for the factory over ride and constructs for the objects accordingly.

From the previous post lets get started without getting into if agent is active/passive, the sample code as below. 

******************************************************************************

class my_agent extends uvm_agent;
//Factory registration
// Using uvm_component_utils as agent is a TB component 
`uvm_component_utils(my_agent)
//External interfaces
virtual dut_if dut_ifs;
//Internal interfaces 
       monitor mon;
        driver drv;
//Boiler plate code start

     function new(string name, uvm_component parent);
         super.new(name, parent);
     endfunction
//Boiler plate code end
//Standard phase methods
function void build();
super.build();
//As the agent contains sequencer, driver, monitor we can construct the agent as below
uvm_report_info(get_full_name(),"Build", UVM_LOW);
//Customization using the factory
 my_seq_1  = my_seq ::type_id::create("my_seq_1", this);  
 my_driv_1 = my_driv::type_id::create("my_driv_1", this);   
my_mon_1  = my_mon ::type_id::create("my_mon_1", this);
 endfunction: build 

//Other Standard phase methods

     function void connect();
         uvm_report_info(get_full_name(),"Connect", UVM_LOW);
     endfunction

     function void end_of_elaboration();
         uvm_report_info(get_full_name(),"End_of_elaboration", UVM_LOW);
     endfunction

     function void start_of_simulation();
         uvm_report_info(get_full_name(),"Start_of_simulation", UVM_LOW);
     endfunction

     task run();
         uvm_report_info(get_full_name(),"Run", UVM_LOW);
     endtask

     function void extract();
         uvm_report_info(get_full_name(),"Extract", UVM_LOW);
     endfunction

     function void check();
         uvm_report_info(get_full_name(),"Check", UVM_LOW);
     endfunction

     function void report();
         uvm_report_info(get_full_name(),"Report", UVM_LOW);
     endfunction

endclass
*********************************************************************************

-Happy Reading
Hash

Sunday, 13 October 2013

Dear Readers

Please feel free to email me and all suggestions/feedback is welcome to make this small effort better.

Lets examine the basic structure of a UVM component and see how it looks like ,hope you find it useful.

The basic building items of a UVM component are as follows bounded between class, endclass keywords as below


class my_component extends uvm_component


1)factory registration
2)external interfaces
3)Internal component handles
4)Boiler plate code
5)Standard phase methods (which we have discussed in the previous blog)

endcomponent 

Let us discuss at these things one by one, this is NOT a clean compile example but can be used for writing UVM TB components

********************************************************************************

class my_component extends uvm_component;

// We need to use uvm_component_utils as uvm_object_utils is NOT used for 
//TB components .uvm_object_utils is used in stimulus generation part
//Factory registration 
`uvm_component_utils(my_component)
//external interfaces
virtual dut_if dut_ifs;
//Internal component handles
        monitor mon;
        driver drv;
//Boiler plate code start
//Boiler plate code which is mandatory for all UVM TB components
 function new(string name, uvm_component parent);
         super.new(name, parent);
//Boiler plate code end 
     endfunction

//Standard Phase methods
 function void build();
         uvm_report_info(get_full_name(),"Build", UVM_LOW);
            endfunction

     function void connect();
         uvm_report_info(get_full_name(),"Connect", UVM_LOW);
     endfunction

     function void end_of_elaboration();
         uvm_report_info(get_full_name(),"End_of_elaboration", UVM_LOW);
     endfunction

     function void start_of_simulation();
         uvm_report_info(get_full_name(),"Start_of_simulation", UVM_LOW);
     endfunction

     task run();
         uvm_report_info(get_full_name(),"Run", UVM_LOW);
     endtask

     function void extract();
         uvm_report_info(get_full_name(),"Extract", UVM_LOW);
     endfunction

     function void check();
         uvm_report_info(get_full_name(),"Check", UVM_LOW);
     endfunction

     function void report();
         uvm_report_info(get_full_name(),"Report", UVM_LOW);
     endfunction

endclass
*********************************************************************************

-Happy Reading
Hash
Dear Readers

First let me Wish you all Happy festive days
Please feel free to email me with your suggestions/feedback and i am open for any constructive ideas which makes this small effort get better




We all know that UVM has the following simulation phase methods-Build time,run time & clean up 

UVM Simulation phase methods can be classified as build,connect, end of elaboration, start of simulation, run and clean up phases(extract, check,report)

Build ,connect, end of elaboration ,start of simulation, run, extract, check,report ,Final
Out of these phases ONLY build is the top down method and all others are bottom up methods ,all phase methods except RUN are functions and RUN is a  task.

So lets see what actually happens in each and every simulation phase method here 

During the build phase the factory is called and used to Construct various child components/ ports/exports and configured,the top level testbench topology is built 

During the connect phase the TLM connections are made and the ports/exports of the components are Connected. i.e, the environment topology is connected.

During the end of elaboration the connections are checked and used for configuring the components. Post elaboration activity and the topology is printed 

During the start of simulation the various files are opened  banner information /topology would be being printed (as below)


# ----------------------------------------------------------------

# UVM-1.0p1 

# (C) 2007-2011 Mentor Graphics Corporation

# (C) 2007-2011 Cadence Design Systems, Inc.

# (C) 2006-2011 Synopsys, Inc.

# ----------------------------------------------------------------


During the run phase main test is executed and simulation is run
UVM adds 12 new phases which would be executed in parallel  with run_phase
These 12 new phases would be used to control stimulus which is explained as below

pre_reset,
reset
post_reset
pre_config
config
post_config
pre_main
main
post_main
pre_shutdown
shutdown
post_shutdown

The stimulus control being done by the objection mechanism, lets see the codes

class my_test_phase extends uvm_test_phase;
//Factory registration
//Use component utils macro as its TB component
`uvm_component_utils(my_phase_test)
//Boiler Plate code which is mandatory for all UVM TB components
function new(string name ,uvm_component_parent)
super.new(name,parent);
//Boiler plate code end
endfunction

task ..._phase(uvm_phase phase)
phase.raise_objection(this, "Starting Phase");
//Sequence start
//end Sequence
phase.drop_objection(this, "Finished Phase");
endtask

endclass


Drivers and monitors would be using JUST this run_phase


During the extract, check, report,Final phase methods post processing is done and the required information /details are gathered on the final state of the DUT,results are checked for the extracted information and the test pass/fail reporting would be done.

One of the differences  between OVM and UVM is that there is no final phase method in ovm.



-Happy Reading
Hash

Friday, 11 October 2013

Dear Readers

Thought would post why the analysis port always uses new and NOT create?

The analysis port always uses  the same type of object and as it is not  a component and  does  not belong to the  factory hierarchy.

Ports are interfaces which  are not extending from either object or component, so we cannot use create and have to use new

-Happy Reading
Hash


Wednesday, 9 October 2013

Tuesday, 8 October 2013

Dear Readers

I was trying to understand where  polymorphism is used in UVM and i found this blogspot really interesting and its explained in detail with code examples

http://learn-verification.blogspot.in/2012/12/uvm-questions-3.html

Hope you also find it useful 

-Happy Reading
Hash

Sunday, 22 September 2013

Dear Readers

I had a doubt on the uvm_do & uvm_do_with macros and this is what i understand from the UVM discussion forums and posting here as it may be useful for the interviews 

 uvm_do and uvm_do_with macros, the answer is that the second one assumes you need to further constrain your sequence/sequence_item(by providing this constraint as the second macro parameter) before it is get consumed. 

uvm_do does the following  3 things, 
1) create object 
2) object.randomize 
3) send packet 


 uvm_do_with there is only one difference, it calls 'randomize with ' (inline constraints) instead of randomize.

Hope you find it useful

-Happy Reading
Hash

Disclaimer

Posting on this blog to learn building UVM test benches, UVCs ,UVM VIPs from various online sources/discussion forums/Attended  training/Seminars /Webinars/Interviews. Am JUST sharing here to Learn from the experts and make this small effort better as i believe learning is a continuous process. Due credit goes to the trainers/online resources 
Dear Readers

Came across this You tube video and found it real interesting.
This explains how to setup a UVM TB right from the scratch given a DUT pin diagram
http://www.youtube.com/watch?v=kA7jiowZq3w



Hope you find it useful,coming up next is "to create a UVM TB given a DUT Pin out and timing diagrams"


-Happy Reading
Hash

Disclaimer

Posting on this blog to learn building UVM test benches, UVCs ,UVM VIPs from various online sources/discussion forums/Attended  training/Seminars /Webinars/Interviews. Am JUST sharing here to Learn from the experts and make this small effort better as i believe learning is a continuous process. Due credit goes to the trainers/online resources 

Tuesday, 17 September 2013

Dear Readers,

Came across this interesting topic on UVM discussion forums on linked in and posting on the blog as I found it real interesting! I JUST tried to organize the discussion to understand easily.

-Happy Reading
Hash


Topic: What are uvm_component_utils /uvm_object_utils and when to use these macros in UVM TB

As we all know that these uvm_component_utils /uvm_object_utils are the defined macros in UVM
There is a fundamental difference between objects and Components though both are classes that can be dynamically created while. Uvm_component is derived from uvm_object, and it adds the following:

1) Hierarchy management
2) Phasing
3) Reporting
4) configuration support
among other things.

Uvm_component -Should be used for objects that are of a "static" nature for the duration of the simulation
Uvm_object   should be used for other dynamically generated data, 

These macros are used for registering the type of uvm_component and uvm_object type objects respectively to the factory. So when you declare a class which is inherited from uvm_component, use uvm_component_utils and when you declare class inherited from uvm_object, use uvm_object_utils. 


They define uvm_component_registry and uvm_object_registry type proxy objects to register your own component/object types with factory. They are different because mechanism for creation of uvm_object and uvm_component type objects using the factory is different in UVM.


When to use uvm_component_utils /uvm_object_utils

On which factor the decision of using "uvm_component" or/either "uvm_object" depends.
 For eg. While creating "sequence" we use "uvm_seq_item" as base class & in this class we use "uvm_object_utils". Now let’s say in this case, if we use "uvm_component_utils" then what will be its impact.


Using either is not a choice, it’s more a must. One should have UVM class library hierarchy opened somewhere on the computer to see the type of the base class. If it is component then use uvm_component_utils, if object use the other one.


Use `uvm_component_utils for anything that is part of the UVM TB structure, including the top-level test that builds the rest of the TB.
Use `uvm_object_utils for anything that is data, such as your transaction class (extended from uvm_sequence_item) and any test sequences (extended from uvm_sequence).
You will not notice a difference until you try to create the components during the build phase or the data items during the runphase.
 If you declared the components or data with the wrong `_utils macro, you will get messages about the wrong number of formals or that there is no parent formal. Components have parents in the TB tree-structure while data is created as needed and does not have a parent. 

When we  build TB components i.e  Driver, Sequencer, Monitor, Agents, scoreboards , need to use uvm_component to register them, UVM provides individual parent classes for each of the components with in-built methods. so we just need to extend the class and build our  own components. 

UVM_objects is used for the things which are not part of the  TB structure i.e the stimulus. sequences use object, more clearly UVM_sequence and transaction class use UVM_Sequence items both directly derived from UVM_object. To keep the TB separate from the stimulus so that a test writer can alter its stimulus however he wanted a and the TB architecture remains unchanged. so it promotes more re-usability for the  TB


Disclaimer

Posting on this blog to learn building UVM test benches, UVCs ,UVM VIPs from various online sources/discussion forums/Attended  training/Seminars /Webinars/Interviews. Am JUST sharing here to Learn from the experts and make this small effort better as i believe learning is a continuous process. Due credit goes to the trainers/online resources 


Thursday, 12 September 2013

Dear Readers

 Came across this UVM blog post and can not resist to  add to the good links list
http://art-of-verification.blogspot.in/
http://www.agilesoc.com/2013/09/09/uvm-boat-anchor-sneak-peek/

 Hope you find this useful

-Happy Reading
Hash



Wednesday, 11 September 2013

Dear Readers

Posting some more information which would be useful in creating a UVM test bench given any given DUT
We would see on how to build UVM T/B with the steps below very soon.
Hope you find this useful and feel free to share your comments!

-Happy Reading
Hash

Steps to build UVM T/B given any DUT:

1. Read the design

   - List down features
   - List down scenarios
   - Create test plan

2. Understanding DUT architecture

  - List down DUT interfaces
      o What kind of interface is it: ACTIVE or PASSIVE?
      o Active will require Driver and Scenario generator

3. Test bench architecture

 This would have the following components

  - DUT instantiated
  - All interfaces defined
  - UVC components instantiated (agents for each interface, ex: axi_master_agent or axi_slave_agent, etc)
  - Reference model mimicking the Design behaviour
  - Register layer model
  - Virtual sequencer which will instantiate all sequencers
  - Virtual sequences which will instantiate required sequences from different interfaces

4. Sequences

  They will be coded specific to each interface
  - Simple sequences like, write, read sequences
  - Sequences for configuring design registers

5. Test Library
  - Test case coded using virtual sequence

Disclaimer

   Posting on this blog to learn building UVM test benches, UVCs ,UVM VIPs from various online sources/Attended  training/Seminars /Webinars. Am JUST sharing here to Learn from the experts and make this small effort better as i believe learning is a continuous process. Due credit goes to the trainers/online resources.

Thursday, 29 August 2013

Dear Readers

Thought of posting some code and here we go with the first program "hello world" and  have comments in the code to understand better .
 Please feel free to share your comments to make this small  effort better

-Hash

*********************************************************************************
 //Import the uvm_package
 import uvm_pkg::*;
`include "uvm_macros.svh"
program bhogadib;
       //uvm_component is the base class & my_test is the derived class
    class my_test extends uvm_component ;
              //utility macro to enable automation
             `uvm_component_utils(my_test)
            //Boilerplate code begin
            function new(string name,uvm_component parent);
            super.new(name,parent);
            endfunction
         //Boilerplate code end
    endclass
       initial begin
           //execute the UVM testcase
          run_test("my_test");
         uvm_report_info("Message","Hello world!!!!!");
        //Print what all types are available in the factory
       factory.print();
     //print the TB structure
    uvm_top.print_topology();
  end
endprogram

*********************************************************************************

# Loading sv_std.std
# Loading mtiUvm.uvm_pkg
# Loading work.first_uvm_test_sv_unit
# Loading work.bhogadib(fast)
# Loading C:\questa_sim_10.0b\uvm-1.0p1\win32\uvm_dpi.dll

# UVM_INFO @ 0: reporter [Message] Hello world!
#
#### Factory Configuration (*)
#
#   No instance or type overrides are registered with this factory
#
# All types registered with the factory: 37 total
# (types without type names will not be printed)
#
#   Type Name
#   ---------
#   my_test
# (*) Types with no associated type name will be printed as <unknown>
#
####
#
# UVM_INFO @ 0: reporter [UVMTOP] UVM testbench topology:
# ----------------------------------
# Name          Type     Size  Value
# ----------------------------------
# uvm_test_top  my_test  -     @455
# ----------------------------------
#
# 1
# Simulation stop requested.
*********************************************************************************

Sunday, 18 August 2013

To understand Sequencer -Sequence much better, i would like to add that sequencer is static and sequence is dynamic

Am working on creating UVC's at the moment and planning to share something soon.

-Hash

Thursday, 23 May 2013

Dear Readers



Posting some more Q&A i  was asked during the interviews.Please feel free to add anything to make this better


-Happy Reading
Hash

Q) Why do we use/advantages of  Virtual Sequencers in UVM?


Ans :


To run Virtual Sequence

Virtual sequences are required when more than one interfaces are required to drive sequence items. 
When there is dependencies on various interfaces   its always better to write a virtual sequence.


 In verif Env, there are always one or more interfaces. Every sequence-sequncer-driver flow is attached/refer to one interface.  Generally we can sequences form testcase, if there are more than one interface, we can use fork-join to trigger them parallel, but in case we need to generate some sequence/scenario  of  individual sequences it will be helpful to use virtual sequencer, which will have instances of various interface sequencers , which then can be controlled form virtual sequencer as per the requirement. For example, if some interface used to configure the  register & rest of traffic happens through another  interface, such controlling of sequences can be easily done through  virtual sequencer. Alternatively we can also use virtual sequences.


Q) Why  is the run phase in UVM again divided into Sub phases?

     What is the advantage of the sub phases (run) in UVM?

Ans:

          Run phases are sub divided in 4 phases.
          Mainly used in asynchronous reset condition.
          Abnormal run_phase termination.


Run phase is only task & consumes time. It actually starts the individual sequences & generates traffic. Within run phase it may require to play around with reset/clk ,which generally happens in tb_top initial begin-end (clk generation/reset generation), or in run phase we may need to reprogram some registers. To do so either we need to write/use sequences to do so rst/clk/register programming, but having run phase divided in to various barriers or phases, which can go back and re do things will save efforts or writing sequences.  So before starting your normal traffic sequences one can use reset an other sub phases. But somehow those are not RECOMMENDED .  



Q) what are the layers in the UVM ?


Ans:

    
   Generally in networking domain, there are protocol layers i.e. one protocol above the other. In verif testbench ,  the main interface agent's sequence  has another layer above it, meaning instead of actual interface  sequence, there is another  form of it, then we can build layering of sequencers, translators sequence , which  converts upper level protocol to actual bub interface sequence and has instance of upper layer sequencer, and sends the translated sequence to lower bus protocol, so in short, layers of sequencers are used to achieve layering of protocol  implementation

   May be Interface Layer, Signal Layer (Driver), Application Layer (Test/Generator).


Q)Do do you enable objections from the command line from any simulation tool?


Ans: 


     NO, I don't think so , as it should be done explicitly in the code


Q) Why do we need objections in UVM?



Ans:


    In UVM, end of test or end of simulation is controller by raising & dropping objections. For example in run phase or sub phases had build in mechanism called as phase_done. The objection mechanism tried to end phase instantly. A sequence must raise the objection when it starts & drop it when it finishes.
 That way end of simulation is closely controlled by user  

Sunday, 12 May 2013

Some more information which may be useful

1)What is the difference between the Push/Pull interfaces in TLM communication

    with the Push interface control and data go in the same direction
    with the pull interface control and data go in the opposite direction

2)In the Sequence items do we randomize the input/output properties

In the Sequence item, we randomize the input properties which contain address/data

3) What does a clone do?

       A clone returns uvm_object

4)Advantage of Virtual interface

Through the Virtual interface classes connect to Physical pins in System Verilog

5)Analysis port & the difference between the regular ports

Analysis port is a regular port which supports broadcast mechanism
It can be connected to a single export /no export/multiple exports also called subscribers
Regular ports are 1:1 where as analysis port are 1:many or none

6)Sequences and the transactions are customizable via the factory pattern
  Sequences, Transactions,Sequence _items are dynamic and created at run time where as Sequencer/driver are static like components 

Friday, 3 May 2013


 I feel the mentor cookbook very good ,hope you also find it useful
https://verificationacademy.com/cookbook

Fantastic (free )UVM online training from Aldec
http://www.aldec.com/en/onlinetraining/1/1/2


Found these links helpful in learning about UVM
http://cluelogic.com/category/uvm/
http://www.youtube.com/watch?v=2ZkoiuxUvls

There are a lot of(~24 Videos) short UVM Videos on Youtube , i find this good

http://www.youtube.com/watch?v=V-pekia4SPM

Good Video on TLM

https://verificationacademy.com/sessions/how-tlm-works/video/246?play=1

Very good paper on Factory patterns, best explained here

The OVM/UVM Factory & Factory Overrides How ... - Sunburst Design

Thursday, 2 May 2013

Dear Readers

Posting more information on UVM which would/may be useful for the interviews
Feel free to add any questions which may be helpful, this is  just a small effort from my side

-Happy Reading
Hash


1)Factory

uvm_factory is used to manufacture (create) UVM objects and components.
factory is a oops coding pattern
Allows test to change the type of a desired component or object
Typically set up at start of simulation

2)Virtual Interface

In SystemVerilog, a virtual interface is a handle variable that contains a reference to a static interface instance.

 Virtual interfaces allow the class-based portion of a verification environment to connect to physical interfaces containing signal definitions in the static module hierarchy.

3)Virtual Sequence

A sequence which controls stimulus generation across more than one sequencer, co-ordinate the stimulus across different interfaces and the interactions between them.

Usually the top level of the sequence hierarchy. AKA 'master sequence' or 'co-ordinator sequence'.

Virtual sequences do not need their own sequencer, as they do not link directly to drivers. When they have one it is called a virtual sequencer.

4)Virtual Sequencer

A virtual sequencer is a sequencer that is not connected to a driver itself, but contains handles for sequencers in the testbench hierarchy.

 It is an optional component for running of virtual sequences - optional because they need no driver hookup, instead calling other sequences which run on real sequencers.

5)Sequence


A class-based representation of one or more stimulus items (Sequence Items) which are executed on a driver.
Can collaborate in a hierarchy for successive abstraction of stimulus and can participate in constrained random setup to enable highly variable sets of stimulus above the randomization possible in an individual transaction.
Sequences can represent temporal succession of stimulus, or parallel tracks of competing or independent stimulus on more than one interface.
They can be built up into comprehensive stress test stimulus or real world stimulus particular to the needs of the protocol. UVM has comprehensive support the automated definition and application of sequences.

In its simplest form, a sequence is a function call (a functor), which may request permission to communicate with a driver using a sequence item.
 This complicated sounding interaction is not so complicated.
A sequence asks for permission to send a transaction (sequence item) to the driver.
Once it has been granted permission by the sequencer, then the transaction is passed to the driver.

6)Sequence Item

A class-based abstract transaction representing the lowest level of stimulus passed from a sequence to a driver. Also known as a Transaction.

7)Sequencer

A component responsible for co-ordinating the execution of stimulus in the form of sequences and sequence items from a parent sequence, ultimately feeding a driver component with transactions.
UVM/OVM provide a standard sequencer component with preset arbitration and locking methods for complex sequence stimulus.
 At its simplest, a sequencer can be thought of as s fancy arbiter.
 It arbitrates who gets access to the driver, which represents who gets access to the interface.

Friday, 26 April 2013

Some more Q&A on UVM from Doulos Webinar ,posted here in case anyone missed it
As mentioned earlier, this is a small repo from the interviews /seminars/training sessions/webinars  attended




Q: what is basic use of uvm
A: To capture best practice in verification IP reuse. UVM lets you build reusable verification components.


Q: why we use create method instead of new() in buitd_phase? can you tell the difference b/w them?
A: This is a factory method. It allows you to override the type of the object being created, whereas the type of the object created by "new" is determined at compile-time.

Q: Is the start_item() and finish_item() code embedded in the `uvm_do() and `uvm_do_with()?
A: Yes, that's right.


Q: what is ovm_test?
A: uvm_test is the base class used when creating user-defined tests in UVM


Q: is req is predefined object handle?
A: req is a variable defined in the base classes uvm_sequence and uvm_driver. It is just for convenience. You could use any variable.

Q: uvm support which language ?
A: UVM is written in SystemVerilog, but is intended to support mixed-language environments. You can mix SV with SystemC or e.



Q: Do we always need to create child sequence inside repeat loop?
A: No. This is just a simple example.


Q: what is this p_sequecer?
A: A pointer (reference) to the sequencer on which the sequence is running.

Q: what is the purpose of factory?
A: The type of the object created by the constructor "new" is fixed at compile-time. The point of the "factory pattern" (type_id::create()) is to let you override the type of the object being created at run-time.


Q: why we write if(starting_phase!=null) in pre_body??
A: Because the starting_phase property is not set by default, so we need to test it is non-null before dereferencing it (otherwise simulation will crash)


Q: What happens if 2 priorities are the same? Like seq3 with prio 2 and seq 2 also with prio 2?
A: Depends on the arbitration mode.


Q: Can I have one sequence running with different two sequencer at a same time ?
A: One sequence instance runs on one sequencer. You could have two different instances of the same sequence type running on two different sequencers (or the same sequencer)

Q: what is use of config_db?
A: To parameterize the UVM verification environment. In other words, to pass a set of resources into the UVM verification environment, usually in a top-down fashion.


Q: What is the use if uvm_declare_p_sequencer macro ?
A: It declares the p_sequencer variable, which gives a sequence access to the sequencer object on which it is currently running.

Q: In what scenarios a virtual sequence useful?
A: In order to co-ordinate the behavior of multiple sequencers in multiple agents connected to multiple DUT interfaces.

Q: can we instantiate child sequencers in the virtual sequencer and directly run child sequences on seqr0.seqr1 in the virtual sequence?
A: A virtual sequence instantiates child sequences, and then runs those child sequences, typically on some other sequencer.


Q: what is `uvm_rand_send?
A: Just a macro that randomizes a transaction object and sends it to a driver. (In effect, it does start_item...randomize...finish_item)

Q: How to use `uvm_do to run sequences inside the virtual sequences
A: would strongly advise you NOT to use `uvm_do until you are really sure what it is doing.

Q: So virtual sequencer is just a place holder for sequences?
A: You don't need a sequencer to run a virtual sequence, but you might choose to use a virtual sequencer if you want to associate other user-defined properties (variables) with the sequencer object.

Q: what happen if we don't use raise and drop objection while implementing sequence ?
A: The point is that the current UVM run phase will end when there are no objections raised. So the idea is that any UVM component or sequence that is "busy" will keep an objection raised until it is finished. Otherwise, the phase (and thus the test) may end prematurely.


Q: difference between start() method vs `uvm_do macros to start sequences?
A: I suggest you avoid `uvm_do until you understand what start() is doing. The `uvm_do macros can save you some typing, but at the risk of hiding what is really going on and making debug harder.

Q: why we use virtual sequence?
A: A virtual sequence co-ordinates the behavior of multiple sequencers in multiple agents

Q: what is background traffic
A: The ordinary stimulus being generated by a particular agent. A virtual sequence could then come along and interrupt what the agent is currently doing and start some other sequence.

Q: what is pre_do,mid_do and post_do explain me?
A: These are callbacks built into every sequence that can be overridden to change its behavior without needing to modify the source code of the sequence itself (for better reuse)



Q: can i write functionality of DUT in sequence?
A: Think of the sequence as generating stimulus, not as describing the expected behavior of the DUT

Q: what happen when sequencer already processing any sequence and virtual sequencer called lock?
A: lock stops the sequence items already being processed until the sequencer is unlocked


Q: what happened if a sequencer is already executing a transaction and we try to do a lock on that from the virt sequence
A: That's the point of lock! The currently executing transaction are suspended until the sequencer is unlocked.


Q: can multiple driver use 1 sequencer ? how?
A: Probably a bad idea. You want to start with one driver connected to one sequencer. If you want to split or merge transaction streams, you would probably use layered sequencers.

Q: so if virtual sequences don't run transactions, then what goes through virtual sequences? and why to use them?
A: Virtual sequences run sequences on other sequencers in order to coordinate the behaviour of those sequencers.

Q: what if there are 2 seq that use the grab?
A: That is exactly what was described in the webinar. The most recent grab goes to the front of the queue, the most recent lock goes to the back of the queue.

Q: why pre_body and post_body is not called in child class?
A: pre/post_body are not explicitly called in user-defined code. They are callbacks that can be overridden by the user. UVM calls pre_start - pre_body - body - post_body - post_start.

Q: the most recent lock has priority? shouldn't it be the oldest lock that has priority?
A: Yeah. That's how UVM works ;-) The most recent grab comes first, then the previous grab... then the oldest lock, then the next-oldest lock, and finally the most recent lock.

Q: If I want to connect a driver directly to the monitor, without using an interface, can it be done?
A: Sure, they are just objects in a SystemVerilog program, but connecting the driver to the monitor directly is usually considered bad practice (because you want the monitor to monitor what ACTUALLY happened, not what you THOUGHT the driver was doing)


Q: what is better to create different test sequence or different tests?
A: Whatever you want. In practice you would always have multiple tests, which could run the same or different sequences.


Q: Where is this code goes(creating library of sequences)?
A: Either in the run_phase method (or a sub-phase) of any uvm_component, or in the body method of any sequence.

Q: all the sequences in the uvm_sequence_library have to be running on same sequencer?
A: Yes, in effect, because a sequence library IS a sequence running on one sequencer.

Q: how do we suspend a sequence if and intruppt is generated and again resume the sequence from the same point after ISR
A: Any existing traffic (sequence items) will be suspended while the sequencer is locked, and resumed when it is unlocked. It is up to you to make it all work properly and consistently. UVM has no built-in machinery that understands the concept of an ISR.

Q: how do we suspend a sequence if and intruppt is generated and again resume the sequence from the same point after ISR
A: Any existing traffic (sequence items) will be suspended while the sequencer is locked, and resumed when it is unlocked. It is up to you to make it all work properly and consistently. UVM has no built-in machinery that understands the concept of an ISR.

Q: What is sequence layering in UVM?
A: Having multiple sequencers layered one above the other.

Q: How different is UVM from its parent OVM?
A: The first version of UVM was OVM with the characters "ovm" replaced by "uvm". Since then, UVM has been diverging from OVM with many new features added and existing features deprecated.

Q: in the examples that ship with UVM, the feedback to the sequencer is done via a TLM peek port, would recommend using the RSP item instead?
A: Good question. There are several ways to build the interface between sequencer and driver. We are focusing here on the req/rsp mechanism, but not strongly recommending it as the best or only solution. This is still a point of discussion in the UVM community.

Q: what is difference between pull driver and push driver? when they are used?
A: just use the pull driver.

Q: what does 'finish_item' do?
A: The second part of the handshake between sequence and driver.

Q: how do we suspend a sequence if and interrupt is generated and again resume the sequence from the same point after ISR

A: Any existing traffic (sequence items) will be suspended while the sequencer is locked, and resumed when it is unlocked. It is up to you to make it all work properly and consistently. UVM has no built-in machinery that understands the concept of an ISR.

Q: what does start_item actually do?
A: Waits for the driver to call get or get_next_item, then returns.

Q: How to form nested packets(nested packet is one packet is part of another packet) in transaction class?
A: Either with nested sequences (parent and child sequences as we showed in the early slides) or layered sequences (as we are showing now)
Audience Question

Q: Response that we get back from the driver to sequencer is the same response which is responded by DUT ?
A: Yes and no. The interface between the DUT and the driver is at the pin level, representing the hardware interface to the DUT. The interface between the driver and sequencer is transaction-level, but in theory should represent the same information (abstracted) as the pin-level interface


Q: If you were to implement a "slave" protocol witht he REQ/RSP mechanism, would you need to send a "ready" req, which essentially sits at the driver until a read fromt he master occurs on the interface? the RSP then goes back, and triggers a data item from the appropriate sequence?

A: That sounds reasonable. I guess the point is that the driver can only send the response object when it has all the information it needs to populate the object.
Audience Question

Q: What are some scenarios to use responses in sequences?
A: Any protocol in which there is a response, e.g. the data passed back from a read command, or status information passed back from any command. The alternatives would be to overwrite fields in the request object or use the path through the monitor component.

Q: if there are layered monitors or drivers,there is same generation of req and res?
A: The req/rsp mechanism is only built into the transaction-level interface between the driver and sequencer.

Q: why do you call req.randomize() after start_item? shouldn't req be ready when the driver gets it?
A: You need to understand the concept of late randomization. The whole point of the start/finish_item handshake is to delay the randomization of the transaction object until the last possible moment before releasing it to the driver.

Q: I just want to ask is there any method which we can call depending on some set of events .. as i dont want to change my sequence i just wasnt to pause it and after somtime resume it... but not by fixing delay but dependent on set of events

A: There are all sorts of ways in UVM of making components or sequences dependent on events. The point I am trying to make is that there is no clean, build-in solution to deal with the ISR scenario.

Q: through sequence library can we able  to generate multiple irun.log files for different sequences being executed?
A: No, the two concepts are unrelated.



Q: Am not too sure if sequences can be blocking...?
A: Sequences are inherently blocking: they consume time.


Q: what is need of objection mechanism
A: In order to co-ordinate the end of the test. The test should only end when each and every verification component has finished whatever it was doing.


Q: difference between sequence randomization and transaction randomization?
A: Sequence randomization randomizes the rand fields of the sequence object, transaction randomization does the same thing for the transaction object


Q: what is use of UVM_config_db?
A: To parameterize the UVM verification environment. In other words, to pass a set of resources into the UVM verification environment, usually in a top-down fashion

Q: in a layered stack what would be ideal functional call used in translator sequence and driver
A: Just the regular calls, nothing special. I suggest you download and study the examples.

Q: what if we do randomize both sequence and transaction randomize?
A: Then you randomize both the properties of the sequence objects and the properties of the transaction objects. Sequences generate sequences of transactions.


Q: i.e for driver should we use get() or get_next_item or try_next_item()
A: Depends on all sorts of issues within the verification env you are creating. Any or all may be appropriate. get() blocks, try_*() does not block.


Q: wht is the purpose of `vm_object_utils
A: To register the class with the factory. Always, always use `uvm_component_utils or `uvm_object_utils for components, transaction, and sequences respectively.

Q: How are virt sequences and sequence library different?
    What are the use cases where they are used?
A: A virtual sequence is used to co-ordinate the behavior of multiple agents driving multiple DUT interfaces. A sequence library selects from a set of sequences to run on a single sequencer (which could be virtual or not)

Q: How are virt sequences and sequence library different? What are the use cases where they could be used?
A: A virtual sequence is used to co-ordinate the behavior of multiple agents driving multiple DUT interfaces. A sequence library selects from a set of sequences to run on a single sequencer (which could be virtual or not)


Q: In the UVM phases what is this top_down & bottom_up execution? can throw some light onit?
A: Sure. Certain phases (e.g. build_phase) are executed top-down (starting at the top of the component hierarchy). Other phases (most of them) are executed bottom-up starting from the components at the bottom of the component hierarchy.


Q: how the virtual sequencer/virtual sequences be useful ina layered protocol?
A: You would usually start thinking of layered sequences in the context of a layered protocol, not virtual sequences


Q: why do we use run_phase(uvm_phase phase);here need of uvm_phase phase
A: That's just the way the UVM class library has evolved. The phase argument is used to raise and drop objections.


Q: in a layered stack e.g tcp -ip stack. I was confused whether there is need of any layered monitors to pass info back or even of anlaysis. I was thinking will be good to pass application data to from application layer to scoreboard as stimulus using sequence or shud be passed all the way to the pins and monitor read it and its passes all the way up to the stack again in reverse order through layered monitors and then to scoreboard
A: Great question! The UVM community are still discussing the best way to do this. Layered monitors make perfect sense. When layering agents, you may need to use the UVM factory to replace individual drivers or monitors in higher layer agents