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.

Three Managers' Traffic Interleaving at SRAMInside the fabric, one value per cycle: which manager the SRAM's port took, the seat's hready, and whether the DMA was asking.
0123456789101112131415161718192021222324252627282930313233343536373839system cycle32333435363738394041424344454647484950515253545556575859606162636465666768697071SRAM takesseatdmaseat-seatdmaseatdmaseat-seatdmaseatdmaseat-seatdmaseatdmaseat-seatdmaseatdmaseat-seatdmaseatdmaseat-seatdmaseatdmaseat-seat hreadyDMA askssystem cycle 33
Scroll horizontally ↔
  1. 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.

  2. 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.

  3. 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.

  4. 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.

Five questions this page answers
Question
1Why does a concurrency bug need two managers at one target in the same cycle?
2How does the bench put three managers on the fabric at once?
3What does a seed do for a concurrent test?
4Why must a stress test check every manager's data?
5What 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.

A Recipe for Concurrent TrafficPick one target, send every manager there in the same cycles, check each manager's data, and vary the timing with a seed.
  • Memory
  • Manager
  • Debug
  • Control / FSM
  • Monitor
  • Data
  • Control
  • Transaction / TLM
A Recipe for Concurrent TrafficPick one target, send every manager there in the same cycles, check each manager's data, and vary the timing with a seed. memory One target SRAM, or the bridge manager Seat back to back manager DMA a copy job debug Debug manager a stream of reads control Seed random gaps monitor Checks every read, everybyte, DONE readscopyreadswhenresults
  1. memory One targetSRAM, or the bridge
    • results → Checks
  2. manager Seatback to back
    • reads → One target
  3. manager DMAa copy job
    • copy → One target
  4. debug Debug managera stream of reads
    • reads → One target
  5. control Seedrandom gaps
    • when → One target
  6. monitor Checksevery read, every byte, DONE
  1. One target

    Collisions happen only where managers share a target. Choose it on purpose.

  2. Every manager at once

    Start the DMA job and the debug reads, then let the seat read with no idle cycles.

  3. A seed for the timing

    Random gaps from a seed move the collisions around; one seed always gives the same run.

  4. 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

New words on this page
WordMeaning
Concurrent trafficTransfers of several managers on one fabric in the same cycles.
CollisionTwo managers asking for one target in the same cycle.
ContentionManagers competing for a target over many cycles.
SeedThe number a random generator starts from; the same seed gives the same run.
Stress testA test that loads the fabric on purpose to make rare timings common.
Double grantAn arbiter showing two managers' transfers to one target at once.
Debug streamA 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.

Two seeds, forty cycles each
SeedCycles where both askedRequests lostVerdict
111FAIL
700PASS

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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

The lab's rows (record-v7-labs.mjs, section stress).
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 1

On 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.

One table, one faulty chip, three ways to look
RunVerdictWhat it shows
Good chip, without the last rowpass201 finished transfers
Q103, without the last rowpassevery check passed; 249 finished transfers
Q103, with the read of the DMA's destinationfailseat: read 80003900 = 00000000, expected 13579bdf (mask ffffffff)
Q103, a one-line checker at the SRAM's portreportsbuilt 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).

The checker: report when the SRAM's port shows anything but exactly one manager (ports hsel and hmaster of soc_tb.ahb_sram).
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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has three managers the bench can drive and one shared target at a time.

  1. Traffic generators

    Large fabrics are stressed by verification agents on every port, each drawing random transfers under constraints, with a scoreboard per target.

  2. Seeds by the thousand

    Regressions run thousands of seeds a night and keep the coverage of collisions, not only the pass rate.

  3. 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?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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 lost

Check Yourself

Predict the outputThe same arbiter with seed 7. What is the last line printed?
// Two managers ask for one target at random (an LCG from the seed). The arbiter has a bug: in a cycle where both
// ask, manager 1's request is dropped and never served. A test sees the bug only if both ask in the same cycle.
module tb;
  bit [31:0] state = 7;
  int asked [2], served [2], both = 0;
  function automatic bit coin();
    state = state * 32'd1664525 + 32'd1013904223;
    return state[31:29] == 0;   // asks in about 1 cycle of 8
  endfunction
  initial begin
    bit a0, a1;
    for (int c = 0; c < 40; c++) begin
      a0 = coin(); a1 = coin();
      asked[0] += a0; asked[1] += a1;
      if (a0 && a1) begin both++; served[0]++; end        // the bug: manager 1 is lost
      else begin served[0] += a0; served[1] += a1; end
    end
    $display("seed 7, 40 cycles: both asked in %0d cycles", both);
    $display("manager 0 asked %0d, served %0d; manager 1 asked %0d, served %0d", asked[0], served[0], asked[1], served[1]);
    if (served[1] == asked[1]) $display("PASS");
    else $display("FAIL: a request was lost");
  end
endmodule
ConceptIn the lab, why did Q103 pass the table without its last row?
ConceptWhat did the one-line checker at the SRAM's port check?
ConceptWhy does a stress test take a seed?
ConceptA fabric locks up and every manager waits. What ends the run with a failed check?

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.

Practice

Report a problem with this page