Hi All,
Can the write method of analysis port which used to communicate between monitor and scorebaord be declared as task instead of function? If no, why so?
Regrads,
Abhinandan
Hi All,
Can the write method of analysis port which used to communicate between monitor and scorebaord be declared as task instead of function? If no, why so?
Regrads,
Abhinandan
It can be declared as a task provided there are no blocking statements ( although from a strict LRM perspective it’s illlegal to call a task from a function w/o fork join_none )
The reason it’s a function and not a task is due to it’s definition in class uvm_tlm_if_base
Check the following blog :: cluelogic
The base class prototypes write() as a function. Per the LRM, you are required to follow the same prototype, so write() needs to be declared as a function. You will get an error if you declare it as a task.
On replacing component_b :: write in edalink as
virtual task write(transaction trans);
`uvm_info(get_type_name(),$sformatf("Inside NEW write method.Received trans On Analysis Imp Port "),UVM_LOW)
`uvm_info(get_type_name(),$sformatf(" Printing trans, \n %s",trans.sprint()),UVM_LOW)
endtask
The code does work on 2 EDA tools ( VCS & Questa ).
Pls note that I understand that ideally one shouldn’t declare write as a task and that LRM terms it illegal
Coincidentally a few yrs ago I had a colleague who had declared his write as a task and the simulation did go through ( along with Warning msg).
When I asked him to add #0 within task write and re-run the tool had given a compilation error.
As mentioned by @AGS91 if we declare task it still works and no compilation error is thrown. One of my colleague declared it as task, and it is working.
Regards,
Abhinandan
Thanks for the reply.
Regards,
Abhinandan
The uvm_analysis_imp class has an internal write() method which is declared as a function. It will in turn call the write function/task of the class which is instantiating it. I was incorrect when I stated you will get an error, as you aren’t redefining the write() method.
3 of the simulators will give you a warning about calling a task from a function. The fourth will generate an error.