Type cast error for uvm config db

In my TB, I am setting the env_config in the test using uvm_config _db set. In the sequence I am trying to get this env_config handle using uvm_config_db get, but I am getting compilation error saying “formal and actual do not have assignment compatible data types (expecting datatype compatible with ‘class uvm_pkg::uvm_component’ but found ‘class obs_config_env_pkg::obs config sequence’ instead)”.

I am not understanding why this error is coming since sequence is also an object and the env cfg is also extended from uvm_object.

Can someone help me on this?

Regards,
Abhinandan

You shouldn’t try to get() anything from the uvm_config_db() in a sequence since a sequence is an object and doesn’t have a location in the hierarchy that get() can use.

Instead, you should assign the env_config handle from the test when the sequence is created, prior to starting the sequence.

Thanks for the reply @cgales. So, how can I then access the env_config handle in my sequence?

You should have the handle in your sequence, and when you create the sequence, assign the handle from your test.

@cgales . I tried the method you have mentioned, it worked.
Thanks @cgales.