How to parametrize a subscriber class

Hi all,

I’m trying to parameterize a subscriber in this way:


class parameterized_subscriber #(type my_obj = uvm_object, type T = uvm_sequence_item) extends uvm_subscriber #(T);
    // omitted utils macros...
    my_obj obj;
endclass

While this seems to work as a parametrization, I then would like to extend the parameterized class specifying only one of the two parameters (therefore still keeping a parameterized subscriber where only the type of transaction is parameterizable. Unfortunately I don’t quite get the syntax right and I have the impression I cannot specify one parameter only.

Any idea how to accomplish this?

I realize that giving a little bit more of the context will help you out understanding my goal. I want to have a base subscriber with several mechanisms already in place (like the write function and other methods). This base subscriber uses an object to perform various operations, but the object is parameterized as well. So I want to have a parameterized subscriber which has all the infrastructure in place to deal with the parameterized object, and then create specialization of it with the specialized object as well, but leaving the parameter of the type of transaction the subscriber would deal with. In this way I can layer a little bit more the class hierarchy and specialize only the parts that are different.

In reply to abs:

Extendenin a class requires to keep the original format, i.e. 2 parameters. The extension does not meen you are replacing one of the parameters with a fixed type.

In reply to chr_sue:

Well, it’s maybe not an extension then. Could we call it specialization then?
How can I specialize only one parameter and keep the other as is?

In reply to abs:

You can make a typedef, reducing by 1 parameter.

In reply to chr_sue:

In reply to abs:
You can make a typedef, reducing by 1 parameter.

could you be more explicit? I’m kink of lost with your statement…

In reply to abs:

Look here, this is your starting point:

class parameterized_subscriber #(type my_obj = uvm_object, type T = uvm_sequence_item) extends uvm_subscriber #(T);
    // omitted utils macros...
    my_obj obj;
endclass

Now you can make atypedef like this (reducing to 1 parameter):

typedef parameterized_subscriber #(type my_obj = fixed_object, type T = uvm_sequence_item) my subscriber;

Where fixed object is an object you do not change in the subscriber.

In reply to chr_sue:

In reply to abs:
Look here, this is your starting point:

class parameterized_subscriber #(type my_obj = uvm_object, type T = uvm_sequence_item) extends uvm_subscriber #(T);
// omitted utils macros...
my_obj obj;
endclass

Now you can make atypedef like this (reducing to 1 parameter):

typedef parameterized_subscriber #(type my_obj = fixed_object, type T = uvm_sequence_item) my subscriber;

Where fixed object is an object you do not change in the subscriber.

That’s it! Thanks a lot, it was indeed what I was looking for