Parameterize test base with env type

Hi,

I have a layered verification environment i.e. testcase extends sub_test_base; sub_test_base extends global_test_base etc. Same hierachy applies also to the env. At the global level we create a global env variable inside global test base. At the sub layer, we would like to utilize the env variable created at the global layer. The problem is that we should be able to change the type of the env variable to be the sub env type. Sub env type extends global env type, but it also brings some new properties like new agents, and methods as well. My first idea was to make global test base parameterized, so you can deliver the correct env type with help of parameterization. But I don’t know if it is the best way to do it… Could you help me, please? Basically, I think we have a couple of alternatives:

  1. Parameterize global test base with env type as mentioned above, or
  2. Use type overriding at the sub layer to override the type of the env variable introduced in global testbase. But with that approach you are not able to access directly the overriden properties vai global env type variable (m_env) like sequencer of sub layer agent m_env.agent_in_subenv.sequencer.

What is the preferred approach in my case?

Thanks already in advance for your answers.

-Ilia

In reply to ilia:
I would recommend using type overriding with factory over using parameters. This gives you more flexibility and creates fewer dependencies. If you use parameters to override, you can wind up in a situation with too many parameters in your global test base. Also, it doesn’t solve the problem directly accessing additional overridden properties because the compiler won’t let you reference them when the type is not overridden.

When you use the factory to create your env, you can always use a dynamic $cast to get the to properties in the extended classes.

In reply to dave_59:

Thanks Dave for your clarifying answer.

To summarize this, I should call factory create for the env in the build phase of the global test. Then in the derived test, I should call UVM type override prior to super.build_phase to override the type of the env. After that, if I would like to access to the additional overridden members of the derived env, I should make dynamic cast with $cast(). Did I interpret it correctly, hopefully broadly yes.

-Ilia

In reply to ilia:
You got it.

In reply to dave_59:

Thanks Dave!

Anyway, I am still wondering what really is the division of labor between parameterization and type overriding in case of base classes in the layered verification environments? I think the parameterization opens the way into the world of horizontal reuse, which is mainstream at the moment, right? They presented the paper “Parameterized Classes, Interfaces & Registers” in DVCon EU 2015 in which it was talked about the horizontal reuse enabled by the parameterization.

-ilia

In reply to ilia:
There are a number of different perspectives on the division between parameterized class and the factory. Here is mine. Perhaps you could write a paper too.

In reply to dave_59:

Thanks for that.