V5.5.1 The End-of-Test Memory Compare

MediumImplement30 minVerilator + your C over DPI · serverReview the topic

Write the other way to check a core. Run the model to the end of the program, then compare its memory with the chip's. Report how many words differ, the first one, and the model's last store into it.

Hardware context: Two core faults of ap_soc v1.5 under a step compare and an end-of-test memory compare. An end-of-test compare of memory images.

A step compare checks every record as it retires. An end-of-test compare runs the model alone, to the end of the same program. Then it compares the final memory image with the one the chip left. It needs no trace at all, only the two images.

Write end_compare in endcompare.c. Step the model until it retires a jump to itself, within a record limit. Then compare a window of its SRAM with the chip's words. While the model runs, remember the pc of its last store into each word of the window. It is the only clue the method gives you.

The chips' tables were recorded on ap_soc v1.5: the two kernels of lesson V5.5, four rounds each. They ran on the good chip and on two chips with one core fault each.

Full specification
ReturnWhen
0Every compared word agrees (also when count is 0)
(differing << 24) | (first << 16) | (pc & 0xFFFF)differing is the count of words that differ. first is the first one's index in the window. pc is the model's last store into it, 0 if none.
0xFFFFFFFFThe model has not retired its jump to itself within max_records records

The model's SRAM is model_sram: byte i at 0x8000_0000 + i, little-endian. A record is a store when mem_wmask is not 0; mem_addr is the byte address it wrote. The bench answers every device read with 0, and accepts every device write.

Examples

Example 1

The Shift Kernel on the Good Chip
Input
shift kernel, the table of the good chip; words 0 to 63; 10000 records
Output
differing = 0, first_word = 0, last_store_pc_low = 0x0

The model's table and the good chip's agree word for word.

Example 2

The Shift Kernel on the Chip Whose SLL Shifts Right (Recorded)
Input
shift kernel, the table of the chip whose SLL shifts right; words 0 to 63; 10000 records
Output
differing = 64, first_word = 0, last_store_pc_low = 0x38

Every one of the 64 words differs. The first is word 0, last written by the store at pc 80000038, in the last round. When the SLL went wrong is not in the answer.

Example 3

The Byte Kernel on the Chip Whose SRL Fills from the Sign (Recorded)
Input
bytes kernel, the table of the chip whose SRL fills from the sign; words 0 to 63; 10000 records
Output
differing = 0, first_word = 0, last_store_pc_low = 0x0

This chip computed wrong values too, but the byte masks of the kernel removed every wrong bit. The images agree, and this method reports nothing.

Constraints and Contract

  • One file, endcompare.c, with end_compare of endcompare.h. Use only ap_iss.h calls, model_sram and the arguments.
  • The record that ends the run is counted. A model that needs N records to reach its jump to itself succeeds with max_records = N.
  • count is at most 1,024. first is word-aligned and inside SRAM.

Hints

Hint 1

Which record ends the run? One whose pc equals its next_pc and that did not trap.

Hint 2

Stores can be bytes or halves: the word they fall in is (mem_addr - first) / 4.

Hint 3

An image compare finds what is different now, not when it went wrong. Keep the last store, not the first.

What the grader checks: Each case runs your end_compare on one kernel and one chip's table. Some tables have one word changed; some cases use a smaller window or limit. It checks the three numbers you return. In these kernels each word has a single store instruction, so the grader cannot tell your first writer from your last. It cannot tell you when a word went wrong, and neither can the method.

14 checks on Verilator + your C over DPI · server. 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 2 problems on this path

Report a problem with this page

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

The Shift Kernel on the Good Chip

Input
shift kernel, the table of the good chip; words 0 to 63; 10000 records
Expected output
differing = 0, first_word = 0, last_store_pc_low = 0x0

The model's table and the good chip's agree word for word.

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

Verilator + your C over DPI · server