top of page

14.6.4. Forever Loop

​

The forever loop creates an infinite loop that continues until explicitly disabled or simulation ends. It is exclusively used in testbenches for continuous operations like clock generation and monitoring.

​

Syntax and Structure

Verilog

Characteristics

​

  • Executes infinitely (no termination condition)

​

  • MUST contain timing control (#delay or @event)

​

  • Typically used in initial blocks

​

  • Can be stopped with disable statement

​

  • NOT synthesizable (testbench only)

​

Primary Use: Clock Generation

Verilog

Other Forever Loop Applications

Verilog

Controlling Forever Loops
 

Using disable Statement

Verilog

Using $finish

Verilog

Critical: Must Have Timing Control
 

âš  CRITICAL: Forever loops MUST contain timing control or they create infinite zero-time loops that HANG the simulator!

Verilog

Repeat loop

Advanced techniques
 

© Copyright 2025 VLSI Mentor. All Rights Reserved.©

Connect with us

  • Instagram
  • Facebook
  • Twitter
  • LinkedIn
  • YouTube
bottom of page