Scenarios That Cross Blocks: DMA, Bus and Interrupt Together

Real use runs several blocks at once: a DMA moves data while interrupts arrive and the core works. Build such a scenario from firmware, see what the passive checkers add, and learn where firmware cannot push the chip harder.

You Will Be Able To

  • Build a scenario in which the DMA, a peripheral and interrupts are active at the same time.
  • Say what the passive checkers see that a firmware test does not check.
  • Name what neither the firmware nor the checkers can see in a scenario.
  • Explain where firmware cannot stress the chip, and what does instead.
Lesson
V4.8
Time
28 min
Runs on
Your browser
Check
5 questions

Every block works alone. The DMA copies, the UART sends, the GPIO interrupts. Together they share one bus and one interrupt controller. A bug that needs two of them busy at once passes every test that runs them singly.

Three Timelines OverlappingStep through one scenario. The DMA feeds the UART, the board pulses a pin, and the core serves the pin.
  • Peripheral
  • Pads
  • Processor
  • Bus
  • Data
  • Interrupt
Three Timelines OverlappingStep through one scenario. The DMA feeds the UART, the board pulses a pin, and the core serves the pin. peripheral DMA cycles 327 to 1664:SRAM to UART0TXDATA pads UART0 and padIO0 15 bytes out peripheral GPIO pin 8 3 edges from theboard processor Core handlers from cycle447 to 1036 bus Fabric andmonitors DMA and core sharethe bus; passivecheckers watch reads, writesTXDATAsource 2handler loads, storessource 5: done
  1. peripheral DMAcycles 327 to 1664: SRAM to UART0 TXDATA
    • reads, writes → Fabric and monitors
    • source 5: done → Core
  2. bus Fabric and monitorsDMA and core share the bus; passive checkers watch
    • TXDATA → UART0 and pad IO0
  3. pads UART0 and pad IO015 bytes out
  4. peripheral GPIO pin 83 edges from the board
    • source 2 → Core
  5. processor Corehandlers from cycle 447 to 1036
    • handler loads, stores → Fabric and monitors
  1. The DMA starts

    Firmware programs a job from SRAM to TXDATA. The DMA paces itself on the UART's room.

  2. The board pulses

    While the job runs, three edges on IO8 raise GPIO interrupts.

  3. They share the bus

    The handlers' loads and stores and the DMA's transfers meet in the fabric. The passive checkers watch both.

  4. Done

    The DMA's own interrupt ends main's wait.

Read the diagram as text
  • DMA: cycles 327 to 1664: SRAM to UART0 TXDATA
  • UART0 and pad IO0: 15 bytes out
  • GPIO pin 8: 3 edges from the board
  • Core: handlers from cycle 447 to 1036
  • Fabric and monitors: DMA and core share the bus; passive checkers watch
  • DMA → Fabric and monitors: reads, writes
  • Fabric and monitors → UART0 and pad IO0: TXDATA
  • GPIO pin 8 → Core: source 2
  • Core → Fabric and monitors: handler loads, stores
  • DMA → Core: source 5: done

Cycles from the retire trace of the good run below.

Before You Start

Read Interrupt Tests End to End and DMA first. Passive checkers were introduced with the windows of a check.

Five questions this page answers
Question
1Why does a chip need tests where blocks work at once?
2How does firmware make several blocks busy together?
3What do the passive checkers add to such a test?
4What can neither firmware nor checkers see?
5Where can firmware not push the chip harder?

The Idea: Bugs Live Where Blocks Meet

A use case of a real product is never one block. A sensor's bytes arrive and the DMA moves them. An interrupt says they are there, the core processes them, and another block answers. Each step was tested; the overlap was not. Arbitration on the fabric, two interrupts at once, a register written while a job runs: these exist only when blocks run together.

Firmware can build such a scenario because it can start several things and then wait. It starts a DMA job, enables a peripheral, takes interrupts while the job runs, and waits for the job's own interrupt. The bench adds outside events at chosen moments.

Two kinds of checking run at once. The firmware checks the result it can see. The bench's passive checkers check every bus rule and every transfer of the blocks they watch, all the time. They catch what the firmware never looks at.

New Words

New words on this page
WordMeaning
ScenarioA test in which several blocks are busy at the same time, as in real use.
ConcurrencyTwo or more activities that overlap in time on the chip.
Block monitorA passive checker of one block's outputs, such as the DMA monitor that compares each byte written with the byte read.
ArbitrationThe fabric choosing which manager's transfer goes next when two want the bus.
Device register as destinationA DMA address in the APB window, which the DMA keeps fixed. For UART0's TXDATA and RXDATA it also waits for the UART.
Bus-manager seatThe bench's bus driver in the core's place, which can make transfers the core never makes.

