The SystemVerilog preprocessor runs before the compiler sees the code. ` define`, ifdef` and include`` do pure text substitution with no type checking and no scope.
TOPIC MAP — PREPROCESSOR TO SIMULATOR
source.sv ──► PREPROCESSOR ──► expanded text ──► COMPILER ──► ...
│
┌────────────┼──────────────┐
│ │ │
▼ ▼ ▼
`define `ifdef `include
text macros conditional file paste
(lesson 1) compilation + guards
(lesson 2) (lesson 3)
│ │ │
└────────────┴──────────────┘
│
▼
Debugging macro problems (lesson 4:
expansion errors, loud guards, safe
log macros, build stages)Lesson | Covers |
|---|---|
Object-like and function-like macros, the parens rule, multiline bodies, and macros versus parameters. | |
` | |
Textual paste semantics, the double-include failure, the guard pattern, and search paths. | |
Expansion-error reading, loud configuration guards, a safe log macro, and build stages. |
A missing command-line define (` ifdef`` on a misspelled or unset name is silently false), or a macro redefined later in compile order so the second build expands a different body.