Home / Learn Verilog / `define Macros

`define Macros

Text substitution.

The short versionText substitution.

Theory in plain words

Macro`define W 8`W usedtext replaced
Macro

In plain terms

`define NAME value replaces NAME with value before compilation.

Why we use it

Constants and short code snippets.

Under the hood

Use backtick when you use them; prefer parameters for module constants.

Real-world use

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

Try it

Macro constantsVerilog: edit and run

Macros are global; parameters are local.

Quick quiz

1. Macros are used with...