Simvik

Test the data and address buses

Find stuck data lines and stuck or shorted address lines in external RAM. A hard embedded C problem (Board bring-up, step by step), run and graded in the…

hard · Board bring-up, step by step · bring-up · memory-test · bits

Write the two classic bring-up tests for an external RAM. Run on a good board, both return 0. The address test trusts what it reads back, so it is only run after the data test passes.

test_data_bus(): at index 0, write each single-bit pattern from 0x00000001 up to 0x80000000 and read it straight back. Return the first pattern that does not read back, or 0.

test_address_bus(): uses the indexes 0 and each power of two below MEM_WORDS (1, 2, 4, ... 32), the "test offsets".

  1. Write PATTERN at every test offset, then ANTIPATTERN at index 0. If any test offset no longer reads PATTERN, its address line is stuck: return that offset.
  2. Write PATTERN back at 0. Then for each test offset t in turn: write ANTIPATTERN at t; if index 0 no longer reads PATTERN, return t; if any other test offset o no longer reads PATTERN, the two lines are shorted: return t | o. Then write PATTERN back at t.
  3. Return 0.

Starter code

uint32_t test_data_bus(void) {
  mem_write(0, 0xFFFFFFFFu);
  if (mem_read(0) != 0xFFFFFFFFu) return 0xFFFFFFFFu;
  return 0;
}

uint32_t test_address_bus(void) {
  return 0;
}

Example tests

A good board, then a broken data line

run("good");
data_stuck = 1u << 13;
run("D13 open");

Expected output:

good: data ok, address 0
D13 open: data 0x00002000, address not tested

An address line stuck low

addr_low = 4;
run("A2 stuck low");

Expected output:

A2 stuck low: data ok, address 4

Learn it first

More Board bring-up, step by step problems