Two harts each swapped the lock word and both read zero. Find the cycle where the bus arbiter broke a locked transfer, then repair it.
Hardware context: ap_soc exclusive monitor and bus arbiter. Spin locks and shared counters on a multi-manager bus
In this ap_soc variant the harts have no exclusive monitor. Each takes a spin lock with a locked read and write of the lock word (Arm IHI 0033 issue C section 3.3). The arbiter between the two harts must not hand the bus over in the middle of that pair. AMBA 2 puts that duty on the arbiter (IHI 0011A section 3.11.5).
A field log shows both harts inside the critical section. Run the failing bench, name the first wrong cycle and signal, choose the cause, then fix the arbiter.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
sample | 11 | input of each check |
Full specification
| At a rising edge | Effect |
|---|---|
| reset_n low | owner becomes 0 and held becomes 0. Reset takes priority. |
| hready low | Nothing changes. The current transfer is still in its data phase. |
| hready high, owner requests with lock high | held becomes 1 and owner keeps the bus. |
| hready high, otherwise | held becomes 0. If the other hart requests, it becomes owner. If not, owner keeps the bus. |
The locking rules follow IHI 0033 issue C section 3.3. The bus is locked after a cycle with HMASTLOCK and HREADY high. It is unlocked after a cycle with HMASTLOCK low and HREADY high. Taking turns when both harts request is an ap_soc design choice.
Section 3.3 also permits locked IDLE transfers inside a locked sequence. The ap_soc harts never issue them, so this arbiter keeps the bus only when the owner requests with lock high. Lock without a request counts as unlocked. Both are ap_soc design choices.
Diagnose the Failing Run
The test below runs the buggy design. Read its log, then find where it first goes wrong in the waveform.
Log
Waveform
Click a signal at a cycle to select it. Or focus the waveform and use the arrow keys: Left and Right move one cycle, Up and Down one signal.
Step 3 is optional: fix the code in the editor, then run the tests.
Examples
Example 1
Reset- Input
reset_n=0, req=00, lock=00, hready=1
- Output
owner = 0, held = 0
Hart 0 owns the idle bus and nothing is locked.
Example 2
Both Harts Request- Input
reset_n=1, req=11, lock=00, hready=1
- Output
owner = 1, held = 0
No lock is held, so the turn passes to hart 1.
Example 3
Only Hart 1 Requests- Input
reset_n=1, req=10, lock=00, hready=1
- Output
owner = 1, held = 0
Hart 0 is idle, so hart 1 keeps the bus.
Constraints and Contract
- Keep module lock_arbiter and its ports. Both outputs are registered.
- Reach the bench only through your ports. force, release, defparam, bind, $root and bench names are refused before the run.
Hints
Hint 1
Find the cycle where hart 1 has issued the locked read but not the locked write.
Hint 2
Which signal tells the arbiter that the owner's transfers belong together?
Hint 3
After the fix, check a wait state in the middle of a locked pair.
What the grader checks: The bench story checks reset, turn-taking, a locked pair, a wait state and the unlock. The fix cases try every input combination from each state, resets during wait states, and a random sequence with resets.
830 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path