Home / Learn Verilog / Function vs Task

Function vs Task

Which to choose.

Quick summaryWhich to choose.

How to think about this

Comparefunctionreturns a valueno delaystaskoutputsdelays allowed
Compare

Definition

Functions: one result, no time. Tasks: many outputs, can wait.

Why you need this

Wrong choice leads to compile errors.

How it works

Use functions for logic, tasks for sequences.

Where you'll see this

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Same helper both waysVerilog: edit and run

Both give 42.

Test what you just read

1. Need an output and a delay?