Jump to content
Sign in to follow this  
amitk3553

Polymorphism in testbench

Recommended Posts

in case you have such ubus example,,, you have different agents ,, each one is responsible to act like either master or slave ,, It isn't restricted that all agents act in the same way at the same time,, but you have to randomly configure each one to make your test more random and more effective ,, such way ,, you have different agents ,,, each one extended from uvm_agent base class ,, and each one may have the same function name ,, for instance write(),, strope () ,, read() and so on ,, 

 

Through build phase ,, you called build function through all environments in the same test bench ,, although they have the same name ,, polymorphism play its role 

 

another example through when run phase ,,, each agent may have his own run routine with the same name run () ,, but they don't act as each other ,, so polymorphism play its role here also 

 

on Other matter ,, naming function whose main purpose similar like run, is so practical as on complex tests you have high number of agents and scripts and you may get lost in routines' names  

Share this post


Link to post
Share on other sites

hi,

 

polymorphism is a general concept. see http://en.wikipedia.org/wiki/Polymorphism_(computer_science). the testbenches we write are essentially software. in that sense all methods to improve creation/speed/maintenance/stability/reuse of software should be in the focus for tb developers too. the concept of polymorphism is one way to improve.

 

/uwe

Share this post


Link to post
Share on other sites

You can use the polymorphism in UVM as following example:

 

class driver extends uvm_driver;

class my_driver extends driver;

 

module test;

   ....

   driver dr;

   initial begin

       // polymorphism:  wait until run-time to bind the object type

       // You can override either by type or instance.

       factory.set_type_override_by_type(driver::get_type(), my_driver::get_type());

      

       // It is important to use factory before create

       dr = driver::type_id::create("driver", null);

      

       run_test();

   end

endmodule

 

Hope it helps.

Quang

Share this post


Link to post
Share on other sites

Another Simple use case of polymorphism is callbacks.... in driver classes you call the methods [pre* , *post]  which are defined in façade class.

 

Now when you extend these façade class you provide definition to these method, once these extended callback classes are added to queue of these callback class then during execution of test case functionality of these redefined method will be called by using the handle of old class...

 

this is possible by polymorphism...

hope it helps and clear to you :-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×