When i look into the uvm cookbook the “write” method is implemented as a “function”.
So my question is why its “function” why not “task” ? If the requirement is to just have something in Zero time than we can
have the “task” without any delay.And what i know is that “write” is blocking. right ?
So can anyone please explain me the right reason to implement it as “function” not “task”.
The SystemVerilog LRM requires that a function is non-blocking and must complete in zero time. The write() function is non-blocking and meets this requirement.
A task can call another task or a function, but a function can only call another function. A function can not call a task since there is the potential that it can consume time.
One reason what I can think of is that, the purpose of write function is to get the data from where it is collected, for example from a monitor, and get a copy of it for further processing (for example in a scoreboard).
In the write task we should not doing any other functionality & should be kept outside of the write function.
In case the methodology had allowed to keep the write function as a task, there is a possibility that we add some delays and the next data might get effected.