Hardware interview practice
Distinguish SystemVerilog Functions and Tasks
A testbench needs one reusable parity calculation and one reusable bus transaction that waits for clock edges and returns both data and status. Which choice assigns the two jobs correctly?
Choose one
Answer choices
- A. Use functions for both because SystemVerilog functions may contain arbitrary timing controls when called from a testbench.
- B. Use tasks for both because functions cannot have arguments in SystemVerilog.
- C. Use a function for the zero-time parity calculation and a task for the clocked bus transaction; the task may consume simulation time and return multiple outputs, while synthesizable uses of either remain tool- and context-bounded.
- D. Use a task for parity because tasks are the only subprograms allowed to return a value, and a function for the bus transaction because functions may wait on clocks.
