Here is a code piece
class APB_Component extends Component;
APB_Stim stim_gen;
APB_Driver driver;
APB_Channel chan;
function new(string _name, Component _parent, virtual APB_test_intf _hook);
super.new( _name, _parent );
chan = new(1);
stim_gen = new("stim_gen", this);
driver = new("driver", this, _hook);
stim_gen.sink = chan;
driver.source = chan;
endfunction : new
...
In this code, a constructor of a class is implemented. Three parameters are passed to this function. one string, and one class namely Component and one interface APB_test_intf.
On the line: stim_gen = new(“stim_gen”, this);
What does that “this” keyword signifies here? Does this mean passing stim_gen as argument to itself?
It’s very confusing…
In reply to tahirsengine:
Here is a code piece
class APB_Component extends Component;
APB_Stim stim_gen;
APB_Driver driver;
APB_Channel chan;
function new(string _name, Component _parent, virtual APB_test_intf _hook);
super.new( _name, _parent );
chan = new(1);
stim_gen = new("stim_gen", this);
driver = new("driver", this, _hook);
stim_gen.sink = chan;
driver.source = chan;
endfunction : new
...
In this code, a constructor of a class is implemented. Three parameters are passed to this function. one string, and one class namely Component and one interface APB_test_intf.
On the line: stim_gen = new(“stim_gen”, this);
What does that “this” keyword signifies here? Does this mean passing stim_gen as argument to itself?
It’s very confusing…
I kind a got the idea now.
In original class APB_Stim, there was a class passed as a second argument on this place. So in the constructor of APB_Stim class, keyword “this” signifies that class, which originally is passed in the definition of constructor or new() function.
It’s kind of like self talking but, this will help many.