top of page

Synthesizability Considerations

​

Synthesizable Loops (for loop only)

​

For loops can be synthesized ONLY under these conditions:

​

  • Loop bounds must be CONSTANTS known at elaboration

​

  • Iteration count must be determinable at compile time

​

  • Loop is 'unrolled' into replicated hardware

​

  • No timing controls inside loop body

​

Synthesizable Example

Verilog

Non-Synthesizable Loops

Screenshot (762).png

Best Practices and Guidelines
 

Loop Selection Guide
 

  • Use for: Array operations, when you need the index value
     

  • Use while: When iteration count depends on a condition
     

  • Use repeat: For simple N-time repetition, waiting N cycles
     

  • Use forever: For clock generation and continuous monitoring
     

General Best Practices
 

  • Always use integer for loop variables
     

  • Include timing controls in while/forever loops
     

  • Use begin-end even for single statements (clarity)
     

  • Avoid deep nesting (max 2-3 levels)
     

  • Comment complex loop logic
     

  • Use parameters for loop bounds in synthesizable code
     

Synthesis Guidelines
 

  • Only use for loops in synthesizable code
     

  • Ensure loop bounds are constants
     

  • Keep iteration count reasonable for hardware size
     

  • Remember: loops unroll to replicated logic
     

  • Test synthesis results for large loop counts

 

Complete Testbench with All Loop Types

Verilog

Common Mistakes and Solutions

​

Mistake #1: Infinite Zero-Time Loop

Verilog

Mistake #2: Using reg for Loop Variables

Verilog

Mistake #3: Variable Loop Bounds in Synthesis

Verilog

Mistake #4: Forgetting begin-end

Verilog

Forever loop

Generate Block
 

© Copyright 2025 VLSI Mentor. All Rights Reserved.©

Connect with us

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