Override multiple class with same parent class

Hi,

I am now facing a situation that I need to override multiple classes, which are all extends from the same class.

For example,

class A extends Central;
class B extends Central;
class C extends Central;
.
.
.

And I would like to add some component to Central, but class A, B, C and Central are not my code, so I can’t directly modify them.

The method I use now is

class a extends A;
class b extends B;
class c extends C;

Add the component to a, b, c, and then

set_type_override_by_type(A, a);
set_type_override_by_type(B, b);
set_type_override_by_type(C, c);

But I think this is quite stupid : If I have 100 class extends from the central, I need to create 100 classes to extends and override them!!!

So I would like to know is there any more efficient way to do this.

Thanks for the answer in advance.

In reply to NewToSV:

Without knowing the intent behind your request, I can’t suggest a more efficient way. Sometimes you get stuck on one approach and it becomes difficult to think of another strategy.

The only thing I can recommend is working with the owners of the code to make easier for you.

In reply to dave_59:

Thanks dave.

Actually, Central and A, B, C is class in Tool in above example, so it’s not allowed to changed them, especially add some customized component or function.

A, B, C is classes for different scenario: all read, all write, and R/W random

What I want to do is to change the transaction length(times) default defined in Central. Original length is 30, and for some scenario I need 100, so I extends A,B,C and override them to add the function to change length value.

So I would like to know is there a more efficient way to add that function, maybe a command can directly override Central Class and influence its child class A, B, C, or some way else.

Any method better than extending all child class of Central and override them would be helpful.

Thanks

In reply to NewToSV:

I don’t know what you mean by “class in Tool”

The person who wrote the code has to give you betters ways of controlling how transactions get generating. Normally people create separate configuration classes objects that can be used as control knobs, for example the transaction length, so you don’t need to do everything by extension.

In reply to dave_59:

Thanks dave for the discussion.

class in Tool —> There is a tool in my environment formed by a package of multiple UVM code, VIP, and AIP. It’s shared by many users, so it is not allowed to modify code in the tool unless you found some bug, you can submit to tool owner.

Normally people create separate configuration classes objects that can be used as control knobs, for example the transaction length, so you don’t need to do everything by extension. —> Yes, I’m totally agree with you, especially for the case modifying transaction length.

But what I want to discuss is that if there is a situation : I have many class extends from the same class. All these code are shared by many users, so I can’t directly modify them for my own feature.

What would be a better way to add my feature? In my way, I create same amount of classes to extends them and override them, then add my feature inside. But, there is definitely a better way to achieve this.