Task and Function in SystemVerilog

This is my first post. I put on hold to start write anything as I am still not sure how shall I organize this, or what to put in this blog. Anyway, I should have starting point, and just go ahead from it. Let me start with the question asked by a DE today.

Question : What is the difference between task and function in SystemVerilog?
  1. Task can have time control statements and delay, while function doesn’t support time control statement.
  2. Function can have return value, but task cannot.
  3. Task can call other task/functions, but function cannot call a task. (This limitation is on Verilog, SystemVerilog allow function to call a task using spawned thread.)
  4. A function must have at least one input argument, while task can have no arguments at all.

Some notes.

  1. Both task and function support input, output, inout as their argument.
  2. For inout type, the argument act as input at the beginning and as output at the end of the routine.
  3. If a task that does not consume time, it is advisable to make it a void function, so it can be called from any task or function.

Comments

  1. SystemVerilog allow function to call a task using spawned thread : very well said

    plz visit my blog

    http://technicalone.blogspot.in/2013/07/task-called-within-function.html

    ReplyDelete

Post a Comment

Popular Posts