Jump to content

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  

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • 4 weeks later...

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 :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...