Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ774
Page ↗
Q774DVASIC interview problem

Capture per-iteration values in fork...join_none

TechniquesDVSystemVerilogfork joinAutomatic lifetimeConcurrency
DifficultyMedium
TopicTestbench Concurrency
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

A loop spawns three join_none children. Correct the code so each child prints its own iteration value, then state what output ordering is and is not guaranteed.

Starting declarationSystemVerilog
for (int i = 0; i < 3; i++) fork
  // child print
join_none
wait fork;

Example input and output

Use this case to check your interpretation
Input
three iterations spawn three join_none children
Output
one legal print order is 0, 2, 1
Explanation

The captured multiset is deterministic, but sibling scheduling is not, so any permutation of 0, 1, and 2 is legal.

02

Requirements (4)

  • Print exactly one occurrence of each value 0, 1, and 2.
  • Capture i in an automatic variable declared in the fork scope for that iteration.
  • Wait for every spawned child before the parent finishes.
  • Do not assert any particular ordering among sibling processes.