A C test reads one byte from the UART and never finishes: the run ends at its cycle limit. The trace ends in a loop of three instructions. Find the transfer where the test went wrong first.
The firmware asks the bench for its test byte with one event, then waits in uart_getc() for RX_READY. It should print got and the byte. The run ended at its cycle limit instead, and the last rows of the trace repeat a load of UART0 STATUS.
#include "drivers/uart.h"
#include "tb.h"
#define EVT_SEND 0x31 /* bench: send the test byte */
int main(void)
{
reg_write32(SYSCTL_PINMUX, 2u << 2); /* pad IO1 carries UART RX */
reg_write32(UART0_DIV, 8);
tb_event(EVT_SEND);
unsigned char b = uart_getc(); /* waits for RX_READY */
tb_puts("got ");
tb_put_hex(b);
tb_putc('\n');
return b != 0x5a;
}
The bench's side of the run: wait for an event, then send 0x5A on the receive pad.
| Who | Operation | Address | Data | Mask | Expect | Delay | Repeat |
|---|---|---|---|---|---|---|---|
| tb | wait_event | 00000013 | 00000000 | ffffffff | 00000000 | 0 | 1 |
| tb | uart_send | 00000000 | 0000005a | ffffffff | 00000000 | 0 | 1 |
The full specification holds the listing of main. The Recorded Wave Window shows 64 cycles from cycle 200 of the run. It holds the core's data bus (address, write data, read data) and the receive pad IO1.
The trace below shows 21 of 852 retired loads and stores, cycles 183 to 6005. Name the first transfer that went wrong: its cycle, the wrong part, its address and its register or variable. Then choose the cause.
Full specification
80000288 <main>:
80000288: addi sp,sp,-16
8000028c: sw ra,12(sp)
80000290: sw s0,8(sp)
80000294: li a5,8
80000298: lui a4,0x10004
8000029c: sw a5,16(a4)
800002a0: lui a4,0x10000
800002a4: sw a5,16(a4)
800002a8: li a0,49
800002ac: jal 8000027c <tb_event>
800002b0: lui a4,0x10000
800002b4: addi a4,a4,4
800002b8: lw a5,0(a4)
800002bc: andi a5,a5,2
800002c0: beqz a5,800002b8 <main+0x30>
800002c4: lui a5,0x10000
800002c8: lw s0,12(a5)
800002cc: lui a0,0x80000
800002d0: addi a0,a0,792
800002d4: jal 80000224 <tb_puts>
800002d8: zext.b a0,s0
800002dc: jal 80000244 <tb_put_hex>
800002e0: li a0,10
800002e4: jal 80000218 <tb_putc>
800002e8: lw ra,12(sp)
800002ec: zext.b a0,s0
800002f0: lw s0,8(sp)
800002f4: addi a0,a0,-90
800002f8: snez a0,a0
800002fc: addi sp,sp,16
80000300: ret
The register list names every address the answer may use. Addresses are in hex without 0x in the trace; write them with or without 0x in the form.
Data in the trace is the word as the bus carried it. A load's data is what came back; a store's is what was written.
Diagnose the Failing Run
Recorded Console and Result
EVENT 208: 00000031 verdict=fail reason=cycle_limit status=00000002 cycles=6008 traps=0 interrupts=0 mismatches=0
Retired Memory Transfers
| Cycle | PC (hex) | Operation | Address (hex) | Data (hex) |
|---|---|---|---|---|
| 183 | 8000007c | store | 10004020 | 00000002 |
| 188 | 8000028c | store | 8000fffc | 80000084 |
| 191 | 80000290 | store | 8000fff8 | 00000000 |
| 199 | 8000029c | store | 10004010 | 00000008 |
| 202 | 800002a4 | store | 10000010 | 00000008 |
| 209 | 80000280 | store | 10004028 | 00000031 |
| 216 | 800002b8 | load | 10000004 | 00000001 |
| 223 | 800002b8 | load | 10000004 | 00000001 |
| 230 | 800002b8 | load | 10000004 | 00000001 |
| 237 | 800002b8 | load | 10000004 | 00000001 |
| 244 | 800002b8 | load | 10000004 | 00000001 |
| 251 | 800002b8 | load | 10000004 | 00000001 |
| 258 | 800002b8 | load | 10000004 | 00000001 |
| 265 | 800002b8 | load | 10000004 | 00000001 |
| 272 | 800002b8 | load | 10000004 | 00000001 |
| 5970 | 800002b8 | load | 10000004 | 00000001 |
| 5977 | 800002b8 | load | 10000004 | 00000001 |
| 5984 | 800002b8 | load | 10000004 | 00000001 |
| 5991 | 800002b8 | load | 10000004 | 00000001 |
| 5998 | 800002b8 | load | 10000004 | 00000001 |
| 6005 | 800002b8 | load | 10000004 | 00000001 |
Recorded Wave Window
Samples from cycle 200
| Cycle | System clock edge | Time (ns) | d_haddr | d_hwdata | d_hrdata | IO1 |
|---|---|---|---|---|---|---|
| 200 | Rising | 2385 | 31 | 8 | 0 | 1 |
| 200 | Falling | 2390 | 31 | 8 | 0 | 1 |
| 201 | Rising | 2395 | 31 | 8 | 0 | 1 |
| 201 | Falling | 2400 | ffffffd0 | 0 | 0 | 1 |
| 202 | Rising | 2405 | ffffffd0 | 0 | 0 | 1 |
| 202 | Falling | 2410 | 10000000 | 0 | 0 | 1 |
| 203 | Rising | 2415 | 10000000 | 0 | 0 | 1 |
| 203 | Falling | 2420 | 10000000 | 0 | 0 | 1 |
| 204 | Rising | 2425 | 10000000 | 0 | 0 | 1 |
| 204 | Falling | 2430 | 10004000 | 0 | 0 | 1 |
| 205 | Rising | 2435 | 10004000 | 0 | 0 | 1 |
| 205 | Falling | 2440 | 10004028 | 0 | 0 | 1 |
| 206 | Rising | 2445 | 10004028 | 0 | 0 | 1 |
| 206 | Falling | 2450 | 800002b0 | 31 | 0 | 1 |
| 207 | Rising | 2455 | 800002b0 | 31 | 0 | 1 |
| 207 | Falling | 2460 | 800002b0 | 31 | 0 | 1 |
| 208 | Rising | 2465 | 800002b0 | 31 | 0 | 1 |
| 208 | Falling | 2470 | 8000ffe0 | 0 | 0 | 1 |
| 209 | Rising | 2475 | 8000ffe0 | 0 | 0 | 1 |
| 209 | Falling | 2480 | 8000ffe0 | 0 | 0 | 1 |
| 210 | Rising | 2485 | 8000ffe0 | 0 | 0 | 1 |
| 210 | Falling | 2490 | 10000000 | 0 | 0 | 1 |
| 211 | Rising | 2495 | 10000000 | 0 | 0 | 1 |
| 211 | Falling | 2500 | 10000004 | 0 | 0 | 1 |
| 212 | Rising | 2505 | 10000004 | 0 | 0 | 1 |
| 212 | Falling | 2510 | 10000004 | 0 | 0 | 1 |
| 213 | Rising | 2515 | 10000004 | 0 | 0 | 1 |
| 213 | Falling | 2520 | 0 | 0 | 0 | 1 |
| 214 | Rising | 2525 | 0 | 0 | 0 | 1 |
| 214 | Falling | 2530 | 0 | 0 | 1 | 1 |
| 215 | Rising | 2535 | 0 | 0 | 1 | 1 |
| 215 | Falling | 2540 | 0 | 0 | 0 | 1 |
| 216 | Rising | 2545 | 0 | 0 | 0 | 1 |
| 216 | Falling | 2550 | fffffff8 | 0 | 0 | 1 |
| 217 | Rising | 2555 | fffffff8 | 0 | 0 | 1 |
| 217 | Falling | 2560 | 10000000 | 0 | 0 | 1 |
| 218 | Rising | 2565 | 10000000 | 0 | 0 | 1 |
| 218 | Falling | 2570 | 10000000 | 0 | 0 | 1 |
| 219 | Rising | 2575 | 10000000 | 0 | 0 | 1 |
| 219 | Falling | 2580 | 10000004 | 0 | 0 | 1 |
| 220 | Rising | 2585 | 10000004 | 0 | 0 | 1 |
| 220 | Falling | 2590 | 0 | 0 | 0 | 1 |
| 221 | Rising | 2595 | 0 | 0 | 0 | 1 |
| 221 | Falling | 2600 | 0 | 0 | 1 | 1 |
| 222 | Rising | 2605 | 0 | 0 | 1 | 1 |
| 222 | Falling | 2610 | 0 | 0 | 0 | 1 |
| 223 | Rising | 2615 | 0 | 0 | 0 | 1 |
| 223 | Falling | 2620 | fffffff8 | 0 | 0 | 1 |
| 224 | Rising | 2625 | fffffff8 | 0 | 0 | 1 |
| 224 | Falling | 2630 | 10000000 | 0 | 0 | 1 |
| 225 | Rising | 2635 | 10000000 | 0 | 0 | 1 |
| 225 | Falling | 2640 | 10000000 | 0 | 0 | 1 |
| 226 | Rising | 2645 | 10000000 | 0 | 0 | 1 |
| 226 | Falling | 2650 | 10000004 | 0 | 0 | 1 |
| 227 | Rising | 2655 | 10000004 | 0 | 0 | 1 |
| 227 | Falling | 2660 | 0 | 0 | 0 | 1 |
| 228 | Rising | 2665 | 0 | 0 | 0 | 1 |
| 228 | Falling | 2670 | 0 | 0 | 1 | 1 |
| 229 | Rising | 2675 | 0 | 0 | 1 | 1 |
| 229 | Falling | 2680 | 0 | 0 | 0 | 1 |
| 230 | Rising | 2685 | 0 | 0 | 0 | 1 |
| 230 | Falling | 2690 | fffffff8 | 0 | 0 | 1 |
| 231 | Rising | 2695 | fffffff8 | 0 | 0 | 1 |
| 231 | Falling | 2700 | 10000000 | 0 | 0 | 1 |
| 232 | Rising | 2705 | 10000000 | 0 | 0 | 1 |
| 232 | Falling | 2710 | 10000000 | 0 | 0 | 1 |
| 233 | Rising | 2715 | 10000000 | 0 | 0 | 1 |
| 233 | Falling | 2720 | 10000004 | 0 | 0 | 1 |
| 234 | Rising | 2725 | 10000004 | 0 | 0 | 1 |
| 234 | Falling | 2730 | 0 | 0 | 0 | 1 |
| 235 | Rising | 2735 | 0 | 0 | 0 | 1 |
| 235 | Falling | 2740 | 0 | 0 | 1 | 1 |
| 236 | Rising | 2745 | 0 | 0 | 1 | 1 |
| 236 | Falling | 2750 | 0 | 0 | 0 | 1 |
| 237 | Rising | 2755 | 0 | 0 | 0 | 1 |
| 237 | Falling | 2760 | fffffff8 | 0 | 0 | 1 |
| 238 | Rising | 2765 | fffffff8 | 0 | 0 | 1 |
| 238 | Falling | 2770 | 10000000 | 0 | 0 | 1 |
| 239 | Rising | 2775 | 10000000 | 0 | 0 | 1 |
| 239 | Falling | 2780 | 10000000 | 0 | 0 | 1 |
| 240 | Rising | 2785 | 10000000 | 0 | 0 | 1 |
| 240 | Falling | 2790 | 10000004 | 0 | 0 | 1 |
| 241 | Rising | 2795 | 10000004 | 0 | 0 | 1 |
| 241 | Falling | 2800 | 0 | 0 | 0 | 1 |
| 242 | Rising | 2805 | 0 | 0 | 0 | 1 |
| 242 | Falling | 2810 | 0 | 0 | 1 | 1 |
| 243 | Rising | 2815 | 0 | 0 | 1 | 1 |
| 243 | Falling | 2820 | 0 | 0 | 0 | 1 |
| 244 | Rising | 2825 | 0 | 0 | 0 | 1 |
| 244 | Falling | 2830 | fffffff8 | 0 | 0 | 1 |
| 245 | Rising | 2835 | fffffff8 | 0 | 0 | 1 |
| 245 | Falling | 2840 | 10000000 | 0 | 0 | 1 |
| 246 | Rising | 2845 | 10000000 | 0 | 0 | 1 |
| 246 | Falling | 2850 | 10000000 | 0 | 0 | 1 |
| 247 | Rising | 2855 | 10000000 | 0 | 0 | 1 |
| 247 | Falling | 2860 | 10000004 | 0 | 0 | 1 |
| 248 | Rising | 2865 | 10000004 | 0 | 0 | 1 |
| 248 | Falling | 2870 | 0 | 0 | 0 | 1 |
| 249 | Rising | 2875 | 0 | 0 | 0 | 1 |
| 249 | Falling | 2880 | 0 | 0 | 1 | 1 |
| 250 | Rising | 2885 | 0 | 0 | 1 | 1 |
| 250 | Falling | 2890 | 0 | 0 | 0 | 1 |
| 251 | Rising | 2895 | 0 | 0 | 0 | 1 |
| 251 | Falling | 2900 | fffffff8 | 0 | 0 | 1 |
| 252 | Rising | 2905 | fffffff8 | 0 | 0 | 1 |
| 252 | Falling | 2910 | 10000000 | 0 | 0 | 1 |
| 253 | Rising | 2915 | 10000000 | 0 | 0 | 1 |
| 253 | Falling | 2920 | 10000000 | 0 | 0 | 1 |
| 254 | Rising | 2925 | 10000000 | 0 | 0 | 1 |
| 254 | Falling | 2930 | 10000004 | 0 | 0 | 1 |
| 255 | Rising | 2935 | 10000004 | 0 | 0 | 1 |
| 255 | Falling | 2940 | 0 | 0 | 0 | 1 |
| 256 | Rising | 2945 | 0 | 0 | 0 | 1 |
| 256 | Falling | 2950 | 0 | 0 | 1 | 1 |
| 257 | Rising | 2955 | 0 | 0 | 1 | 1 |
| 257 | Falling | 2960 | 0 | 0 | 0 | 1 |
| 258 | Rising | 2965 | 0 | 0 | 0 | 1 |
| 258 | Falling | 2970 | fffffff8 | 0 | 0 | 1 |
| 259 | Rising | 2975 | fffffff8 | 0 | 0 | 1 |
| 259 | Falling | 2980 | 10000000 | 0 | 0 | 1 |
| 260 | Rising | 2985 | 10000000 | 0 | 0 | 1 |
| 260 | Falling | 2990 | 10000000 | 0 | 0 | 1 |
| 261 | Rising | 2995 | 10000000 | 0 | 0 | 1 |
| 261 | Falling | 3000 | 10000004 | 0 | 0 | 1 |
| 262 | Rising | 3005 | 10000004 | 0 | 0 | 1 |
| 262 | Falling | 3010 | 0 | 0 | 0 | 1 |
| 263 | Rising | 3015 | 0 | 0 | 0 | 1 |
| 263 | Falling | 3020 | 0 | 0 | 1 | 1 |
Given Files
Use the register map to identify the transfer in the recording.
tb.h
#ifndef AP_TB_H
#define AP_TB_H
_Noreturn void tb_pass(void);
_Noreturn void tb_fail(unsigned code);
void tb_putc(char byte);
void tb_puts(const char *text);
void tb_put_hex(unsigned value);
void tb_event(unsigned id);
/* Slot zero is the single bench-to-firmware argument word. */
unsigned tb_arg(unsigned n);
void tb_wait_event(unsigned id);
#endif
drivers/uart.h
#ifndef AP_UART_H
#define AP_UART_H
#include "hal.h"
static inline void uart_flush(void)
{
while (!FIELD_GET(UART0_STATUS_ROOM, reg_read32(UART0_STATUS))) { }
}
static inline void uart_putc(unsigned char byte)
{
uart_flush();
reg_write32(UART0_TXDATA, byte);
}
static inline unsigned char uart_getc(void)
{
while (!FIELD_GET(UART0_STATUS_RX_READY, reg_read32(UART0_STATUS))) { }
return reg_read32(UART0_RXDATA);
}
static inline void uart_enable_rx_irq(void)
{
reg_write32(UART0_IRQ_ENABLE, UART0_IRQ_ENABLE_RX_READY_MASK);
}
#endif
UART0 · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | TXDATA | 7:0 | data | wo | not stored | The low byte is the next byte to send. Byte to send. | |
0x004 | STATUS | 0 | room | ro | block | Transmit room and receive queue state. The transmitter can take a byte. | |
0x004 | STATUS | 1 | rx_ready | ro | block | At least one received byte waits. | |
0x004 | STATUS | 2 | rx_full | ro | block | The receive queue is full. | |
0x008 | IRQ_ENABLE | 0 | room | rw | 0x0 | regs | Which status bits raise interrupt source 1. ROOM raises the request. |
0x008 | IRQ_ENABLE | 1 | rx_ready | rw | 0x0 | regs | RX_READY raises the request (new in v1.5). |
0x00C | RXDATA | 7:0 | data | ro | block | The oldest received byte. The read removes it from the queue. Received byte. | |
0x010 | DIV | 15:0 | cycles | rw | 0x0010 | regs | Bit time in clk_sys cycles (new in v1.5). clk_sys cycles a bit. |
## UART0 (base 0x1000_0000, interrupt source 1, clk_sys, PD_MAIN) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | TXDATA | 7:0 | data | wo | | not stored | The low byte is the next byte to send. Byte to send. | | `0x004` | STATUS | 0 | room | ro | | block | Transmit room and receive queue state. The transmitter can take a byte. | | `0x004` | STATUS | 1 | rx_ready | ro | | block | At least one received byte waits. | | `0x004` | STATUS | 2 | rx_full | ro | | block | The receive queue is full. | | `0x008` | IRQ_ENABLE | 0 | room | rw | `0x0` | regs | Which status bits raise interrupt source 1. ROOM raises the request. | | `0x008` | IRQ_ENABLE | 1 | rx_ready | rw | `0x0` | regs | RX_READY raises the request (new in v1.5). | | `0x00C` | RXDATA | 7:0 | data | ro | | block | The oldest received byte. The read removes it from the queue. Received byte. | | `0x010` | DIV | 15:0 | cycles | rw | `0x0010` | regs | Bit time in clk_sys cycles (new in v1.5). clk_sys cycles a bit. |
ap_sysctl · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | CHIP_ID | 31:0 | value | ro | 0x2A5310C5 | const | The chip's identity: the IDCODE of the TAP. Fixed number. |
0x004 | RESET_CAUSE | 0 | power_on | ro | block | Sticky record of reset sources since power-on. Power-on reset. | |
0x004 | RESET_CAUSE | 1 | pin | ro | block | Reset pin. | |
0x004 | RESET_CAUSE | 2 | watchdog | ro | block | Watchdog. | |
0x004 | RESET_CAUSE | 3 | software | ro | block | Software request. | |
0x004 | RESET_CAUSE | 4 | debug | ro | block | Debug request. | |
0x008 | SOFT_RESET | 0 | timer | wo | not stored | Reset requests from software. 1 arms one restart of the timer. | |
0x008 | SOFT_RESET | 1 | chip | wo | not stored | 1 requests the software reset (new in v1.5). | |
0x00C | STRAPS | 0 | boot | ro | block | Straps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM. | |
0x010 | PINMUX | 31:0 | select | rw | 0x00000000 | regs | Two bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n. |
0x014 | CLK_GATE | 0 | uart0 | rw | 0x1 | regs | 1 lets that block's clock run (new in v1.5). UART0. |
0x014 | CLK_GATE | 1 | gpio | rw | 0x1 | regs | GPIO. |
0x014 | CLK_GATE | 2 | timer | rw | 0x1 | regs | Timer and PWM. |
0x014 | CLK_GATE | 3 | spi | rw | 0x1 | regs | SPI. |
0x014 | CLK_GATE | 4 | dma | rw | 0x1 | regs | DMA. |
0x018 | LOCK | 0 | pinmux | w1s | 0x0 | regs | Write-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes. |
0x018 | LOCK | 1 | clk_gate | w1s | 0x0 | regs | 1: CLK_GATE ignores writes. |
0x018 | LOCK | 2 | debug | w1s | 0x0 | regs | 1: the debug lock is closed. |
0x020 | TB_STATUS | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage. |
0x024 | TB_PUTC | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 1. The firmware kit writes one character here. Plain storage. |
0x028 | TB_EVENT | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 2. The firmware kit writes an event number here. Plain storage. |
0x02C | TB_ARG | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 3. A bench leaves a word for the firmware here. Plain storage. |
## ap_sysctl (base 0x1000_4000, clk_sys, PD_MAIN) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | CHIP_ID | 31:0 | value | ro | `0x2A5310C5` | const | The chip's identity: the IDCODE of the TAP. Fixed number. | | `0x004` | RESET_CAUSE | 0 | power_on | ro | | block | Sticky record of reset sources since power-on. Power-on reset. | | `0x004` | RESET_CAUSE | 1 | pin | ro | | block | Reset pin. | | `0x004` | RESET_CAUSE | 2 | watchdog | ro | | block | Watchdog. | | `0x004` | RESET_CAUSE | 3 | software | ro | | block | Software request. | | `0x004` | RESET_CAUSE | 4 | debug | ro | | block | Debug request. | | `0x008` | SOFT_RESET | 0 | timer | wo | | not stored | Reset requests from software. 1 arms one restart of the timer. | | `0x008` | SOFT_RESET | 1 | chip | wo | | not stored | 1 requests the software reset (new in v1.5). | | `0x00C` | STRAPS | 0 | boot | ro | | block | Straps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM. | | `0x010` | PINMUX | 31:0 | select | rw | `0x00000000` | regs | Two bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n. | | `0x014` | CLK_GATE | 0 | uart0 | rw | `0x1` | regs | 1 lets that block's clock run (new in v1.5). UART0. | | `0x014` | CLK_GATE | 1 | gpio | rw | `0x1` | regs | GPIO. | | `0x014` | CLK_GATE | 2 | timer | rw | `0x1` | regs | Timer and PWM. | | `0x014` | CLK_GATE | 3 | spi | rw | `0x1` | regs | SPI. | | `0x014` | CLK_GATE | 4 | dma | rw | `0x1` | regs | DMA. | | `0x018` | LOCK | 0 | pinmux | w1s | `0x0` | regs | Write-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes. | | `0x018` | LOCK | 1 | clk_gate | w1s | `0x0` | regs | 1: CLK_GATE ignores writes. | | `0x018` | LOCK | 2 | debug | w1s | `0x0` | regs | 1: the debug lock is closed. | | `0x020` | TB_STATUS | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage. | | `0x024` | TB_PUTC | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 1. The firmware kit writes one character here. Plain storage. | | `0x028` | TB_EVENT | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 2. The firmware kit writes an event number here. Plain storage. | | `0x02C` | TB_ARG | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 3. A bench leaves a word for the firmware here. Plain storage. |