Trouble referencing an attribute in a factory overidden class

Hi everyone,

I can’t seem to ‘dot’ down into a class to change an attribute value when that class was replaced using a factory override.
Questions:
Do I need to reference the override class with a different naming convention or something? Can I reference new attributes in a factory override class that are not in the original class before it was overwritten?

Details follow:
I have a UVM testbench that contains an agent with a ‘basic’ coverage class (uvm subscriber).

For my particular test environment, I reuse that agent and replace the coverage class with my project specific detailed coverage class.
I replace it using a factory override.
base_coverage::type_id::set_inst_override(my_detailed_coverage::get_type(),“uvm_test_top.vrp_env_inst.agent.basecoverage”);

Note that the new “my_detailed_coverage class” contains additional attributes that are not in the base_coverage class.

In my test, I’m trying to set one of those attributes in the factory override coverage class (my_detailed_coverage) by doing this:
env_inst.agent.basecoverage.my_new_attribute=1;
Here’s the error:
I get the error stating No field named ‘my_new_attribute’.

If I temporarily add the attribute to the base class, it seems to work but the point was to not clutter up the base class with my test specific items.
What am I misunderstanding?

Thanks,

In reply to BrianK:

You need to downcast before accessing a dereived class property.

https://verificationacademy.com/forums/systemverilog/confusion-over-casting-classes

In reply to dave_59:

Thank you for such a quick response! I have a couple more questions though.

I didn’t realize the base/child class concept applies to a factory override scenario; I’ll read through the reference links in more detail,

However I’m not sure how to do the cast in this scenario. From my limited understanding, the factory over-ride somewhat replaces the original class with a different class, but the instance name is the same. I wasn’t thinking it extended it.

Do I need to create a new instance of my over-ride class and then cast the existing instance name to it?

e.g.
my_detailed_coverage detailed_handle;
detailed_handle = new();

cast(detailed_handle,uvm_test_top.vrp_env_inst.agent.basecoverage)

Then I can refer to: detailed_handle.my_new_attribute=1?

Is the bolded item above correct? Because of the factory override, I’m not sure what type it really is after teh override.

Thanks again,
Brian

In reply to BrianK:

You do not create a new instance of your override. There is only one object instance and your are just moving the handle to a different class variable.

You maight want to look at my short course on classes; especially the second session.

In reply to dave_59:

Doh, Of course, silly me, I did know that. I will review the short course as well.

I’m up and working again; thanks for your help Dave.

Brian