A given C test receives bytes in three rounds and echoes them. Write the bench's side as a UVM virtual sequence. Wait for each request, send two random printable bytes, then reply. The firmware is sometimes slow, so the order is the test.
Hardware context: Hand-shakes between firmware and the bench of ap_soc v1.5 through TB_EVENT and TB_ARG. The bench's side of a hand-shake as a UVM virtual sequence beside a C test.
The firmware runs on the processor and owns the bus. It sets up UART0 and then plays three rounds. In round r it writes TB_EVENT = 0x30 + r and waits for TB_ARG = 0x40 + r. Then it reads two bytes from the receive pad and echoes each one.
Write the bench's side. In each round, wait for the request. Send two bytes through p_sequencer.uart with soc_pad_seq, each randomized into the printable range 32 to 126. Only when both frames are on the line, deposit the reply into TB_ARG through the back door.
After the last echo the firmware writes TB_EVENT = 0x3F. Wait for it, and let the last echo finish before your sequence ends. The environment's scoreboard checks every echo against the byte you sent.
In some runs the firmware is slow to get ready, or slow between rounds. await_event gives up after 800 polls, one cycle apart, so write your own wait with a limit.
Each check compiles your classes with the whole chip's UVM environment. On the laptop that took 115.4 s (measured, with other jobs running). On the live server the whole reference took 5.7 minutes with an empty queue (measured once). Allow more when the server is busy. The page shows your place in the queue and the elapsed time.
Full specification
| Step | Firmware (given) | Your sequence |
|---|---|---|
| 1 | checks that no byte has arrived yet | waits: TB_EVENT reads 0x30 + r |
| 2 | TB_EVENT = 0x30 + r: "send two bytes now" | sends two randomized bytes, one frame at a time |
| 3 | waits for TB_ARG = 0x40 + r, at most 20,000 polls | TB_ARG = 0x40 + r, through the back door |
| 4 | reads two bytes and echoes each on IO0 | the scoreboard compares the echoes |
| cc | Meaning |
|---|---|
| 0x11 to 0x13 | A byte arrived before round r asked |
| 0x21 to 0x23 | No reply 0x40 + r |
| 0x31 to 0x33 | The reply came before both bytes |
| 0x41 to 0x43 | A byte outside 32 to 126 |
| 0x50 | A seventh byte |
Before its first request the firmware sets PINMUX to 0x5AAA and DIV to 4; the board sends at 4 cycles a bit. Until then a byte on IO1 is lost. The bench may slow the firmware before it starts and after each round.
The firmware owns the bus, so reach the mailbox through the bench's back door. Read TB_EVENT with p_sequencer.regs.sysctl_tb_event.peek(status, value), and deposit the reply with sysctl_tb_arg.poke. A soc_pad_seq start returns when its frame is on the line. The given sequence API lists the class form and the calls you may use.
A run may end in a UVM error, or the firmware may stop before your sequence ends. The page then says so in one sentence and shows the console. It cannot show the UVM message itself.
What the grader sees: the firmware's console line, its four events, six bytes echoed on IO0, and no UVM error. With randomized bytes the pad hash differs between answers, so it is not graded.
Given Files
Read-only files supplied by the bench.
sequence-api.txt
class learner_seq extends chip_vseq;
virtual task body();
// Declare locals, start sequences, and check results here.
endtask
endclass
p_sequencer has bus, uart, gpio, flash and jtag handles. Access the register block through p_sequencer.regs. Use soc_pad_seq (op, a, d, reply) for board agents and soc_bus_seq (write, addr, data) for the bus.
Use uvm_reg and uvm_reg_field handles, get_field_by_name, read, write, mirror, predict, get_mirrored_value, get, set and update. peek reads TB_STATUS, TB_PUTC, TB_EVENT, TB_ARG, PINMUX or UART DIV. poke deposits into TB_ARG, PINMUX or UART DIV.
Declare bit, logic, int, byte and string locals, queues (int q[$]) and associative arrays (int scores[string]). Use push_back/front, pop_back/front, size, exists and delete.
Local uvm_event handles support trigger, wait_trigger and wait_ptrigger. Local uvm_barrier handles support wait_for and set_threshold. Use fork ... join for cooperating threads.
Report checks with `uvm_error and messages with `uvm_info, optionally using $sformatf. Quoted text accepts punctuation. Backslash escapes, backticks and hierarchy format specifiers are unavailable.
An optional submission_test extends learner_test. Its build_phase may configure agent activity or replace soc_pad_seq with soc_uart_byte_seq, then calls super.build_phase(phase).
For UART send use d[7:0]. For GPIO set a to the pad and d to its level. For flash use a as the byte offset and d as the value.
JTAG op selects IDCODE (0), halt (1), resume (2), memory read (3), memory write (4) or register read (5). The sequence returns reply.
Compile times depend on the submitted class.
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. |
Examples
Example 1
The Firmware Is Ready at Once- Input
no slowing
- Output
echoed 6 bytes in 3 rounds; events=4, uart_bytes=6
Three requests, three replies and the final event: four events. Each of the six bytes came back on IO0.
Example 2
Slow to Get Ready- Input
the firmware works for a while before its first request
- Output
echoed 6 bytes in 3 rounds; events=4
The first request comes thousands of cycles late. A sequence that sends at once loses its bytes, because IO1 is not routed to UART0 yet.
Example 3
A Reply Before the Bytes- Input
a sequence that writes TB_ARG first and sends after
- Output
refused
The firmware sees its reply, finds no byte waiting and stops with a fail code. The bench broke its promise.
Constraints and Contract
- Submit learner_seq extends chip_vseq with one body() task.
- Start soc_pad_seq on p_sequencer.uart; randomize it before every send.
- Give every wait a limit.
Hints
Hint 1
A loop around a peek of TB_EVENT and p_sequencer.api.idle is a wait you control.
Hint 2
Which side breaks its promise if the reply is written before the bytes?
Hint 3
TB_ARG keeps its last value. What would a reply of 0x41 in round 2 do?
What the grader checks: Four runs of the pre-built ap_soc v1.5 UVM bench, with the processor running the given firmware. It is ready at once, or slowed at its start or between rounds. Each grades the console line, the firmware's events and the echoed bytes, with no UVM error. The grader cannot see how long your waits allow, only whether every round kept its order.
4 checks on ap_soc v1.5 · UVM sequence · 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 3 problems on this path