Changing base test to uvm_env for leveraging purposes

Hi,

I have an existing base test class that is extended from uvm_test.
It consists of various objects such as env1, env2, cfg1, cfg2.
And the intent of this base test class, is to powerup the x1 DUT.

Now, I would like to leverage uvm_test, to form a new testbench, where x2 DUT will instantiated.

I am thinking of changing base test class to be extended from uvm_test, and create a new base_new class which will instantiate x2 of base.

Is this approach reasonable? Or is there a typical approach that should be used in a uvm platform?
Is it correct to use uvm_config_db in order to access base_test objects, therefore existing tests which used to control x1 DUT could still be leveraged?

Example:

[a] Original base test class

Class base_test extends uvm_test

my_env env1;
my_env env2;
my_cfg cfg1;
my_cfg cfg2;

virtual function void build_phase(uvm_phase phase);
cfg1 = my_cfg::type_id::create(“cfg1”,this);
cfg2 = my_cfg::type_id::create(“cfg2”,this);
uvm_config_db#(my_cfg)::set(this,“env”, “my_cfg”, this.cfg1);
uvm_config_db#(my_cfg)::set(this,“env1”, “my_cfg”, this.cfg2);
… likewise for my_env
endfunction

endclass

[b] Change to “Class base_test extends uvm_env”, and create base_new_test as follows:

Class base_new_test extends uvm_test

base_test base1;
base_test base2;
my_env env1;
my_env env2;
my_cfg cfg1;
my_cfg cfg2;

virtual function void build_phase(uvm_phase phase);
base1 = base_test::type_id::create(“base1”, this);
base2 = base_test::type_id::create(“base2”, this);
cfg1 = my_cfg::type_id::create(“cfg1”,this);
cfg2 = my_cfg::type_id::create(“cfg2”,this);
uvm_config_db#(my_cfg)::get(this,“”, “my_cfg”, this.cfg1);
uvm_config_db#(my_cfg)::get(this,“”, “my_cfg”, this.cfg2);
… likewise for my_env
endfunction
endclass

In reply to EE:

What does the base_test as an instance in your base_new_test?

class base_new_test extends base_test is the solution.
To have a safe coding I’d use a different name for the ‘name’ argument in the config_db set/get command like this:
uvm_config_db#(my_cfg)::set(this,“env”, “my_cfg1”, this.cfg1);

BTW you should format your code as SV.

In reply to chr_sue:

Hi Chr_sue,

Thank you for your comments.

The reason that I would like to instantiate base_test as and object, is because a single base test consist of sub environments that controls 1 DUT.
By instantiating 2 base_test (changing it to uvm_env), will allow me to control 2 DUTs in parallel and perhaps with different configuration for each DUT.

If I extend it, this will mean, i need to replicate the sub environments and its associated methods to verify the second DUT?

For example within base_test, I have run_phase task which will do a bunch of things to powerup DUT1. I am hoping that base_test_new when instantiating 2 base_test will result in run_phase executing in parallel for DUT1 and DUT2. I am new uvm user, I think I may have missed your point.

Ok, thanks for pointing out on formating the code in SV.

In reply to EE:

All what you want to do you can do with the sequences, but you can start only 1 test and not more in parallel.
I believe you are following the wrong approach.