Home / Learn Verilog / while, repeat and forever

while, repeat and forever

Loops for testbenches.

The short versionLoops for testbenches.

Theory in plain words

LoopsRTLfor with constantsTestbenchwhile repeat forever
Loops

In plain terms

while loops until false, repeat n runs n times, forever never ends.

Why we use it

Clocks, waiting for conditions.

Under the hood

Mostly testbench constructs; not for synthesis.

Real-world use

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

Try it

Loops in a testbenchVerilog: edit and run

repeat counts edges; while waits for a condition.

Quick quiz

1. forever loops...