Stress: Random Concurrent Traffic
A fabric that serves one manager at a time can still fail when two ask in the same cycle. Make them ask together, at one target, with a seed for the timing, and check every manager's data. Then see a real fault that only a passive checker saw.
You Will Be Able To
- Explain why concurrency bugs need managers at one target in the same cycle.
- Build concurrent traffic from the seat, the DMA and the debug manager, with a seed.
- Say which data each manager's check must cover, and why a missing check hides a bug.
- Use a passive checker at a target port to see what no data check sees.
- Lesson
- V7.3
- Time
- 28 min
- Runs on
- Your browser
- Check
- 5 questions
In the stage E9 fault run, one matrix fault passed every check of its stimulus. The seat's reads were right and the DMA said DONE. A passive observer at the target ports was the only thing that saw it.
- Cycle 0
From system cycle 32 (column 0) the seat reads SRAM back to back while the DMA copies inside SRAM. In each cycle the SRAM's port takes one transfer, or none.
- Cycle 1
System cycle 33: the DMA asks, and the port takes the DMA's transfer. The seat's next read is not taken in this cycle.
- Cycle 3
System cycle 35: nobody is taken. SRAM spends this cycle on the seat's read, which follows the DMA's write, so the seat's hready stays low.
- Cycle 4
The pattern repeats: seat, DMA, seat, a free cycle. Round-robin hands the port over in turn.
The same bench on Icarus, with a probe in soc_tb that prints fabric signals and drives nothing (record-v7-labs.mjs, section stress, seed 5). The site's Verilator bench gave the same result block: pass, 1862 cycles.
Before You Start
Read Following a Transfer Across a Bridge, What Firmware Can Never Do and Passive Checkers: Bind and Listen first. Seeds and seeded random stimulus are defined in Random and Constrained-Random Stimulus.
| Question | |
|---|---|
| 1 | Why does a concurrency bug need two managers at one target in the same cycle? |
| 2 | How does the bench put three managers on the fabric at once? |
| 3 | What does a seed do for a concurrent test? |
| 4 | Why must a stress test check every manager's data? |
| 5 | What can a passive checker at a target see that a data check cannot? |
The Idea: Bugs That Need a Crowd
An arbiter has an easy job when one manager asks. It has a hard job when two ask in the same cycle. It must pick one, hold the other, and serve it later. Most fabric bugs live in that cycle. A test that runs the managers one after another never makes it.
So a stress test makes managers meet on purpose. It picks one target and starts a DMA job and a stream of debug reads. Then it lets the seat read the same target back to back. Then the target sees several requests in the same cycles, again and again.
Random timing moves the collisions around. The bench takes a seed and draws random gaps from it. Each seed gives a different pattern of meetings, and the same seed always gives the same run. A failing seed can be run again tomorrow.
- Memory
- Manager
- Debug
- Control / FSM
- Monitor
- Data
- Control
- Transaction / TLM
- One target
Collisions happen only where managers share a target. Choose it on purpose.
- Every manager at once
Start the DMA job and the debug reads, then let the seat read with no idle cycles.
- A seed for the timing
Random gaps from a seed move the collisions around; one seed always gives the same run.
- Check every manager
Each read, each byte the DMA wrote, and the end of every job.
Read the diagram as text
- One target: SRAM, or the bridge
- Seat: back to back
- DMA: a copy job
- Debug manager: a stream of reads
- Seed: random gaps
- Checks: every read, every byte, DONE
- Seat → One target: reads
- DMA → One target: copy
- Debug manager → One target: reads
- Seed → One target: when
- One target → Checks: results
Traffic rows of the bench (tb gaps, jtag stream, dma copy, core rq): tools/soc/ap_soc/bench/soc_tb/README.md.
New Words
| Word | Meaning |
|---|---|
| Concurrent traffic | Transfers of several managers on one fabric in the same cycles. |
| Collision | Two managers asking for one target in the same cycle. |
| Contention | Managers competing for a target over many cycles. |
| Seed | The number a random generator starts from; the same seed gives the same run. |
| Stress test | A test that loads the fabric on purpose to make rare timings common. |
| Double grant | An arbiter showing two managers' transfers to one target at once. |
| Debug stream | A series of reads by the debug manager that runs beside the seat's rows. |
The Smallest Example: A Bug That Needs Both
Two managers each ask about one cycle in eight. A buggy arbiter loses manager 1's request whenever both ask in the same cycle. How often do they meet? That depends on the seed.
| Seed | Cycles where both asked | Requests lost | Verdict |
|---|---|---|---|
| 1 | 1 | 1 | FAIL |
| 7 | 0 | 0 | PASS |
Recorded from the example below on the site's Icarus.
With seed 7 the managers never asked in the same cycle, so the bug never ran and the test passed. With seed 1 they met once, and a request was lost. That is why stress tests run many seeds, and why they pile managers onto one target to make meetings common.
The Rules
Rule 1: Send every manager to one target in the same cycles.
Collisions need a shared target and overlapping requests. Back-to-back seat rows plus a DMA job plus debug reads make them every few cycles.
Rule 2: Vary the timing with seeds, and keep each seed.
Seeded gaps move the collisions around. A failing seed is the bug's replay.
Rule 3: Plan the addresses so managers do not clobber each other.
Give each manager its own area to write, or the test cannot say what each read should return.
Rule 4: Check every manager's data, not only the seat's.
A DMA that says DONE may have written the wrong bytes. Read the destination back.
Rule 5: Let a passive checker watch the target ports.
Some fabric faults leave every value right in one run. A checker on the port sees the rule they break, in every run.
Rule 6: Make the stuck run fail a check.
A test whose managers all hang reports nothing. Keep one manager that has a limit on its own wait, and check what it reads.
Sources for These Rules
Directed, then constrained concurrent, then fully random concurrent traffic: MEHTA-DV 14.3 and 14.4. The same sections divide the address map so subsystems do not clobber each other. Full concurrency surfaces deadlocks, livelocks and stalls.
The bench's traffic rows and their seed: tools/soc/ap_soc/bench/soc_tb/README.md, "Interconnect and boot experiments (E19)". The debug host gives up after 64 busy scans: tools/soc/ap_soc/bench/soc_tb/soc_pads.sv.
The seeded fault of this page and how E9 caught it: docs/soc/fault-table.md (npm run check:soc-faults); plan §3.10, stage E19.
A one-hot HMASTER at a target port is ap_soc's choice, not a signal of IHI 0033C. It says whose address phase the target sees (tools/soc/ap_soc/rtl/ap_ahb_matrix_out.sv).
The Lab: Three Managers, One Target
The table starts a DMA copy of 64 bytes inside SRAM and two debug reads of the source word. Then the seat reads that word 96 times back to back.
core w 80003100 13579bdf ffffffff 00000000 0 1
core w 10006000 80003100 ffffffff 00000000 0 1
core w 10006004 80003900 ffffffff 00000000 0 1
core w 10006008 00000040 ffffffff 00000000 0 1
core w 1000600c 00000001 ffffffff 00000000 0 1
jtag stream 80003100 00000002 00000003 13579bdf 0 1
core rq 80003100 00000000 ffffffff 13579bdf 0 96
core idle 00000000 00000000 ffffffff 00000000 0 1
core poll 10006014 000007d0 00000007 00000002 0 1
core r 80003900 00000000 ffffffff 13579bdf 0 1On the good chip it passed in 1862 cycles. The probe counted whom the SRAM's port took: the seat 98 times, the DMA 128 and the debug manager 2. The DMA's 128 are a read and a write for each of its 64 bytes. The trace at the top shows a slice of it (rule 1).
Now the same table on a faulty chip. Q103 is one of the chip's seeded faults of stage E9, in the matrix. When two managers ask for one target in the same cycle for the first time, its arbiter grants both. The E9 fault table says only a passive observer caught it: neither the firmware column nor the bus-manager column has a mark.
| Run | Verdict | What it shows |
|---|---|---|
| Good chip, without the last row | pass | 201 finished transfers |
| Q103, without the last row | pass | every check passed; 249 finished transfers |
| Q103, with the read of the DMA's destination | fail | seat: read 80003900 = 00000000, expected 13579bdf (mask ffffffff) |
| Q103, a one-line checker at the SRAM's port | reports | built into the chip bench; silent on the good chip |
Fault release fault-36c8b1a3d6eb9bf8787a, seed 5. For the last row the checker was built into the chip bench and run on the good chip and on Q103.
Without its last row, the table checks the seat's reads and the DMA's DONE, as the E9 stimulus did. Both were right, so Q103 passed. Add one read of the DMA's destination and the loss shows: a word that should be 0x1357_9BDF reads 0. The DMA's writes to it never reached SRAM (rule 4).
assign report = hsel && (hmaster != 1) && (hmaster != 2) && (hmaster != 4) && (hmaster != 8);The checker needs no knowledge of the data at all. It knows one rule of the matrix: a target serves one manager at a time. It reported on Q103 in a run where every value was right, and stayed silent on the good chip (rule 5). One more clue was in the result all along: 249 finished transfers against 201, with the same table.
Why It Is Built This Way
Why does the bench offer a debug stream and seat gaps instead of a fully random traffic generator? A table stays readable: each row says what a manager does, and the seed only moves the timing. A failing run can be read row by row and replayed exactly.
Why give the target ports a one-hot hmaster at all? A checker can then ask "who is this transfer for?" at the target, not only at each manager. Rules about sharing, such as one owner at a time, can only be checked where the sharing happens.
Traps
The polite-traffic trap: the stress test starts the DMA, waits for DONE, and then runs the seat. Nothing ever met. Every concurrency fault on this page passes such a test.
The checked-only-the-seat trap: the stress test checks every read of the seat and only the DMA's DONE. The DMA's lost write slips through, as Q103's did in the E9 run. A manager's job is done when its data is right, not when it says so.
The idle-cycle trap: the seat's rows have gaps between them, so the seat rarely asks in the same cycle as the DMA. Collisions at that target become rare, and a seed or two may never make one.
The silent-hang trap: on a fabric that locks up, every manager waits and no row fails. The run ends at a limit with nothing to say. Rule 6 keeps one manager able to fail a check.
At Scale
This section looks ahead. ap_soc has three managers the bench can drive and one shared target at a time.
Traffic generators
Large fabrics are stressed by verification agents on every port, each drawing random transfers under constraints, with a scoreboard per target.
Seeds by the thousand
Regressions run thousands of seeds a night and keep the coverage of collisions, not only the pass rate.
Memory scoreboards
Instead of reading back each word, a reference model of memory follows every write and compares a dump at the end.
Try It
Run it: with seed 1 the managers meet once and a request is lost.
Try seed 7 (the predict question below). What is the verdict?
How would you make the two managers meet in more cycles without more seeds?
seed 1, 40 cycles: both asked in 1 cycles manager 0 asked 4, served 4; manager 1 asked 5, served 4 FAIL: a request was lostCheck Yourself
Common Mistakes
Wrong Run the managers one after another and call it a stress test.
No two managers ever ask in the same cycle.
Fix Start the DMA and the debug reads, then let the seat read the same target back to back.
Wrong Check the seat's reads and the DMA's DONE only.
A DMA write lost in a collision still ends in DONE.
Fix Read back what every manager wrote.
Wrong Trust one passing seed.
It proves only the collisions it made.
Fix Run many seeds, keep the failing ones, and measure which collisions were made.
Remember
- Concurrency bugs need managers at one target in the same cycle: make them meet on purpose.
- Seeds move the collisions; keep the failing seed as the replay.
- Check every manager's data: a DMA that says DONE can still have lost a write.
- A passive checker at a target port sees rules a data check misses, in every run.