Hi,
I have a question about class override: In the following code if super not called in derived class then base class’s task gets overwritten and only derived class task gets executed
BUT, if I call super from derived class, base class task gets executed and then derived class. Shouldnt set_type_override() overwrite the base class?
**
class base extends uvm_object;
`uvm_object_utils(base)
function new(string name= "base");
super.new(name);
endfunction
virtual task cal;
bit[31:0] a;
bit[31:0] b;
bit[31:0] c;
bit[31:0] d;
a = 20;
b = 30;
c = a +b;
d = b-a;
`uvm_info(get_type_name(), $sformatf("a %d b %d c%d",a,b,c), UVM_LOW);
`uvm_info(get_type_name(), $sformatf("a %d b %d d%d",a,b,d), UVM_LOW);
endtask
endclass
class derived extends base;
`uvm_object_utils(derived)
function new(string name= "derived");
super.new(name);
endfunction
virtual task cal;
bit[31:0] a;
bit[31:0] b;
bit[31:0] c;
super.cal();
a = 10;
b = 10;
c = a +b;
`uvm_info(get_type_name(), $sformatf("a %d b %d c%d",a,b,c), UVM_LOW);
endtask
endclass
//In test class
//function new
set_type_override("base", "derived");
//OUTPUT::
UVM_INFO testbench.sv(394) @ 0: reporter [derived] a 20 b 30 c 50
UVM_INFO testbench.sv(395) @ 0: reporter [derived] a 20 b 30 d 10
UVM_INFO testbench.sv(420) @ 0: reporter [derived] a 10 b 10 c 20
**