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.
- Peripheral
- Pads
- Processor
- Bus
- Data
- Interrupt
- The DMA starts
Firmware programs a job from SRAM to TXDATA. The DMA paces itself on the UART's room.
- The board pulses
While the job runs, three edges on IO8 raise GPIO interrupts.
- They share the bus
The handlers' loads and stores and the DMA's transfers meet in the fabric. The passive checkers watch both.
- 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.
| Question | |
|---|---|
| 1 | Why does a chip need tests where blocks work at once? |
| 2 | How does firmware make several blocks busy together? |
| 3 | What do the passive checkers add to such a test? |
| 4 | What can neither firmware nor checkers see? |
| 5 | Where 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
| Word | Meaning |
|---|---|
| Scenario | A test in which several blocks are busy at the same time, as in real use. |
| Concurrency | Two or more activities that overlap in time on the chip. |
| Block monitor | A passive checker of one block's outputs, such as the DMA monitor that compares each byte written with the byte read. |
| Arbitration | The fabric choosing which manager's transfer goes next when two want the bus. |
| Device register as destination | A 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 seat | The 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.
| Activity | Starts | Ends | Checked by |
|---|---|---|---|
| DMA job: 15 bytes to TXDATA | START written | DONE interrupt | DMA monitor; bytes on the pad |
| Three GPIO edges | Bench, after the event | Each handler | The firmware's count; the bench's ext_gpio |
| main | After START | After DONE | The console line |
| The fabric | Always | Always | AHB and APB rule checkers |
From SCENARIO_C below.
The Rules
Rule 1: Start everything, then wait.
Arm every activity before the first one can finish, so they overlap.
Rule 2: End on the slowest activity's own signal.
Here the DMA's interrupt; a fixed delay may end the test too soon.
Rule 3: Let the passive checkers watch the parts you do not check.
They see every transfer, in every run.
Rule 4: Check what only the test knows.
Lengths, counts and final contents are intent; no monitor knows them.
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.
#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;
}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=0On 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
This section looks ahead. ap_soc has one DMA and one core.
Traffic generators
Large chips add bus traffic generators beside the cores, so a scenario can run under a chosen load.
Performance
Scenarios measure latency and bandwidth; the bench's counters give numbers to compare with the architecture's targets.
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.
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 cyclesCheck Yourself
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.