Firmware can only say that the timer matched "eventually". From the seat you can say at which cycle. Pin the timer's match to its cycle, and catch every faulty chip of a hidden set.
Hardware context: The SRAM wrapper, the bridges and the checkers of ap_soc v1.5 under stimulus only the seat makes. The timer's match at its exact cycle, and every byte lane.
Write a table for the bus-manager seat that proves the Timer and PWM block matches at its exact cycle. Straight after reset, set DIV_TOP = 2 and COMPARE = 2, enable the match request and ap_plic source 3, and start the timer. The core's external pin must still be low in the cycle before the match is due, and high in the cycle after. Then stop the timer, clear the match, and claim and complete source 3.
Your table must pass on the good chip and fail on each chip of a hidden set. Which faults the set holds, the page does not say. Use the Timeline of a sample run to find the cycles.
Full specification
| Register | Address | Use |
|---|---|---|
| DIV_TOP | 0x1000_200C | The prescaler: the slot advances every DIV_TOP + 1 cycles |
| COMPARE | 0x1000_2010 | The slot (0 to 3) that matches |
| RUN | 0x1000_2000 | 1 starts the count from the slot it holds; 0 stops it |
| IRQ_ENABLE, IRQ_CLEAR | 0x1000_2018, 0x1000_2014 | Enable the match request; clear it |
| ap_plic | 0x0C00_000C priority 3, 0x0C00_2000 enable bit 3, 0x0C20_0004 claim | Source 3 is the timer |
The delay field of a row is the number of clk_sys cycles the seat waits before that row. A seat row takes a fixed number of cycles, so a table's timing is the same on every run.
Rows: who op address data mask expect delay repeat (two words, four hex numbers, two decimal numbers). A core r row checks (value & mask) == (expect & mask). Rows core re and core we must answer ERROR. A core poll row reads until the masked value matches, at most data reads. The bench manual lists every row.
Given Files
Read-only files supplied by the bench.
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.
Timer and PWM · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | RUN | 0 | run | rw | 0x0 | regs | Starts and stops the counter. 1: the counter runs. |
0x004 | DUTY | 2:0 | slots | rw | 0x0 | regs | How many of the four slots drive the PWM pin high. 0 to 4. |
0x008 | CAPTURED | 1:0 | slot | ro | block | The slot number saved when the capture input fired. Slot number. | |
0x00C | DIV_TOP | 7:0 | top | rw | 0x00 | regs | Prescaler: the last count before the slot number steps. A write restarts the prescaler. Last prescaler count. |
0x010 | COMPARE | 1:0 | slot | rw | 0x0 | regs | The slot number that raises match. Slot number. |
0x014 | IRQ_CLEAR | 0 | match | wo | not stored | Writing 1 to bit 0 clears the stored match flag. 1 clears the flag. | |
0x018 | IRQ_ENABLE | 0 | match | rw | 0x0 | regs | Lets the stored match flag raise interrupt source 3. 1 enables the request. |
0x020 | EVENT | 0 | enable | rw | 0x0 | regs | Six teaching fields (S6.8). Plain read and write. |
0x020 | EVENT | 1 | online | ro | block | A level from the hardware. | |
0x020 | EVENT | 2 | kick | wo | not stored | A written 1 makes one pulse. | |
0x020 | EVENT | 3 | pending | w1c | block | Set by an event; a written 1 clears it. | |
0x020 | EVENT | 4 | seen | rc | block | Set by an event; a read clears it. | |
0x020 | EVENT | 5 | route | rw | 0x0 | block | Takes the first write only. |
0x024 | EVENT_COUNT_LOW | 31:0 | value | ro | block | Low 32 bits of the 64-bit event counter. Count, low word. | |
0x028 | EVENT_COUNT_HIGH | 31:0 | value | ro | block | High 32 bits of the event counter. Count, high word. |
## Timer and PWM (base 0x1000_2000, interrupt source 3, clk_sys, PD_PER) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | RUN | 0 | run | rw | `0x0` | regs | Starts and stops the counter. 1: the counter runs. | | `0x004` | DUTY | 2:0 | slots | rw | `0x0` | regs | How many of the four slots drive the PWM pin high. 0 to 4. | | `0x008` | CAPTURED | 1:0 | slot | ro | | block | The slot number saved when the capture input fired. Slot number. | | `0x00C` | DIV_TOP | 7:0 | top | rw | `0x00` | regs | Prescaler: the last count before the slot number steps. A write restarts the prescaler. Last prescaler count. | | `0x010` | COMPARE | 1:0 | slot | rw | `0x0` | regs | The slot number that raises match. Slot number. | | `0x014` | IRQ_CLEAR | 0 | match | wo | | not stored | Writing 1 to bit 0 clears the stored match flag. 1 clears the flag. | | `0x018` | IRQ_ENABLE | 0 | match | rw | `0x0` | regs | Lets the stored match flag raise interrupt source 3. 1 enables the request. | | `0x020` | EVENT | 0 | enable | rw | `0x0` | regs | Six teaching fields (S6.8). Plain read and write. | | `0x020` | EVENT | 1 | online | ro | | block | A level from the hardware. | | `0x020` | EVENT | 2 | kick | wo | | not stored | A written 1 makes one pulse. | | `0x020` | EVENT | 3 | pending | w1c | | block | Set by an event; a written 1 clears it. | | `0x020` | EVENT | 4 | seen | rc | | block | Set by an event; a read clears it. | | `0x020` | EVENT | 5 | route | rw | `0x0` | block | Takes the first write only. | | `0x024` | EVENT_COUNT_LOW | 31:0 | value | ro | | block | Low 32 bits of the 64-bit event counter. Count, low word. | | `0x028` | EVENT_COUNT_HIGH | 31:0 | value | ro | | block | High 32 bits of the event counter. Count, high word. |
ap_plic · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x004 + 4 × (n − 1), n = 1 to 16 | PRIORITY | 2:0 | level | rw | 0x0 | block | Priority of source n, 0 to 7. 0 never competes. Priority. |
0x001000 | PENDING | 16:1 | sources | ro | block | Pending bits; bit number = source ID. One bit for each source. | |
0x002000 | ENABLE | 16:1 | sources | rw | 0x0000 | block | Enable bits; bit number = source ID. One bit for each source. |
0x200000 | THRESHOLD | 2:0 | level | rw | 0x0 | block | The core sees a request only above this priority. Threshold. |
0x200004 | CLAIM | 4:0 | id | rw | 0x00 | block | Read: claim, returns the winner's ID and clears its pending bit. Write: complete, names the ID that is done. Source ID. |
## ap_plic (base 0x0C00_0000, clk_sys, PD_MAIN) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x004` + 4 × (n − 1), n = 1 to 16 | PRIORITY | 2:0 | level | rw | `0x0` | block | Priority of source n, 0 to 7. 0 never competes. Priority. | | `0x001000` | PENDING | 16:1 | sources | ro | | block | Pending bits; bit number = source ID. One bit for each source. | | `0x002000` | ENABLE | 16:1 | sources | rw | `0x0000` | block | Enable bits; bit number = source ID. One bit for each source. | | `0x200000` | THRESHOLD | 2:0 | level | rw | `0x0` | block | The core sees a request only above this priority. Threshold. | | `0x200004` | CLAIM | 4:0 | id | rw | `0x00` | block | Read: claim, returns the winner's ID and clears its pending bit. Write: complete, names the ID that is done. Source ID. |
Examples
Example 1
The Good Chip- Input
your table
- Output
pass
The pin is low in the cycle before the match and high in the cycle after.
Example 2
A Hidden Faulty Chip- Input
your table on a faulty chip
- Output
fail
A match that comes early, late or never fails one of your rows.
Example 3
What Does Not Count- Input
a wait for the pin with a limit
- Output
refused
It passes on a timer that matches too early.
Constraints and Contract
- At most 64 rows.
- The good chip must pass. Each hidden faulty chip must fail one of your rows.
Hints
Hint 1
A wait that ends "when the pin rises" passes on a chip whose timer is early.
Hint 2
Check the pin twice: low in the cycle before the match, high in the cycle after.
Hint 3
The delay of a row counts from the end of the row before it.
What the grader checks: Your table runs on the pre-built ap_soc v1.5 bench with +core=bfm, on the good chip and on several hidden faulty chips. The good chip must pass with no bench error. The hidden set holds timers whose match comes early, much later or not at all, or just one clock late. So a table must check both edges: the pin low just before the match, and high in the cycle after. On the late chip the bench's own timer monitor is off, so only your rows can see it. The grader cannot see which row caught which chip; it sees only that each hidden chip fails. The Timeline of a sample run shows the first 256 cycles of the good chip.
1 checks on ap_soc v1.5 · bus seat · 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