Wednesday, 15 February 2017

Type overriding using UVM factory

Type overriding means that every time a component class type is created in the Testbench hierarchy, a substitute type i.e. derived class of the original component class, is created in its place, which applies to all the instances of that component type. In UVM, below are the methods by which we can override the class:
  • set_type_override_by_type
  • set_type_override_by_name

There's no difference in the final result either we override by type or name.

In below example, our purpose is to override driver class without making change in existing environment, so we created extended class which is extended from the original driver class.

Factory Code:


// When ~replace~ is 1, a previous override on ~original_type_name~ is replaced, otherwise a previous override, if any, remains intact. Yet to check.

Driver Code:


Extended driver Code:


In test, we can override the driver class by using "set_type_override_by_type" function.

Overriding in Test:


Output:

In test, we can override the driver class by using "set_type_override_by_name" function.

Overriding in Test:


Output:

No comments:

Post a Comment