Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • Start Here5
  • SystemVerilog Language Foundations28
  • Object-Oriented SystemVerilog for Verification30
  • Constraint Randomization — Interview-Critical Deep Dive39
  • SystemVerilog Assertions — Interview-Critical Deep Dive41
  • Functional Coverage in SystemVerilog25
  • Testbench Architecture in SystemVerilog24
  • Advanced Language & Integration26
    • DPI-C: Calling C from SystemVerilog
    • bind: Attaching Verification to RTL
    • Macros, Defines & Compilation
      • `define & Text Macros
      • `ifdef & Conditional Compilation
      • `include & Guard Discipline
      • Debugging Macro Problems
    • Plusargs, Files & Runtime Configuration
    • Simulation Performance & TB Memory
    • RTL/TB Boundaries, Races & Timing
    • What the Open Simulators Run
  • Senior & Interview Preparation23
  • Principal-Level Verification34
Loading lesson

←Advanced Language & Integration
  1. Topics
  2. SystemVerilog
  3. Advanced Language & Integration
  4. Macros, Defines & Compilation

Part 7 of 9Part 7 of 9/Advanced & IntegrationIntermediate

Macros, Defines & Compilation

Text macros, conditional compilation, include guards, and macro debugging for reliable builds.

  • 4topics
  • 4lessons

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.

When would I use this? When you write a log macro that adds file and line, a switch that turns checks on only in simulation, or a shared include file that many files pull in. You will also read other people's macros long before you write your own, so the debugging lesson pays off early.

Diagram
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

Path

Text macros

Object-like and function-like macros, the parens rule, multiline bodies, and macros versus parameters.

Recommended

Conditional compilation

` ifdef`` selection, command-line defines, sim-versus-synthesis guards, and configuration discipline.

Recommended

Include guards

Textual paste semantics, the double-include failure, the guard pattern, and search paths.

Optional

Debugging macros

Expansion-error reading, loud configuration guards, a safe log macro, and build stages.

Optional

Required is the core first pass for this part's goal, Recommended is for most learners, and Optional is reference, specialist or revision material.

Check yourself One build prints a banner macro and another stays silent, with identical source files. Name two preprocessor-level causes.

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.

Expect whiteboard fluency, not trivia.

  • Write a parenthesized function-like macro and explain each paren.

  • Explain ` ifdef` versus a run-time if, and include`` versus a package import.

  • Debug a dangling-else at a macro call site by re-expanding the macro by hand.

PreviousNext: `define & Text Macros

Up next

Up next`define & Text Macros

Sign in to save progress

Practice this lessonPrevious lessonReport an error

See also

  • DPI-C: Calling C from SystemVerilog
  • bind: Attaching Verification to RTL
  • Plusargs, Files & Runtime Configuration