Extend task: main_phase in extended test class, members of the base task are not visiable

Hi VA,

Trying to extend a task in my ext_test, which was defined before in the base_test.

Used the call of: super.main_phase(phase)
In the extended main_phase task, but still receive errors while compilation:

Error-[IND] Identifier not declared
/space/git/block_a/verif/tests/ext_test.sv, 61
Identifier ‘main_drain_time’ has not been declared yet. If this error is not
expected, please check if you have set `default_nettype to none.
Instance stack trace:
$unit /tools/snps/vcs/S-2021.09-SP1-1/etc/uvm-1.2/uvm_pkg.sv, 1

Error-[XMRE] Cross-module reference resolution error
/space/git/block_a/verif/tests/ext_test.sv, 63
Error found while trying to resolve cross-module reference.
token ‘obj’. Originating package ‘$unit’.
Source info: obj.set_drain_time(\this , main_drain_time);
Instance stack trace:
$unit /tools/snps/vcs/S-2021.09-SP1-1/etc/uvm-1.2/uvm_pkg.sv, 1

Code example:


class base_test extends uvm_test;
    ....
    task main_phase(uvm_phase phase);
        uvm_objection obj = phase.get_objection();
        time main_drain_time; 

        super.main_phase(phase);

        `uvm_info(get_name(), "main_phase()", UVM_LOW) 
        main_drain_time = 200ns;
        obj.set_drain_time(this, main_drain_time);
        
        `uvm_info(get_name(), $sformatf("[BASE_TEST] drain_time=%0t, was set for main_phase", main_drain_time), UVM_NONE)
    endtask // main_phase

endclass


class ext_test extends base_test;
    ...
    task main_phase(uvm_phase phase);
        super.main_phase(phase);
        
        `uvm_info(get_name(), "extended_test - main_phase()", UVM_LOW)
        
        main_drain_time = 500ns;
        
        obj.set_drain_time(this, main_drain_time);
        
        `uvm_info(get_name(), $sformatf("[EXTENDED_TEST] override drain_time=%0t, was set for main_phase", main_drain_time), UVM_NONE)
    endtask // main_phase

endclass

What am I missing?
Why the access to the defined members in the base class task are not accessible by the extended class task?

Will appreciate your help.

Thanks,
Michael

In reply to Michael54:

main_drain_time is not a member of the base_test class, it is a local automatic variable of the method base_test::main_phase. You cannot access automatic variables from outside the scope of their declaration.

You probably want to move the declaration of main_drain_time into the base class.

In reply to dave_59:

Thanks Dave,

Following question:
should not the call for: super.main_phase(phase)
which is base_test::main_phase
in the beginning of the ext_test::main_phase
expose these local variables to the extended main_phase task?

Thanks

In reply to Michael54:

No. Automatic variables declared in a function or task (methods) are local to that method and cannot be accessed from outside the scope of the method. Automatic variables get created upon entry to the method and destroyed upon exit.