Lanes meet at a barrier before every burst, and tests stop lanes in the middle of a run. Fix the barrier set-up and the leave hook so the lanes that remain start every burst together.
Hardware context: Three to five traffic lanes that must start each burst in the same nanosecond, with lanes stopped mid-run. Fix a barrier set-up and the hook that removes a lane from it.
A bench has three to five lanes. Before each of four bursts, every lane works for a while and then meets the others at a barrier. So all bursts of a round start in the same nanosecond.
Some tests stop a lane for good in the middle of the run. Sometimes the lane is waiting at the barrier when it is stopped; sometimes it is still working. The test then calls lane_left.
With the code you are given, the first round is fine and later rounds fall apart. Fix make_barrier and lane_left so that, in every round, all the lanes still running start their burst together, and none is left waiting.
Full specification
// Sets up the barrier the lanes meet at before every burst. Each lane looks it up
// by name: uvm_barrier_pool::get_global(name).
function automatic void make_barrier(string name, int unsigned lanes);
uvm_barrier bar = new(name, lanes);
bar.set_auto_reset(0);
endfunction
// Called when a lane is stopped for good. was_waiting is 1 if the lane was
// inside bar.wait_for() when it was stopped.
function automatic void lane_left(uvm_barrier bar, bit was_waiting);
bar.set_threshold(bar.get_threshold() - 1); // one fewer lane will arrive
endfunction
| Given | What it does |
|---|---|
| A lane | For each round: works lane_work ns, calls bar.wait_for(), records its start time, bursts for 10 ns. |
| Stopping a lane | The test notes whether the lane is inside wait_for, kills its process, then calls lane_left(bar, was_waiting). |
lanes | The number of lanes in this case: 3, 4 or 5. |
| The barrier | Each lane gets it by name from the global barrier pool, uvm_barrier_pool::get_global(name). The test passes that same barrier to lane_left. |
Every case is its own barrier and lanes, all running in one test. The test reads the start times at 400 ns.
Examples
Example 1
A Lane Stopped While It Waits- Input
4 lanes, 4 rounds; lane 2 stopped at 23 ns
- Output
rounds_aligned = 4, burst_starts = 13
Lane 2 is inside wait_for when it is stopped, so the barrier still counts it. Cancel it, then lower the threshold to 3: lanes 0, 1 and 3 start rounds 2 to 4 together.
Example 2
A Lane Stopped While It Works- Input
4 lanes, 4 rounds; lane 1 stopped at 43 ns
- Output
rounds_aligned = 4, burst_starts = 14
Lane 1 has not arrived yet, so it is not in the count. Only the threshold changes; a cancel here would remove a lane that is really waiting.
Example 3
Three Lanes- Input
3 lanes, 4 rounds; no lane stopped
- Output
rounds_aligned = 4, burst_starts = 12
Nobody leaves. The barrier must be built for three lanes, not four.
Constraints and Contract
- Keep both signatures.
- Use only the barrier's own methods; do not add timers or polling.
- A round counts as aligned only if every lane that should start it starts at the same time.
Hints
Hint 1
Which barrier do the lanes wait at? Is it the one make_barrier sets up?
Hint 2
What does the barrier do after the first round releases, as the starter sets it up?
Hint 3
A lane killed inside wait_for was already counted. What does lowering the threshold do while it is still in the count?
Hint 4
A lane that was still working was never counted. What would a cancel take away then?
What the grader checks: Nine independent groups of three to five real lane processes, each with its own barrier, run together. Lanes are killed at chosen times, either inside wait_for or while working, and the checks compare the burst start times of every round.
9 checks on UVM · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 problem on this path