Uvm analysis implementation

uvm_analysis_imp_decl will allow us to create our own write function. But implementation of write function is restricted to take only one argument which is transcation type. Is there is any uvm hook or macro would allow me implement a write function with more one(default) argument?

Example.
`uvm_analysis_imp_decl(_in)

class sample extends uvm_component;
uvm_analysis_imp_in#(mydata_type) port_in;

function void write_in(mydata_type tx); 

endclass

In above example, I would like to write function with following argument.
function void write_in(mydata_type tx, int i);

Thanks,
Sanket

In reply to sanketshah:

The hook is to use the Object Oriented Programming paradigm that SystemVerilog provides. Suppose you want to connect two or more analysis_imp’s to the same analysis port. If you change the prototype for the write method(the numbers and types of their arguments), you would have to change it everywhere.

By extending the transaction, only the publisher (the component calling the
write()
method) and the subscriber (your sample component here) need to know about the extra int member.


class hook_mydata_type extends mydata_type;
  int i;
endclass

class sample extends uvm_component;
uvm_analysis_imp_in#(hook_mydata_type) port_in;

function void write_in(hook_mydata_type tx);
  if (tx.i ...
endfunction

endclass

In reply to sanketshah:

OOP says hook_mydata_type can be used in all places where mydata_type is used.

Thats correct but a variable of mydata_type cannot access to the variables presented only in hook_mydata_type.

In reply to sanketshah:

But you can use everywhere hook_mydata_type and this contains the additional property.
I do not understand why you need the specific argument list
function void write_in(mydata_type tx, int i);

Thats because I want my implementation to tie to mydata_type and not involve any other class extended from it. But I want that extra variable coming from the place write function getting called. Plus that extra variable can be type T and not fixed to any datatype.

Sanket

In reply to sanketshah:

You need to accept that you cannot add extra arguments to the write method of an analysis port/analysis_imp. But let’s assume for the moment that you could add an extra argument. The code for the class that calls the write method, and the class that implements the write method both have to know about the existence of that extra variable argument and it’s type, along with the type of the original tx transaction. If these types were parameterize, you would have to parameterize the calling and called classes as well.

So now, going back to the fact that you can only have one argument, you have to encapsulate the knowledge about the two arguments you want into a signal argument. You can do that by extending the tx class and adding the extra variable as an extended class member, or you can create a new class that contains two class members representing the tx and extra variable. In either case, you can parameterize the variable’ type by parameterizing the class.

The problem with the container method is an extra level of indirection and the fact that every implementation connected to the analysis port has to know that it is being passed a container containing a transaction, instead of just the transaction.