Home / Learn Verilog / Functions in RTL

Functions in RTL

Reusable combinational logic.

The gistReusable combinational logic.

The idea, explained simply

Functioninputscombinationalreturn value
Function

Definition

A function returns one value and takes no time; it describes pure combinational logic.

Why you need this

Keeps expressions readable.

How it works

function [W-1:0] name(input ...); ... endfunction

Where you'll see this

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

Try it

Parity and maxVerilog: edit and run

Functions are combinational and instantaneous.

Test what you just read

1. Functions take...