The bench's SPI flash model answers the chip with the wrong bytes. Find its three faults against mode 0 and the command list, and repair it without changing what it models.
Hardware context: The board's devices as models on the pads of ap_soc v1.5: UART, GPIO, SPI flash, JTAG. Repairing an SPI flash model.
A flash model must be small. It answers the three commands the tests use, in the bit timing of the chip's controller, and nothing more. This copy fails every read. The identity command comes back wrong, and three reads in a row return one triple three times.
Repair spi_flash_model. It has three faults. The commands and the image are right.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 4 | input of each check |
Full specification
| Command | Reply (24 bits, first byte highest) | Side effect |
|---|---|---|
| 9F | C0 FF EE | none |
| 03 | image[p], image[p + 1], image[p + 2] (wrapping at 256) | p moves on by three |
| 66 | 00 00 00 | p goes back to 0 |
| anything else | C0 FF EE | none |
Mode 0, as the chip's controller does it. It sets MOSI before the first rising edge and after each falling edge. It reads MISO on each rising edge. So the model takes MOSI on rising edges and changes MISO just after falling edges. After the eighth falling edge the model knows the command. Reply bit 23 must be on MISO for the ninth rising edge.
Examples
Example 1
The Identity, as the Chip Reads It- Input
9f, 9f, 9f
- Output
reply1 = 0xc0ffee, reply2 = 0xc0ffee, reply3 = 0xc0ffee, frames = 3
Three identity frames: C0 FF EE each time, and three complete frames.
Example 2
Three Reads in a Row- Input
03, 03, 03
- Output
reply1 = 0x30373e, reply2 = 0x454c53, reply3 = 0x5a6168, frames = 3
Three reads return bytes 0 to 2, 3 to 5 and 6 to 8 of the image. They are 30 37 3E, 45 4C 53 and 5A 61 68.
Example 3
Back to Byte 0, Then a Read- Input
03, 66, 03
- Output
reply1 = 0x3d444b, reply2 = 0x0, reply3 = 0x3d444b, frames = 3
A read, then 66 sends the pointer back to byte 0, so the next read returns the first three bytes again.
Constraints and Contract
- Keep the module name, the ports, image, pointer and frames.
- Before each case the bench loads the image, sets pointer and frames, and leaves cs_n high.
Hints
Hint 1
Draw one clock: when does MOSI change, and when should the model look at it?
Hint 2
After a 03, what must be different for the next 03?
Hint 3
Count: after the eighth falling edge bits is 8. Which reply bit belongs on MISO then?
What the grader checks: Seven scripts of three frames each, in the timing the chip's controller used in a recorded run of ap_soc v1.5. Each reports the 24 reply bits the controller read in every frame and the count of full frames. A short frame returns only the bits it clocked.
7 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 3 problems on this path