The Smallest Example: Plan the Overlap

Before writing the scenario, write down who is busy when. A scenario is useful only if the activities really overlap.

A plan for the lab scenario
ActivityStartsEndsChecked by
DMA job: 15 bytes to TXDATASTART writtenDONE interruptDMA monitor; bytes on the pad
Three GPIO edgesBench, after the eventEach handlerThe firmware's count; the bench's ext_gpio
mainAfter STARTAfter DONEThe console line
The fabricAlwaysAlwaysAHB and APB rule checkers

From SCENARIO_C below.

The Rules

  1. Rule 1: Start everything, then wait.

    Arm every activity before the first one can finish, so they overlap.

  2. Rule 2: End on the slowest activity's own signal.

    Here the DMA's interrupt; a fixed delay may end the test too soon.

  3. Rule 3: Let the passive checkers watch the parts you do not check.

    They see every transfer, in every run.

  4. Rule 4: Check what only the test knows.

    Lengths, counts and final contents are intent; no monitor knows them.

  5. Rule 5: Use the bus-manager seat for what the core cannot do.

    Back-to-back transfers, exact timing and illegal accesses need the bench in the core's seat.

Sources for These Rules

The DMA's registers and its waits for UART0: docs/soc/ap_soc-facts.md 27.5 and 27.9. Its fixed device addresses: tools/soc/ap_soc/rtl/ap_dma.sv.

The bench's monitors and checkers: tools/soc/ap_soc/bench/soc_tb/README.md. The seat can overlap an address phase with the data phase before it, which the core never does: facts 27.12.

Scenario tests across blocks as a class of chip-level verification: plan §2.1, item 4. The faults are seeded faults of stage E9 (docs/soc/fault-table.md).

Now Run It: One Scenario, Three Chips

The kit has no DMA driver yet, so the lab writes the DMA's registers itself. It sets source, destination and length, enables the DONE interrupt and starts the job.

SCENARIO_C: the DMA feeds the pad; the core counts edges; the DMA's interrupt ends it.
#include "drivers/gpio.h"
#include "irq.h"
#include "tb.h"

static const char text[] = "dma to the pad\n";
static volatile unsigned edges, dma_done;
static void on_edge(void) { gpio_ack(1u << 8); edges = edges + 1; }
static void on_dma(void) { reg_write32(DMA_STATUS, DMA_STATUS_DONE_MASK); dma_done = 1; }

int main(void)
{
    reg_write32(SYSCTL_PINMUX, 2u);                  /* IO0 carries UART TX */
    reg_write32(UART0_DIV, 8);
    gpio_rising_irq(1u << 8);
    irq_enable(GPIO_IRQ, on_edge);
    irq_enable(DMA_IRQ, on_dma);
    reg_write32(DMA_IRQ_ENABLE, DMA_IRQ_ENABLE_DONE_MASK);
    reg_write32(DMA_SRC, (unsigned)text);
    reg_write32(DMA_DST, UART0_TXDATA);              /* a device register: the DMA waits for room */
    reg_write32(DMA_LEN, sizeof text - 1);
    reg_write32(DMA_START, 1);
    tb_event(0x7710);                                /* bench: three edges on IO8, while the DMA runs */
    while (!dma_done) { }
    tb_puts("edges ");
    tb_put_hex(edges);
    tb_putc('\n');
    return 0;
}
Measured on our bench (soc_tb, Verilator 5.052 2026-09-05); faulty chips selected at run time on the bench's fault build.
good (the chip as designed):
  EVENT 334: 00007710
  CONSOLE 1933: edges 00000003
  reason=pass uart_bytes=15 dma_bytes=15 ext_gpio=3 monitor_errors=0
Q046 (Write data is broadcast with its low bit cleared):
  EVENT 334: 00007710
  MONITOR dma: the byte written is not the byte read (address 80000419, 14 bytes left)
  reason=checker uart_bytes=1 dma_bytes=2 ext_gpio=0 monitor_errors=1
Q044 (The programmed transfer loses its final byte):
  EVENT 334: 00007710
  CONSOLE 1847: edges 00000003
  reason=pass uart_bytes=14 dma_bytes=14 ext_gpio=3 monitor_errors=0

