RTL Studio Open IDE

3.8 · SYSTEMVERILOG CLASS

Immediate Assertions

Use immediate assertions in testbenches to catch bugs exactly when they happen.

Watch on YouTube

What you practice

Immediate Assertions (3.8). Use immediate assertions in testbenches to catch bugs exactly when they happen. It is in Assertions — Part 3 · Advanced SV & Mini-UVM of the SystemVerilog Masterclass. Timing, concurrency, constrained-random verification, assertions, and a pure-SV Mini-UVM environment.

The same IDE is the SystemVerilog simulator. Slang lints the file, Verilator runs it, and the waveform viewer sits next to the source.

What you will learn

Immediate assertions let you validate conditions at precise simulation moments using procedural code inside always blocks or tasks.

Learning objectives

  • Understand how immediate assertions differ from concurrent assertions.
  • Write assert(condition) else $error(...) statements in procedural blocks.
  • Use $display and assertions together to validate testbench behavior.
  • Run simulation and interpret INFO: log lines to confirm correctness.

Theory

Immediate assertions are evaluated immediately when the statement is executed in procedural code (e.g., inside initial, always, or task blocks). They use the syntax:

SyntaxBehavior
assert(condition) ;Stops simulation if condition is false (default: $fatal).
assert(condition) else $error(...)Logs error and continues simulation.
assert(condition) else $warning(...)Logs warning and continues.

Unlike concurrent assertions (which sample on clock edges), immediate assertions check conditions *at the exact simulation time* the statement executes — ideal for checking intermediate values after stimulus or delays.

Practice

  1. Open this chapter in RtlStudio.

The files student/rtl/design.sv and student/tb/tb.sv appear in Explore.

  1. Edit student/tb/tb.sv to complete the three assert statements.
  2. In each assert statement, replace the __TODO__ placeholder with assert( so the full statement reads assert(sum == <expected>) else $error(...).
  3. Run Simulation and check the Log panel for INFO: lines.
  4. Verify the log ends with INFO: PASS.

Summary

Students practiced writing immediate assertions inside procedural blocks to validate signal values at specific simulation times. They learned to pair $display checkpoints with assert(condition) else $error(...) for precise, actionable feedback. Immediate assertions are essential for catching logic errors early in simulation without waiting for synthesis or formal tools.

Run it in the Verilog IDE

  1. Open the lesson in the IDE. The SystemVerilog for this topic is already in the editor.
  2. Lint with Slang before you simulate. It covers both Verilog and SystemVerilog in this IDE.
  3. Run Verilator and inspect the VCD. Interfaces, classes, and assertions count only if the simulator agrees.
  4. Run Yosys when the lesson is synthesizable RTL, and keep testbench-only constructs out of that module.

The lesson is done when the simulation matches Immediate Assertions. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.