V2.2.1 Hello on Both Doors

EasyImplement25 minap_soc v1.5 · assembly · serverReview the topic

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
RegisterAddressUse
PINMUX0x1000_4010Two bits a pad; pad 0 carries UART TX with value 2
UART0 TXDATA0x1000_0000The next byte to send
UART0 STATUS0x1000_0004Bit 0 ROOM: the transmitter can take a byte
UART0 DIV0x1000_0010clk_sys cycles a bit; resets to 16
TB_PUTC, TB_STATUSap_sysctl 0x24, 0x20The 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
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000TXDATA7:0datawonot storedThe low byte is the next byte to send. Byte to send.
0x004STATUS0roomroblockTransmit room and receive queue state. The transmitter can take a byte.
0x004STATUS1rx_readyroblockAt least one received byte waits.
0x004STATUS2rx_fullroblockThe receive queue is full.
0x008IRQ_ENABLE0roomrw0x0regsWhich status bits raise interrupt source 1. ROOM raises the request.
0x008IRQ_ENABLE1rx_readyrw0x0regsRX_READY raises the request (new in v1.5).
0x00CRXDATA7:0dataroblockThe oldest received byte. The read removes it from the queue. Received byte.
0x010DIV15:0cyclesrw0x0010regsBit time in clk_sys cycles (new in v1.5). clk_sys cycles a bit.
ap_sysctl · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000CHIP_ID31:0valuero0x2A5310C5constThe chip's identity: the IDCODE of the TAP. Fixed number.
0x004RESET_CAUSE0power_onroblockSticky record of reset sources since power-on. Power-on reset.
0x004RESET_CAUSE1pinroblockReset pin.
0x004RESET_CAUSE2watchdogroblockWatchdog.
0x004RESET_CAUSE3softwareroblockSoftware request.
0x004RESET_CAUSE4debugroblockDebug request.
0x008SOFT_RESET0timerwonot storedReset requests from software. 1 arms one restart of the timer.
0x008SOFT_RESET1chipwonot stored1 requests the software reset (new in v1.5).
0x00CSTRAPS0bootroblockStraps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM.
0x010PINMUX31:0selectrw0x00000000regsTwo bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n.
0x014CLK_GATE0uart0rw0x1regs1 lets that block's clock run (new in v1.5). UART0.
0x014CLK_GATE1gpiorw0x1regsGPIO.
0x014CLK_GATE2timerrw0x1regsTimer and PWM.
0x014CLK_GATE3spirw0x1regsSPI.
0x014CLK_GATE4dmarw0x1regsDMA.
0x018LOCK0pinmuxw1s0x0regsWrite-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes.
0x018LOCK1clk_gatew1s0x0regs1: CLK_GATE ignores writes.
0x018LOCK2debugw1s0x0regs1: the debug lock is closed.
0x020TB_STATUS31:0valuerw0x00000000regs (power-on reset only)Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage.
0x024TB_PUTC31:0valuerw0x00000000regs (power-on reset only)Scratch word 1. The firmware kit writes one character here. Plain storage.
0x028TB_EVENT31:0valuerw0x00000000regs (power-on reset only)Scratch word 2. The firmware kit writes an event number here. Plain storage.
0x02CTB_ARG31:0valuerw0x00000000regs (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

Report a problem with this page

Your code RISC-V assemblySaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

TB_ARG = 0x2a

Input
TB_ARG = 0x2a
Expected output
console: "hello 2a\n"

TB_ARG = 0x2a: the line is "hello 2a".

Run samples executes all 3 public checks. Check all tests runs 5 checks on the server.

ap_soc v1.5 · assembly · server