An arbitration policy is a promise you can check. Write a checker that watches the DMA's port and the SRAM's port and reports when the DMA waits longer than round-robin allows.
Hardware context: The round-robin arbiter of each target of ap_soc's matrix. A fairness checker for the DMA at SRAM.
ap_soc's matrix arbitrates each target round-robin (FAIR = 1, facts 27.7). The search for the next manager starts one above the manager served last. With four managers, a waiting transfer is served before the target takes more than three transfers of the others. That is the promise.
Write a checker for it at SRAM, for the DMA. The DMA's transfer starts waiting in a cycle where the DMA shows an address phase to SRAM with hready high. SRAM must not take it in that cycle. It stops waiting in the cycle SRAM takes it. Count the transfers of other managers that SRAM takes while it waits, the first cycle included. Report when the count passes three.
Each case runs traffic of the seat, the DMA and the debug manager on SRAM. On the good chip your checker must stay silent; on each hidden faulty chip it must report.
Full specification
input logic clk, resetn, // clk_sys and the bus reset
input logic [31:0] haddr, input logic [1:0] htrans, input logic hready, // the DMA's manager port
input logic peer_hsel, input logic [1:0] peer_htrans, input logic peer_hready, input logic [3:0] peer_hmaster, // the SRAM's target port
output logic report
| Port | Signal | Note |
|---|---|---|
| haddr | the address phase's address | 32 bits |
| htrans | transfer type | 2 = NONSEQ; bit 1 high: a transfer |
| hready | the port's HREADY | an address phase is accepted, and a data phase ends, in a cycle where it is 1 |
| peer_htrans | transfer type | 2 = NONSEQ; bit 1 high: a transfer |
| peer_hready | the target's HREADYOUT, which is also its HREADY input | an address phase is accepted, and a data phase ends, in a cycle where it is 1 |
| peer_hsel | the target is selected | the matrix shows one manager's address phase |
| peer_hmaster | one-hot: whose address phase is shown | bit 0 debug, bit 1 DMA, bit 2 core data port (the seat), bit 3 core instruction port |
SRAM is the window 0x8000_0000 to 0x8000_FFFF. SRAM takes an address phase when peer_hsel, peer_htrans bit 1 and peer_hready are all 1. Then peer_hmaster says whose it is.
Given Files
Read-only files supplied by the bench.
ports.sv
// Observation site: soc_tb.ahb_dma,soc_tb.ahb_sram
module learner_checker(input logic clk, input logic resetn, input logic [31:0] haddr, input logic [1:0] htrans, input logic hready, input logic peer_hsel, input logic [1:0] peer_htrans, input logic peer_hready, input logic [3:0] peer_hmaster, output logic report);
// Supply the module body only.
endmodule
report.txt
soc_tb samples report on each rising edge of clk with resetn high. Assert report for a sampled violation. The bench counts reports.
The sequence table · bench manual
One row a line: who op address data mask expect delay repeat. Two words, four hex numbers, two decimal numbers. delay: cycles to wait before the row. repeat: how often the row runs. A line that starts with # is a comment. With +core=bfm the table is the test: the bench writes TB_STATUS = 2 before the first row and the pass or fail word after the last. With +core=cpu a table holds the bench's side of a firmware test.
| who | op | Meaning |
|---|---|---|
core | w wh wb | Write a word, a half, a byte of data at address; the answer must be OKAY |
core | r rh rb | Read; (value & mask) must equal (expect & mask) |
core | we re | Write or read that must answer ERROR |
core | wq rq | As w and r, with the next row's address phase on this row's data phase (back to back) |
core | poll | Read until the masked value is the expected one; data = the most reads (0: 1,000) |
core | irq | The interrupt pins now (bit 0 software, 1 timer, 2 external) against mask and expect |
core | wait_irq | Wait until a pin of mask is high; data = the most cycles |
core | idle | End a back-to-back run |
dma | copy | One job from address to data of mask bytes; STATUS must be expect (2 DONE, 4 FAULT) |
jtag | idcode | TAP reset, read IDCODE, compare |
jtag | halt resume step | Debug control (a halt waits for the core) |
jtag | rr rw | Read or write the register numbered address (0x1000 + n, a CSR, 0x7b0, 0x7b1) |
jtag | stream | Start background word reads at address A, count D, maximum random gap M, expected word E |
tb | wait_release | Wait for the system bus and core resets to release. Seat tables also hold each row at dispatch during reset. |
tb | watchdog | Set the seat stall limit to data system clocks (zero disables it). A stalled request reports its row, address and direction. |
tb | gaps | Maximum random gap D before each seat row, in system cycles (0 disables gaps) |
jtag | mr mw | Read or write a word of memory through the debug manager |
jtag | arm status | "Halt at reset" = data; {halted, error, busy} against mask and expect |
jtag | cmd | Command number address (0 to 7, facts 27.10) with the word data; its reply against mask and expect |
tb | uart_send | Send the byte data to the chip |
tb | uart_expect | The next byte from the chip must be expect; address = the most bit times to wait |
tb | gpio_set gpio_pulse | Pad address to level data; a pulse of data cycles of CLK |
tb | gpio_expect | The sixteen pads against mask and expect |
tb | reset supply | The reset pin, or the supply, for data cycles of CLK |
tb | wait_event | Wait until the test writes address to TB_EVENT |
tb | arg | Deposit data in TB_ARG |
tb | wait_status | Wait until (TB_STATUS & mask) equals (expect & mask) |
tb | poke peek | Back-door write of mask bytes (0: 4) of data; back-door read against mask, expect |
tb | wait | Only the delay |
sym | a symbol name | Back-door write of data to that C variable, with the symbol's size |
core and dma rows need +core=bfm. soc-rows.mjs turns a list of core and tb rows into both forms: a table for the seat, or a table in SRAM for an interpreter in ROM, with a hand-shake wherever the list goes from one side to the other.
## The sequence table
One row a line: `who op address data mask expect delay repeat`. Two words, four hex numbers, two decimal
numbers. `delay`: cycles to wait before the row. `repeat`: how often the row runs. A line that starts with `# `
is a comment. With `+core=bfm` the table is the test: the bench writes TB_STATUS = 2 before the first row and
the pass or fail word after the last. With `+core=cpu` a table holds the bench's side of a firmware test.
| who | op | Meaning |
| --- | --- | --- |
| `core` | `w` `wh` `wb` | Write a word, a half, a byte of `data` at `address`; the answer must be OKAY |
| `core` | `r` `rh` `rb` | Read; `(value & mask)` must equal `(expect & mask)` |
| `core` | `we` `re` | Write or read that must answer ERROR |
| `core` | `wq` `rq` | As `w` and `r`, with the next row's address phase on this row's data phase (back to back) |
| `core` | `poll` | Read until the masked value is the expected one; `data` = the most reads (0: 1,000) |
| `core` | `irq` | The interrupt pins now (bit 0 software, 1 timer, 2 external) against `mask` and `expect` |
| `core` | `wait_irq` | Wait until a pin of `mask` is high; `data` = the most cycles |
| `core` | `idle` | End a back-to-back run |
| `dma` | `copy` | One job from `address` to `data` of `mask` bytes; STATUS must be `expect` (2 DONE, 4 FAULT) |
| `jtag` | `idcode` | TAP reset, read IDCODE, compare |
| `jtag` | `halt` `resume` `step` | Debug control (a halt waits for the core) |
| `jtag` | `rr` `rw` | Read or write the register numbered `address` (`0x1000 + n`, a CSR, `0x7b0`, `0x7b1`) |
| `jtag` | `stream` | Start background word reads at address A, count D, maximum random gap M, expected word E |
| `tb` | `wait_release` | Wait for the system bus and core resets to release. Seat tables also hold each row at dispatch during reset. |
| `tb` | `watchdog` | Set the seat stall limit to `data` system clocks (zero disables it). A stalled request reports its row, address and direction. |
| `tb` | `gaps` | Maximum random gap D before each seat row, in system cycles (0 disables gaps) |
| `jtag` | `mr` `mw` | Read or write a word of memory through the debug manager |
| `jtag` | `arm` `status` | "Halt at reset" = `data`; `{halted, error, busy}` against `mask` and `expect` |
| `jtag` | `cmd` | Command number `address` (0 to 7, facts 27.10) with the word `data`; its reply against `mask` and `expect` |
| `tb` | `uart_send` | Send the byte `data` to the chip |
| `tb` | `uart_expect` | The next byte from the chip must be `expect`; `address` = the most bit times to wait |
| `tb` | `gpio_set` `gpio_pulse` | Pad `address` to level `data`; a pulse of `data` cycles of CLK |
| `tb` | `gpio_expect` | The sixteen pads against `mask` and `expect` |
| `tb` | `reset` `supply` | The reset pin, or the supply, for `data` cycles of CLK |
| `tb` | `wait_event` | Wait until the test writes `address` to TB_EVENT |
| `tb` | `arg` | Deposit `data` in TB_ARG |
| `tb` | `wait_status` | Wait until `(TB_STATUS & mask)` equals `(expect & mask)` |
| `tb` | `poke` `peek` | Back-door write of `mask` bytes (0: 4) of `data`; back-door read against `mask`, `expect` |
| `tb` | `wait` | Only the delay |
| `sym` | a symbol name | Back-door write of `data` to that C variable, with the symbol's size |
`core` and `dma` rows need `+core=bfm`. `soc-rows.mjs` turns a list of `core` and `tb` rows into both forms: a
table for the seat, or a table in SRAM for an interpreter in ROM, with a hand-shake wherever the list goes from
one side to the other.
Examples
Example 1
The Good Chip- Input
your checker, every case
- Output
silent
The DMA waits behind a few transfers, never more than three.
Example 2
Back to Back- Input
the seat reads SRAM in every cycle it can
- Output
silent
Round-robin still lets the DMA in.
Example 3
A Hidden Faulty Chip- Input
your checker on a faulty chip
- Output
reports
The DMA waits while SRAM keeps taking the others.
Constraints and Contract
- Use assign, always_comb or always_ff @(posedge clk), with if, else and begin/end. Local state is bit or logic, up to 32 bits a variable. Expressions use ports, local names, literals and the operators ! ~ & | ^ + - == != && || < > <= >= << >> ? : and bit selects. Nothing else of SystemVerilog is accepted: no braces, no system tasks, no hierarchy.
- Report only when the promise breaks: a report on the good chip fails the case.
- Each check builds the chip bench once with your checker inside. That took about 17 s on the laptop (measured); expect an estimated 40 s or more on the live server.
Hints
Hint 1
The manager port shows the DMA's side; only the target port shows whom SRAM took.
Hint 2
A transfer SRAM takes in the same cycle it is shown never waits.
Hint 3
Under heavy traffic the good chip makes the DMA wait behind some transfers: a limit of zero is wrong.
What the grader checks: Your checker is built into the ap_soc v1.5 bench at the two sites. Each case runs on the good chip, where the checker must stay silent. It also runs on a hidden faulty chip, where it must report. The grader cannot see your exact limit. Under these cases the good chip never makes the DMA wait behind more than one transfer. So a limit of one, two or three is accepted, and so is a larger one the hidden chip exceeds. The promise is three.
3 checks on ap_soc v1.5 · DMA AHB + SRAM AHB checker · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your text only; the chip, the bench and the hidden checks stay on the server. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path