Turn a stream of sensor bytes into a memory record another program can read immediately.
Hardware context: The boot sequencer and S6 firmware board running a sensor input program. Implement a logger that publishes ordered samples and their sum before ringing the completion doorbell.
A sensor feeds UART0. Another program owns the log buffer and polls a completion word. Write the firmware between them.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
trial | 8 | input of each check |
Full specification
| Address | Meaning |
|---|---|
| 80000000 | Requested count, zero through seven |
| 80000004 | Byte address of the first aligned output word in SRAM |
| 80000008 | Write the full unsigned sum here |
| 8000000c | Completion word starts at zero. Write one after the log and sum are visible. |
| 10000004 | UART status. Bit 1 means a sample waits. Bit 0 describes transmit room. |
| 1000000c | Receive data. A read consumes the oldest byte. Zero is a valid sample. |
All addresses above are hexadecimal. Store each received byte as a zero-extended word in arrival order.
For an empty ticket publish a zero sum immediately. Preserve the ticket and all memory outside the requested outputs.
Finish with a jump to itself. The board allows 520 instruction ticks, including waits for input.
| Program row | Convention |
|---|---|
| i(LUI, d, 0, upper) | Load upper 20 bits. i(ADDI, d, s, k) adds a signed constant. |
| i(LW, d, base, offset) / i(SW, s, base, offset) | Offsets count bytes. Each operation transfers a word. |
| i(ANDI, d, s, mask) / i(ADD, d, a, b) | Mask bits or add two register values. |
| i(BEQ, a, b, address) / i(JAL, 0, 0, address) | Targets are absolute byte addresses. Each row occupies four bytes. |
Examples
Example 1
Capture 1- Input
1 samples; buffer at SRAM + 128 bytes
- Output
correct = 1
One sample produces one word and the same sum.
Example 2
Capture 2- Input
3 samples; buffer at SRAM + 160 bytes
- Output
correct = 1
Three samples occupy twelve bytes. A zero byte still takes a slot.
Example 3
Capture 3- Input
0 samples; buffer at SRAM + 272 bytes
- Output
correct = 1
The empty log occupies no sample words. The sum becomes zero before completion.
Constraints and Contract
- Keep module sensor_logger. Edit only the_program and use at most 128 instruction rows.
Hints
Hint 1
Test the count before inspecting the UART.
Hint 2
Read status as often as needed. Read data once per accepted sample.
Hint 3
Compute the next slot using the width of a stored record.
What the grader checks: The hidden S6 firmware bench varies arrival times, values, counts and buffer placement. It checks memory at publication and termination.
6 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path