Write assembly for ap_soc's processor that fills all eight hazard bins of the coverage build. It must end with the pass word within 80 system cycles.
Hardware context: Random programs of the chip's lockstep gate on ap_soc v1.5, with real interrupt lines. Assembly that fills every hazard bin of the coverage build inside a cycle budget.
A random program generator leaves holes: rare pairs of instructions it hardly ever makes. A directed test fills each hole on purpose, for the price of the pair. Here you write that test, and you pay for every cycle.
Your program runs from SRAM on the processor of ap_soc, on the coverage build of the bench. The build counts the eight bins below on the core's retire records. Fill all eight, then write the pass word to TB_STATUS.
The budget is 80 system cycles for the whole run, from reset to the pass word. The grader accepts up to 10 percent over it: 88 cycles.
Full specification
| Bin | Hit when |
|---|---|
| raw1 | An instruction reads a register (not x0) that the record just before it wrote |
| raw2 | It reads a register written two records before, and not by the record just before |
| load_use | It reads the register that a load just before it wrote |
| load_store | A store's data register (rs2) is the one a load just before it wrote |
| store_load | A load reads the word that a store just before it wrote |
| branch_raw | A branch compares a register that the record just before it wrote |
| csr_raw | A CSR instruction reads or writes the CSR that the record just before it wrote |
| x0_write | An arithmetic instruction writes x0 (not the nop addi x0, x0, 0), and the next one reads x0 |
A bin is a pair of neighbouring records on the retire trace. Both must be records that did not trap: a trap breaks the pair. Only the order of records counts, so these bins say nothing about stalls or forwarding inside the pipeline.
The three instructions put in front of your program (TB_STATUS = 2, "main entered") are records too, and they already hit raw1. SRAM starts at 0x8000_0000 and your program is loaded there; the names of defs.S are given.
| Measured on this bench | Bins hit | Cycles |
|---|---|---|
| The reference | 8 of 8 | 51 |
| The starter: only the pass word | 1 of 8 | 25 |
| A nop between the load and its use | 6 of 8 | 52 |
| All eight, then a delay loop of 40 rounds | 8 of 8 | 210 |
Coverage Goal
Hit at least 8 of 8 declared bins across the runs. hazard.raw1, hazard.raw2, hazard.load_use, hazard.load_store, hazard.store_load, hazard.branch_raw, hazard.csr_raw, hazard.x0_write.
Total budget across runs is 80 system cycles with a 10% grading margin.
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
Examples
Example 1
The Starter- Input
only the pass word
- Output
bins hit: raw1; 25 cycles
The three instructions in front of the program already hit some bins. The rest need pairs of your own.
Example 2
The Reference- Input
one pair a bin, sharing where it can
- Output
all eight bins; 51 cycles
Thirteen instructions before the pass word make eight pairs. Some instructions belong to two pairs.
Example 3
All Eight, Too Slowly- Input
the reference, then a delay loop of 40 rounds
- Output
all eight bins; 210 cycles: over the budget
Coverage alone is not the goal. Each extra record costs simulation time in every regression run.
Constraints and Contract
- RV32I and Zicsr assembly for the SRAM layout, with the names of defs.S.
- One run. It must pass with the pass word, hit all eight bins, and stay within the budget plus 10 percent.
Hints
Hint 1
Each bin is two instructions in a row. Write the pair first, then look for pairs that can share an instruction.
Hint 2
Which of your pairs already hit raw1 without trying? Which bin can never be hit by a pair that also hits raw1?
Hint 3
A store and then a load of the same word: what address must the load use?
What the grader checks: One run on the coverage build of the bench. It checks that the run passes and that each of the eight bins has a hit. It checks that the run's system cycles stay within the budget plus 10 percent. It counts the three instructions in front of your program too. It does not check which pairs you chose, or that a pair means a stall in the pipeline.
1 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 3 problems on this path