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.

vishnu vaishnav | Sukhveer R. | Vadher Chirag | Harsh Bhut | Harsh Patel |Kaushal Narodiya | Janak Dharaiya | Anand Dodiya | Indeeksha Digital Pvt. Ltd. | IndEeksha Innovative Semiforce (ActivEdge)

Whatsapp Call Email Inquiry