Analysis Port and Export 'new()' method

Hi,
Why we use new() method in case of analysis ports and exports instead of create() method?

Thanks

In reply to Salman94:

When a ‘class’ is registered with factory, that class has implementation for ‘create()’ method.
While, in case of ‘Port’ which is class, and uvm source code for any ‘Port’ does not have any factory registration. So new() should be used to create a port.

Secondly, there is no point to replace any ‘Port’ in env, so this should be a reason for having ‘create()’ method implementation for any port.

In reply to prashant.kaushik:

In reply to Salman94:
Secondly, there is no point to replace any ‘Port’ in env, so this should be a reason for having ‘create()’ method implementation for any port.

What do you mean by this?

In reply to Salman94:

Hi Sallu,

All below mentioned UVM TLM1 classes are derived from the base class ‘uvm_port_base’.
This ‘uvm_port_base’ class provides only new method for creating instance of this classes.

As correctly mentioned by Prashant , Create method is generally used whenever there is a scope to replace already existing UVM_Component by a new UVM_Component.

uvm_port #(T)
uvm
port #(REQ,RSP)
uvm
imp #(T,IMP)
uvm
imp #(REQ, RSP,IMP,REQ_IMP,RSP_IMP)
uvm
export #(T)
uvm
_export #(REQ,RSP)

In reply to DigvijayS:

Hi Digvijay,
Yes you are right that ‘uvm_port_base’ class provides only new() method so this is the only reason of using new() for creating ports.And by using ‘create()’ method factory will come into picture and overriding concept also.Is there something I am missing?

Thanks,

In reply to Salman94:

Which kind of constructing an object depends what you want to to with this object. And it is not a question which methods are provided by the corresponding class. Commonly you are using the type_id::create method from the factory to create an object which shall be registered wit the factory and is intenden for overriding. Ports and exports will not be overriden, thus you can simply use the constructor call new(…) to create it.

In reply to chr_sue:

So the reason of using new() for ports is we don’t require them to be overrided.Hence we don’t use create() for them.

In reply to Salman94:

Yes, this is the reason