On the good chip the DMA job ran from cycle 327 to 1664. The three GPIO handlers ran inside it, from 447 to 1036: rule 1. The slice below measures the overlap. No bus rule was broken, and 15 bytes reached the pad.

On Q046 the DMA writes each byte with its low bit cleared. The firmware checks nothing about the bytes, yet the run failed at cycle 427. The DMA monitor saw a byte written that differs from the byte read. That is rule 3: a check nobody wrote into the test.

On Q044 the job loses its last byte. The run passed: 14 bytes left the pad, not 15. The monitor compares what the DMA writes with what it reads, and both were right; only the length was wrong. No monitor knows how many bytes the test meant to send. Rule 4: that check belongs to the test, here a bench row that expects every byte on the pad.

Why It Is Built This Way

The same scenario could be driven by the bus-manager seat without the core. It would lose the real interrupt handlers and the real instruction flow. Firmware gives the scenario as the product will see it. What firmware cannot do is push harder. The core issues one legal transfer at a time, never back to back. Fabric stress and error injection belong to the seat (module V6).

Overlap also saves time. In the optimize problem of this page, the banner and the checksum ran one after the other in about 19,000 cycles. With the DMA feeding the UART they took about 11,200, measured on the laptop with GCC 14.2.

The Trap: The Scenario That Ran in Single File

A scenario test starts the DMA, waits for it to finish, then enables the GPIO interrupt and asks for edges. It passes, and it is three single-block tests in a row. The arbitration, the shared interrupt controller and the handler during a job were never exercised.

The second trap is trusting the monitors with everything. They know the rules of the bus and of each block, not the test's intent. A job that is one byte short is legal. The practice problems build a scenario, make a crossed wire visible, and fit two jobs inside one budget.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has one DMA and one core.

  1. Traffic generators

    Large chips add bus traffic generators beside the cores, so a scenario can run under a chosen load.

  2. Performance

    Scenarios measure latency and bandwidth; the bench's counters give numbers to compare with the architecture's targets.

  3. Software stacks

    Later in a project, scenarios become real drivers and real use cases, often on emulators (module V13).

Try It

Run the slice: it measures how long each pair of activities overlapped.

Move the GPIO handlers to start after the DMA job ended. What does the slice report?

The predict question below gives it only two of the lanes.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: DMA job cycles 327 to 1664 GPIO handlers cycles 447 to 1036 main waits cycles 335 to 1664 DMA job and GPIO handlers overlap for 589 cycles DMA job and main waits overlap for 1329 cycles GPIO handlers and main waits overlap for 589 cycles

Check Yourself

Predict the outputThe slice now reads only the DMA job and the GPIO handlers. What is the last line it prints?
// Three things one run did at once, each as an interval of cycles from its trace and the bench's log.
module tb;
  localparam int N = 2;
  string name [N];
  int    from [N], upto [N];
  function automatic int overlap(int a, int b);
    int lo = from[a] > from[b] ? from[a] : from[b];
    int hi = upto[a] < upto[b] ? upto[a] : upto[b];
    return hi > lo ? hi - lo : 0;
  endfunction
  initial begin
    name[0] = "DMA job"; from[0] = 327; upto[0] = 1664;
    name[1] = "GPIO handlers"; from[1] = 447; upto[1] = 1036;
    for (int i = 0; i < N; i++) $display("%-22s cycles %5d to %5d", name[i], from[i], upto[i]);
    for (int i = 0; i < N; i++)
      for (int j = i + 1; j < N; j++)
        $display("%s and %s overlap for %0d cycles", name[i], name[j], overlap(i, j));
  end
endmodule
ConceptWhy does a chip need tests where blocks run at once?
ConceptWhat did the DMA monitor catch that the firmware did not check?
ConceptA job loses its last byte and the run passes. Who should have caught it?
ConceptWhich stress can firmware not create?

Common Mistakes

Wrong Wait for one activity before starting the next.

The scenario becomes single-block tests in a row.

Fix Start everything, then wait on the slowest activity's own signal.

Wrong Leave all checking to the passive checkers.

They know the rules, not the test's intent: a short job is legal.

Fix Check counts, lengths and contents in the test.

Wrong Stress the fabric from firmware.

The core makes one legal transfer at a time.

Fix Use the bus-manager seat for stress and error injection.

Remember

  • Scenarios run several blocks at once, as real use does.
  • Start everything, then wait on the slowest activity's own signal.
  • Passive checkers catch broken rules the test never checks; only the test knows its intent.
  • Firmware cannot stress the fabric; the bus-manager seat can.

Practice

Report a problem with this page