VLSI Training in Ahmedabad | UVM Training in Gujarat – Indeeksha Digital Pvt. Ltd.

fork...join_any or fork...join_none block after N threads complete

May 20, 2025

How to exit a fork...join_any or fork...join_none block after N threads complete ? — not all, just a few......

I recently explored some ways to do this, and here’s what I found:

  • Counter — Simple idea: each thread increments a shared count, and you wait until it hits N.
  • Works… but not thread-safe. Two threads could mess up the count if they increment at the same time.
  • Event — Threads trigger events when done, and you wait for N such events.
  • Again, not thread-safe — but great for handshaking and synchronization between processes.
  • Semaphore — This one’s solid. Each thread calls put() when done. You just get(N) and move on.
  • Thread-safe. No race conditions. Works beautifully.
  • UVM Barrier — A UVM-based solution that lets you sync threads by setting a threshold.
  • Great if you're already in a UVM environment.
  • Internally uses counters and events — so similar limitations apply, just better encapsulated.

I’ve also included a simple explanation of what a uvm_barrier actually is (UVM for dummies style!) in the attached PPT — and even if you're new to UVM, you'll still be able to understand it.

Bottom line: If you're working in SystemVerilog alone, semaphores are your best bet — clean, safe, and reliable when threads are fighting to update shared data. But if you're in a UVM environment, uvm_barrier gives you a neat, built-in way to handle thread sync — just know what’s under the hood. Either way, understanding when and how to exit after N threads gives you much better control over your testbench behavior.
If you need a PPT on this topic, feel free to ping us! We'd be happy to assist.

If you found these tools helpful, feel free to share this knowledge with as many students and professionals as possible.
Always open to feedback or ideas to expand this tool further!

Ready to expand your knowledge in VLSI, SV, UVM, and semiconductor trends?
To explore more insights and updates, kindly click on the link below and become a part of our group — INDEEKSHA INNOVATIVE SEMIFORCE.

Join INDEEKSHA INNOVATIVE SEMIFORCE today! Click the link below and be part of the movement.

https://www.linkedin.com/groups/10068204/

Whatsapp Call Email Inquiry