Write the first program for the chip: one line on the bench console and the same bytes out of the UART pad. You set the pin mux and the divider.
Hardware context: The first run of ap_soc v1.5 from power-on reset to a console line. Integration day one.
Write the first program for ap_soc in assembly. It sends one line to the bench console through TB_PUTC, and the same bytes out of the UART TX pad, IO0. The line is hello followed by the low byte of TB_ARG as two lowercase hex digits and a new line.
The board's UART runs at 8 clk_sys cycles a bit, the test divider of this chip. The pad must carry UART TX, and every byte must leave the pad before the pass word.
Full specification
| Register | Address | Use |
|---|---|---|
| PINMUX | 0x1000_4010 | Two bits a pad; pad 0 carries UART TX with value 2 |
| UART0 TXDATA | 0x1000_0000 | The next byte to send |
| UART0 STATUS | 0x1000_0004 | Bit 0 ROOM: the transmitter can take a byte |
| UART0 DIV | 0x1000_0010 | clk_sys cycles a bit; resets to 16 |
| TB_PUTC, TB_STATUS | ap_sysctl 0x24, 0x20 | The console; the pass word 0x900D |
The names SYSCTL, UART, TB_PUTC, TB_STATUS and TB_ARG are defined for you. The chip starts your program in SRAM, after writing "main entered".
Given Files
Read-only files supplied by the bench.
defs.S
# defs.S: addresses and helpers of the smoke programs of ap_soc v1.5 (stage E4).
# check-soc-top.mjs puts this text in front of every program. Numbers: gen/ap_soc_regs.h.
.equ ROM, 0x00000000
.equ CLINT, 0x02000000
.equ PLIC, 0x0C000000
.equ UART, 0x10000000
.equ GPIO, 0x10001000
.equ TIMER, 0x10002000
.equ WDOG, 0x10003000
.equ SYSCTL, 0x10004000
.equ SPI, 0x10005000
.equ DMA, 0x10006000
.equ HOLE, 0x10007000
.equ PWRCTL, 0x10008000
.equ SRAM, 0x80000000
.equ TB_STATUS, 0x20
.equ TB_PUTC, 0x24
.equ TB_EVENT, 0x28
.equ TB_ARG, 0x2C
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
TB_ARG = 0x2a- Input
TB_ARG = 0x2a
- Output
console: "hello 2a\n"
TB_ARG = 0x2a: the line is "hello 2a".
Example 2
TB_ARG = 0x5c- Input
TB_ARG = 0x5c
- Output
console: "hello 5c\n"
TB_ARG = 0x5c: the line is "hello 5c".
Example 3
TB_ARG = 0- Input
TB_ARG = 0
- Output
console: "hello 00\n"
TB_ARG = 0: the line is "hello 00", with both digits.
Constraints and Contract
- Assembly for the SRAM layout.
- The console text and the bytes on the pad are both compared, for several values of TB_ARG.
Hints
Hint 1
The transmitter has one shifter. What happens to a byte written while it is busy?
Hint 2
A divider at its reset value sends at half the board's rate.
Hint 3
The pass word ends the run. Is the last frame out by then?
What the grader checks: Each case compares the console and the bytes the board received on the UART pad at 8 cycles a bit. It does not check the frames' exact timing.
5 checks on ap_soc v1.5 · assembly · 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