Algorithm Search⌘K

Algorithmcore

March test

Also called March C-, memory march algorithm.

A memory test that walks through all addresses in up or down order applying read and write elements, such as March C- with 10n operations for stuck-at and coupling faults.

Time
O(m N) worst
Space
O(1) extra
Where
N = the number of memory cells; m = the total number of operations in all elements of the test
Properties
deterministicofflineiterative
Origin
Ravindra Nair, Satish M. Thatte, Jacob A. Abraham, Marian Marinescu, Ad J. van de Goor, 1978

A march test is a test for a random access memory of NN cells. It is a short list of march elements. Each element visits every address once, in increasing or in decreasing order, and at each address it runs the same few reads and writes before it moves on. A read expects a known value, and the test fails at the first read that gets another value. A march test takes time linear in NN, and the right choice of elements detects every cell stuck at 0 or 1, every cell that cannot change its value, every fault of the address decoder and every coupling of the memory coupling fault model. The best known example, March C− of van de Goor, has 6 elements and 10N10N operations. Memory testers and on-chip memory built-in self-test controllers run march tests on almost every memory that is made.

In plain words

A memory chip has millions of one-bit cells. A defect can make a cell stuck, make it unable to flip, or make a write to one cell disturb another cell. Trying every pair of cells would take far too long.

A march test sweeps the whole memory a few times. On each sweep it goes up or down the addresses and does the same small job at each cell, for example "read it and expect 0, then write 1". Because the sweep moves in one direction, every cell below the current one already has its new value and every cell above it still has its old one. Going up once and down once makes every pair of cells meet in both orders, so a disturbance between any two cells shows up as a wrong read later in the sweep.

The problem

The input is a memory of NN one-bit cells with addresses 0,…,N−10, \ldots, N - 1, and a march test. A march test is a list of elements M0,…,Me−1M_0, \ldots, M_{e-1}. Each element has an order, ⇑\Uparrow for increasing addresses, ⇓\Downarrow for decreasing addresses or ⇕\Updownarrow when either order works, and a list of operations. An operation is w0w0 or w1w1, a write, or r0r0 or r1r1, a read that expects the given value. The output is "pass", or the first failing read with its element, address and the value it got.

The faults are those of van de Goor's functional model, one fault at a time: a cell stuck at 0 or 1, a cell with a transition fault that cannot go up (↑\uparrow) or down (↓\downarrow), the inversion, idempotent and state couplings ⟨t;↕⟩\langle t; \updownarrow \rangle, ⟨t;v⟩\langle t; v \rangle and ⟨x;v⟩\langle x; v \rangle of the coupling page, and address decoder faults, where an address reaches no cell, the wrong cell or two cells. These are the memory counterparts of the stuck-at and transition fault models of logic. A fault is detected when the test fails from every initial content of the memory.

The algorithm

  1. MARCH(memory, M_0, …, M_{e−1}, N)
  2. 1for each element M_k = (order, operations) of the test
  3. 2for each address a from 0 to N − 1 if order is ⇑ or ⇕, from N − 1 to 0 if order is ⇓
  4. 3for each operation of M_k, in order
  5. 4if the operation is w v then write v to address a
  6. 5else the operation is r v: read address a
  7. 6if the value read is not v then return FAIL(k, a, the operation, the value)
  8. 7return PASS

The test is fixed before the run, so the same loop serves every march test. The code of this page gives March C− as

⇕(w0); ⇑(r0,w1); ⇑(r1,w0); ⇓(r0,w1); ⇓(r1,w0); ⇕(r0),\Updownarrow(w0);\ \Uparrow(r0, w1);\ \Uparrow(r1, w0);\ \Downarrow(r0, w1);\ \Downarrow(r1, w0);\ \Updownarrow(r0),

MATS+ as ⇕(w0); ⇑(r0,w1); ⇓(r1,w0)\Updownarrow(w0);\ \Uparrow(r0, w1);\ \Downarrow(r1, w0), and runs an element marked ⇕\Updownarrow upward.

Example

A transition fault. Take N=4N = 4 cells, all 0 at the start, and let cell 2 be unable to go from 1 to 0. MATS+ writes 0 everywhere, then on the upward sweep reads 0 and writes 1 at each cell, then on the downward sweep reads 1 and writes 0. The last write fails at cell 2, but no read follows, so MATS+ passes this memory.

March C− runs as follows.

element operations at cell 2 cell 2 after operations so far
M0M_0 ⇕(w0)\Updownarrow(w0) w0w0 0 4
M1M_1 ⇑(r0,w1)\Uparrow(r0, w1) r0r0 gets 0, w1w1 1 12
M2M_2 ⇑(r1,w0)\Uparrow(r1, w0) r1r1 gets 1, w0w0 fails 1 20
M3M_3 ⇓(r0,w1)\Downarrow(r0, w1) after cell 3, r0r0 gets 1: FAIL 1 23

The test stops after 23 of its 40 operations and reports element M3M_3, address 2, and the value 1.

Coverage on four cells. The tests of this page inject every fault of each class into a memory of 4 cells and run each test from all 16 initial contents. The table gives the number of faults detected from every initial content.

test operations stuck-at (8) transition (8) inversion (24) idempotent (48) state (48) address decoder (44)
MATS, ⇕(w0);⇕(r0,w1);⇕(r1)\Updownarrow(w0); \Updownarrow(r0, w1); \Updownarrow(r1) 4N4N 8 4 12 12 36 38
MATS+ 5N5N 8 4 18 18 36 44
MATS++, ⇕(w0);⇑(r0,w1);⇓(r1,w0,r0)\Updownarrow(w0); \Uparrow(r0, w1); \Downarrow(r1, w0, r0) 6N6N 8 8 18 18 36 44
March C− 10N10N 8 8 24 48 48 44

The address decoder faults here are an address that reaches no cell (a read returns a fixed 0 or 1), an address that reaches the wrong cell, and an address that reaches two cells (a read returns their AND or their OR). The numbers come from this small model and this small NN. They show which tests miss faults, not the coverage on a real chip.

Correctness

The full proof shows four things. First, a run that does not fail performs exactly N∑kmkN \sum_k m_k operations, where mkm_k is the number of operations of MkM_k, because every element visits each address once. The six elements of March C− have 1, 2, 2, 2, 2 and 1 operations, which gives 10N10N, and MATS+ gives 5N5N. Second, a test passes on a fault-free memory from every initial content exactly when every read follows a write of the value it expects, since the operations that reach one cell are the operations of the test in order. Third, March C− detects every stuck-at cell and every transition fault, by following the faulty cell through the elements as in the example. Fourth, MATS+ misses every transition fault ↓\downarrow.

That March C− detects all inversion, idempotent and state couplings is proved on the memory coupling fault page. The detection of the address decoder faults is shown in van de Goor's book and not proved here. The tests check both claims by exhaustive injection for memories of 2 to 5 cells, which confirms them for those sizes only.

Proof: The operation count of a march test, no false alarms, and the faults of one cell that the 10N march test detectsfull

The memory has NN one-bit cells with addresses 0,…,N−10, \ldots, N - 1. A march test is a list of elements M0,…,Me−1M_0, \ldots, M_{e-1}. Element MkM_k has an address order and a list of mkm_k operations. Lines L1 to L7 of the page apply each element to every address in its order and all its operations to one address before the next. The page writes March C− as

⇕(w0); ⇑(r0,w1); ⇑(r1,w0); ⇓(r0,w1); ⇓(r1,w0); ⇕(r0)\Updownarrow(w0);\ \Uparrow(r0, w1);\ \Uparrow(r1, w0);\ \Downarrow(r0, w1);\ \Downarrow(r1, w0);\ \Updownarrow(r0)

and MATS+ as ⇕(w0); ⇑(r0,w1); ⇓(r1,w0)\Updownarrow(w0);\ \Uparrow(r0, w1);\ \Downarrow(r1, w0). A fault counts as detected when the test fails from every initial content of the memory, since the content at power-up is not known.

Theorem 1 (operation count). A test that does not fail performs exactly N∑kmkN \sum_k m_k operations. March C− performs 10N10N operations and MATS+ performs 5N5N.

Proof. Line L2 visits each of the NN addresses once per element, whatever the order, and line L3 runs the mkm_k operations of MkM_k at each address. Only line L6 leaves early, and only on a failure. So element MkM_k contributes NmkN m_k operations. For March C−, (m0,…,m5)=(1,2,2,2,2,1)(m_0, \ldots, m_5) = (1, 2, 2, 2, 2, 1) and the sum is 10. For MATS+, (1,2,2)(1, 2, 2) sums to 5. □\square

Call a test consistent when, reading its operations in order and ignoring addresses, every read rvrv has a write before it and the last write before it is wvwv.

Theorem 2 (no false alarm). A test passes on a fault-free memory from every initial content if and only if it is consistent.

Proof. In a fault-free memory, a read returns the value of the last write to the same cell, or the initial value if there was none. Fix a cell aa. The operations on aa are those of M0M_0, then those of M1M_1, and so on, in the order of the list, because each element touches aa once and runs all its operations there. So the operations that reach aa are exactly the operation list of the test, in order. If the test is consistent, the last write before each read rvrv on aa is wvwv, and the read returns vv. If a read rvrv has a last write w¬vw\lnot v before it, it fails from every initial content. If a read rvrv has no write before it, it reads the initial value of the cell, and it fails when the memory starts with ¬v\lnot v in that cell. □\square

March C− and MATS+ are consistent: in March C− the reads expect 0, 1, 0, 1 and 0, and each follows a write of that value in the element before.

A cell stuck at vv always holds vv. A cell with a transition fault ↑\uparrow cannot go from 0 to 1, and with ↓\downarrow it cannot go from 1 to 0. In both cases the other cells and the address decoder work.

Theorem 3. March C− detects every stuck-at cell and every transition fault, from every initial content.

Proof. Let ii be the faulty cell. The other cells behave as in a fault-free memory, and reads of address ii return the content of cell ii.

  • Stuck at 1: M1M_1 reads ii expecting 0 and gets 1.
  • Stuck at 0: M1M_1 writes 1 to ii, and the first operation of M2M_2 at ii reads it expecting 1 and gets 0.
  • Transition fault ↑\uparrow: after M0M_0 the cell holds 0, from either initial value, since the write of 0 needs no rising transition. The write of 1 in M1M_1 fails, and the read of M2M_2 gets 0.
  • Transition fault ↓\downarrow: if the cell starts at 1, the write of M0M_0 fails and the read of M1M_1 gets 1. If it starts at 0, M1M_1 writes 1, M2M_2 reads 1 and then writes 0, which fails, and the read of M3M_3 gets 1. □\square

Theorem 4. MATS+ misses every transition fault ↓\downarrow.

Proof. Start from all 0. Then M0M_0 writes 0 with no transition, M1M_1 reads 0 and writes 1, and M2M_2 reads 1 and writes 0. The last write fails on the faulty cell, but no read follows it, so every read returns the expected value. □\square

What is cited and what is checked. That March C− detects every unlinked inversion, idempotent and state coupling is proved on the memory coupling fault page, and this page does not repeat it. That it detects the address decoder faults of van de Goor's model is shown in his book (1991) and is not proved here. The tests of this page check both claims by injecting every fault of each class, from every initial content, into memories of 2 to 5 cells. That is an exhaustive check for those sizes, not a proof for every NN.

Complexity

The run takes O(mN)O(m N) time, where mm is the number of operations per address over all elements, and O(1)O(1) extra space for the loop counters. For a fixed test, mm is a constant, so the time is linear in NN. Any test that detects every stuck-at cell must read and write every cell, so linear time is the best possible order.

The constant matters on real memories. With N=220N = 2^{20} cells and 10 ns per operation, March C− takes about 0.1 s. A test with N2N^2 operations, which is what a test that handles each pair of cells on its own needs, would take about 3 hours.

Properties

  • Linear time. Every march test of ee elements with mm operations in total runs in mNmN operations.
  • Deterministic and data-independent. The sequence of addresses and values is fixed, so a simple address counter and a few data bits generate it in hardware.
  • No false alarms. A test in which every read follows a write of the expected value passes on every fault-free memory. All standard tests have this form.
  • Order matters. The element orders ⇑\Uparrow and ⇓\Downarrow decide which couplings meet a victim at the right value. MATS+ detects every stuck-at cell and every address decoder fault in the model of this page, but misses some couplings and every transition fault ↓\downarrow.
  • Unlinked faults only. The coverage results assume one fault at a time. Two couplings on the same victim can mask each other.

Variants and improvements

  • MATS (Nair, Thatte and Abraham, 1978) has 4N4N operations and detects every stuck-at cell.
  • MATS+ adds order to MATS, and MATS++ adds a final read to the last element, which catches the transition faults ↓\downarrow that MATS+ misses.
  • March C (Marinescu, 1982) has 11N11N operations with an extra ⇕(r0)\Updownarrow(r0) element in the middle. Van de Goor showed that this element is redundant for the target faults, which gives March C−.
  • Longer tests such as March A and March B, from the work of Suk and Reddy, target linked couplings. Many later tests target faults found in real SRAMs, such as read disturb and faults that depend on the timing of the operations.
  • Word-oriented memories. A memory with BB-bit words runs each march test with several data backgrounds, so that the bits inside one word also couple in both directions.
  • Built-in self-test. On-chip memory BIST runs a march test with an address counter that counts both ways and a comparator. Some controllers can be programmed with the elements.

When to use it

Use a march test for every embedded or stand-alone RAM in production test and in memory BIST. March C− is a common default for bit-oriented SRAM. Pick a longer test when the fault list of the memory technology needs it, and add a retention test with a pause when the cells can leak. For the random logic around the memory, use logic test methods such as scan design instead.

Pitfalls

  • Assuming the initial content. A cell can hold anything at power-up. The first element must write every cell before any read.
  • Ignoring the order of ⇕\Updownarrow. An element marked ⇕\Updownarrow may run in either order only if the coverage proof does not depend on it. Running a ⇑\Uparrow element downward breaks the coupling coverage.
  • Logical and physical addresses. Coupling between neighbours depends on the physical layout. Address scrambling in the decoder can put logically far cells side by side, which matters for tests that target neighbourhoods.
  • One fault at a time. A memory with several faults can pass a test that detects each fault alone.
  • Stopping at the first failure. For repair with spare rows and columns, the tester must log every failing address, not only the first.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

march_elements.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/march-test/. The authors are listed in prov/G5W6E7.jsonl.
"""March tests for bit-oriented random access memories.

A march test is a list of march elements. Each element has an address order
(up, down or any) and a short list of operations, each a write w0 or w1 or a
read r0 or r1 that expects the given value. The element applies all its
operations to one address before it moves to the next. A test with operations
per address m_1, ..., m_e on N cells performs N (m_1 + ... + m_e) operations
and runs in that much time with O(1) extra space.

The memory is any object with read(address) and write(address, value).
"""

from __future__ import annotations

import re
from typing import Optional, Protocol, Sequence

UP, DOWN, ANY = "up", "down", "any"
Op = tuple[str, int]
Element = tuple[str, tuple[Op, ...]]
Failure = tuple[int, int, int, int]


class Memory(Protocol):
    def read(self, address: int) -> int: ...

    def write(self, address: int, value: int) -> None: ...


def parse(text: str) -> list[Element]:
    """Parse a test such as "any(w0); up(r0,w1); down(r1,w0)"."""
    test: list[Element] = []
    for part in text.split(";"):
        m = re.fullmatch(r"\s*(up|down|any)\s*\(([^)]*)\)\s*", part)
        if not m:
            raise ValueError(f"bad march element {part!r}")
        ops = []
        for tok in m.group(2).split(","):
            tok = tok.strip()
            if not re.fullmatch(r"[rw][01]", tok):
                raise ValueError(f"bad operation {tok!r}")
            ops.append((tok[0], int(tok[1])))
        test.append((m.group(1), tuple(ops)))
    return test


def show(test: Sequence[Element]) -> str:
    return "; ".join(f"{order}({','.join(f'{k}{v}' for k, v in ops)})" for order, ops in test)


MATS = parse("any(w0); any(r0,w1); any(r1)")
MATS_PLUS = parse("any(w0); up(r0,w1); down(r1,w0)")
MATS_PLUS_PLUS = parse("any(w0); up(r0,w1); down(r1,w0,r0)")
MARCH_C_MINUS = parse("any(w0); up(r0,w1); up(r1,w0); down(r0,w1); down(r1,w0); any(r0)")


def operation_count(test: Sequence[Element], n: int) -> int:
    """The number of read and write operations of the test on n cells."""
    return n * sum(len(ops) for _, ops in test)


def addresses(order: str, n: int) -> range:
    """The address order of an element. "any" is run upward here."""
    return range(n - 1, -1, -1) if order == DOWN else range(n)


def consistent(test: Sequence[Element]) -> bool:
    """True if every read expects the value a fault-free memory holds at that point.

    All cells get the same operations in each element, so one value per element
    boundary describes the whole memory. A read before any write is not allowed.
    """
    value: Optional[int] = None
    for _, ops in test:
        for kind, v in ops:
            if kind == "w":
                value = v
            elif value != v:
                return False
    return True


def run_march(memory: Memory, test: Sequence[Element], n: int) -> Optional[Failure]:
    """Apply the test to a memory of n cells.

    Returns None if every read gave the expected value, else the first failure as
    (element index, address, operation index, value read).
    """
    for e, (order, ops) in enumerate(test):  # @line L1
        for a in addresses(order, n):  # @line L2
            for t, (kind, v) in enumerate(ops):  # @line L3
                if kind == "w":  # @line L4
                    memory.write(a, v)
                else:
                    got = memory.read(a)  # @line L5
                    if got != v:
                        return (e, a, t, got)  # @line L6
    return None  # @line L7


class GoodMemory:
    """A fault-free memory of n one-bit cells."""

    def __init__(self, n: int, init: Sequence[int] | None = None) -> None:
        self.cells = list(init) if init is not None else [0] * n

    def read(self, address: int) -> int:
        return self.cells[address]

    def write(self, address: int, value: int) -> None:
        self.cells[address] = value
ram_faults.py 104 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/march-test/. The authors are listed in prov/G5W6E7.jsonl.
"""A small memory with one injected functional fault, for checking march tests.

The faults follow van de Goor's functional model (see the memory coupling
fault page). A fault is a tuple:

- ("SAF", i, v): cell i is stuck at v.
- ("TF", i, t): cell i cannot make the transition t ("up" is 0 to 1, "down" is 1 to 0).
- ("CFin", i, j, t): a transition t of the aggressor i inverts the victim j.
- ("CFid", i, j, t, v): a transition t of i sets j to v.
- ("CFst", i, j, x, v): while i holds x, j holds v.
- ("AFnone", a, v): address a reaches no cell, and a read of it returns v.
  Cell a is never accessed.
- ("AFother", a, b): address a reaches cell b instead of cell a.
- ("AFmulti", a, b, w): address a reaches cells a and b. A write goes to both,
  and a read returns their AND (w = 0) or their OR (w = 1).
"""

from __future__ import annotations

from itertools import product
from typing import Sequence

Fault = tuple


class FaultyMemory:
    """A memory of n one-bit cells with one fault."""

    def __init__(self, n: int, fault: Fault, init: Sequence[int]) -> None:
        self.n = n
        self.fault = fault
        self.cells = list(init)
        f = fault
        if f[0] == "SAF":
            self.cells[f[1]] = f[2]
        self._state_coupling()

    def _targets(self, a: int) -> list[int]:
        f = self.fault
        if f[0] == "AFnone" and a == f[1]:
            return []
        if f[0] == "AFother" and a == f[1]:
            return [f[2]]
        if f[0] == "AFmulti" and a == f[1]:
            return [a, f[2]]
        return [a]

    def _state_coupling(self) -> None:
        f = self.fault
        if f[0] == "CFst" and self.cells[f[1]] == f[3]:
            self.cells[f[2]] = f[4]

    def _write_cell(self, c: int, v: int) -> None:
        f = self.fault
        old = self.cells[c]
        new = v
        if f[0] == "SAF" and c == f[1]:
            new = f[2]
        if f[0] == "TF" and c == f[1] and old != new:
            if (f[2] == "up") == (new == 1):
                new = old
        self.cells[c] = new
        if old != new and f[0] in ("CFin", "CFid") and c == f[1]:
            t = "up" if new == 1 else "down"
            if t == f[3]:
                j = f[2]
                self.cells[j] = 1 - self.cells[j] if f[0] == "CFin" else f[4]
        self._state_coupling()

    def write(self, address: int, value: int) -> None:
        for c in self._targets(address):
            self._write_cell(c, value)

    def read(self, address: int) -> int:
        f = self.fault
        cells = self._targets(address)
        if not cells:
            return f[2]
        if len(cells) == 1:
            return self.cells[cells[0]]
        vals = [self.cells[c] for c in cells]
        return max(vals) if f[3] == 1 else min(vals)


def all_faults(n: int) -> dict[str, list[Fault]]:
    """Every fault of each class in a memory of n cells."""
    cells = range(n)
    pairs = [(i, j) for i in cells for j in cells if i != j]
    return {
        "SAF": [("SAF", i, v) for i in cells for v in (0, 1)],
        "TF": [("TF", i, t) for i in cells for t in ("up", "down")],
        "CFin": [("CFin", i, j, t) for i, j in pairs for t in ("up", "down")],
        "CFid": [("CFid", i, j, t, v) for i, j in pairs for t in ("up", "down") for v in (0, 1)],
        "CFst": [("CFst", i, j, x, v) for i, j in pairs for x in (0, 1) for v in (0, 1)],
        "AF": [("AFnone", a, v) for a in cells for v in (0, 1)]
        + [("AFother", a, b) for a, b in pairs]
        + [("AFmulti", a, b, w) for a, b in pairs for w in (0, 1)],
    }


def initial_states(n: int) -> list[tuple[int, ...]]:
    return list(product((0, 1), repeat=n))
march_test.py 41 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/march-test/. The authors are listed in prov/G5W6E7.jsonl.
"""The public module of the march-test page.

The code, with its @line markers, is in march_elements.py. The tools read a
file whose name ends in _test.py as a test file, so the markers cannot be here.
"""

from march_elements import (
    ANY,
    DOWN,
    MARCH_C_MINUS,
    MATS,
    MATS_PLUS,
    MATS_PLUS_PLUS,
    UP,
    GoodMemory,
    addresses,
    consistent,
    operation_count,
    parse,
    run_march,
    show,
)

__all__ = [
    "ANY",
    "DOWN",
    "MARCH_C_MINUS",
    "MATS",
    "MATS_PLUS",
    "MATS_PLUS_PLUS",
    "UP",
    "GoodMemory",
    "addresses",
    "consistent",
    "operation_count",
    "parse",
    "run_march",
    "show",
]
test_march_test.py 163 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/march-test/. The authors are listed in prov/G5W6E7.jsonl.
"""March tests against exhaustive fault injection in a small memory."""

from __future__ import annotations

import random

import pytest

from march_test import (
    ANY,
    DOWN,
    MARCH_C_MINUS,
    MATS,
    MATS_PLUS,
    MATS_PLUS_PLUS,
    UP,
    GoodMemory,
    addresses,
    consistent,
    operation_count,
    parse,
    run_march,
    show,
)
from ram_faults import FaultyMemory, all_faults, initial_states


def detected(test, fault, n) -> bool:
    """A fault counts as detected when the test fails from every initial content."""
    return all(run_march(FaultyMemory(n, fault, s), test, n) is not None for s in initial_states(n))


class CountingMemory(GoodMemory):
    def __init__(self, n):
        super().__init__(n)
        self.ops = 0

    def read(self, address):
        self.ops += 1
        return super().read(address)

    def write(self, address, value):
        self.ops += 1
        super().write(address, value)


def read_trace(memory, test, n):
    """Reference run: every value read, without stopping at a mismatch."""
    out = []
    for order, ops in test:
        for a in addresses(order, n):
            for kind, v in ops:
                if kind == "w":
                    memory.write(a, v)
                else:
                    out.append(memory.read(a))
    return out


def expected_trace(test, n):
    out = []
    for _, ops in test:
        for _ in range(n):
            for kind, v in ops:
                if kind == "r":
                    out.append(v)
    return out


def random_test(rng):
    test = [(ANY, (("w", rng.randint(0, 1)),))]
    for _ in range(rng.randint(1, 4)):
        ops = tuple((rng.choice("rw"), rng.randint(0, 1)) for _ in range(rng.randint(1, 3)))
        test.append((rng.choice([UP, DOWN, ANY]), ops))
    return test


def test_parse_and_show():
    assert show(MARCH_C_MINUS) == "any(w0); up(r0,w1); up(r1,w0); down(r0,w1); down(r1,w0); any(r0)"
    assert parse(show(MATS_PLUS)) == MATS_PLUS
    with pytest.raises(ValueError):
        parse("up(r2)")


@pytest.mark.parametrize("n", range(1, 9))
def test_operation_counts(n):
    assert operation_count(MARCH_C_MINUS, n) == 10 * n
    assert operation_count(MATS_PLUS, n) == 5 * n
    assert operation_count(MATS_PLUS_PLUS, n) == 6 * n
    for test in (MATS, MATS_PLUS, MATS_PLUS_PLUS, MARCH_C_MINUS):
        m = CountingMemory(n)
        assert run_march(m, test, n) is None
        assert m.ops == operation_count(test, n)


def test_standard_tests_are_consistent():
    for test in (MATS, MATS_PLUS, MATS_PLUS_PLUS, MARCH_C_MINUS):
        assert consistent(test)


@pytest.mark.parametrize("seed", range(40))
def test_consistent_iff_good_memory_always_passes(seed):
    rng = random.Random(seed)
    test = random_test(rng)
    if rng.random() < 0.3:
        test = test[1:]  # may read before any write
    n = 3
    passes = all(run_march(GoodMemory(n, s), test, n) is None for s in initial_states(n))
    assert passes == consistent(test)


@pytest.mark.parametrize("seed", range(25))
def test_runner_matches_reference_trace(seed):
    rng = random.Random(100 + seed)
    test = random_test(rng)
    n = 3
    expect = expected_trace(test, n)
    for faults in all_faults(n).values():
        for f in faults:
            for s in initial_states(n):
                fails = run_march(FaultyMemory(n, f, s), test, n) is not None
                assert fails == (read_trace(FaultyMemory(n, f, s), test, n) != expect)


@pytest.mark.parametrize("n", [2, 3, 4, 5])
def test_march_c_minus_detects_every_fault(n):
    for cls, faults in all_faults(n).items():
        for f in faults:
            assert detected(MARCH_C_MINUS, f, n), (cls, f)


def coverage(test, n):
    return {cls: sum(detected(test, f, n) for f in faults) for cls, faults in all_faults(n).items()}


def test_coverage_table_n4():
    assert coverage(MATS, 4) == {"SAF": 8, "TF": 4, "CFin": 12, "CFid": 12, "CFst": 36, "AF": 38}
    assert coverage(MATS_PLUS, 4) == {"SAF": 8, "TF": 4, "CFin": 18, "CFid": 18, "CFst": 36, "AF": 44}
    assert coverage(MATS_PLUS_PLUS, 4) == {"SAF": 8, "TF": 8, "CFin": 18, "CFid": 18, "CFst": 36, "AF": 44}
    assert coverage(MARCH_C_MINUS, 4) == {"SAF": 8, "TF": 8, "CFin": 24, "CFid": 48, "CFst": 48, "AF": 44}


def test_mats_plus_misses():
    n = 4
    missed_tf = [f for f in all_faults(n)["TF"] if not detected(MATS_PLUS, f, n)]
    assert missed_tf == [("TF", i, "down") for i in range(n)]
    # the coupling of the memory coupling fault page: a rise of i > j sets j to 1
    assert not detected(MATS_PLUS, ("CFid", 1, 0, "up", 1), n)
    assert detected(MATS_PLUS, ("CFid", 0, 1, "up", 1), n)


def test_good_memory_never_fails():
    for n in range(1, 6):
        for s in initial_states(n):
            assert run_march(GoodMemory(n, s), MARCH_C_MINUS, n) is None


def test_failure_report():
    n = 4
    got = run_march(FaultyMemory(n, ("SAF", 2, 1), (0,) * n), MARCH_C_MINUS, n)
    assert got == (1, 2, 0, 1)  # element 1, address 2, its r0 read 1

History

Early RAM tests such as walking and galloping patterns took time quadratic in the number of cells. In 1978 Nair, Thatte and Abraham gave a functional fault model and the linear test MATS. Suk and Reddy published a march test of linear length for coupling faults in 1981, and Marinescu introduced the march notation and March C in 1982. Abadir and Reghbati surveyed the field in 1983. Van de Goor collected the fault models in his 1991 book and, in 1993, showed which classes each march test detects, including the 10N test March C−. March tests then became the standard algorithms of memory BIST controllers.

References

  1. R. Nair, S. M. Thatte and J. A. Abraham, Efficient algorithms for testing semiconductor random-access memories, IEEE Transactions on Computers C-27(6), 572 to 576, 1978, the functional fault model and the linear test MATS
  2. D. S. Suk and S. M. Reddy, A march test for functional faults in semiconductor random access memories, IEEE Transactions on Computers C-30(12), 982 to 985, December 1981, the march test of linear length for faults in which a write to one cell changes another
  3. M. Marinescu, Simple and efficient algorithms for functional RAM testing, Proc. International Test Conference 1982, 236 to 239, the march notation and the 11N test March C
  4. M. S. Abadir and H. K. Reghbati, Functional testing of semiconductor random access memories, ACM Computing Surveys 15(3), 175 to 198, 1983, the survey of RAM fault models and tests, including MATS+
  5. A. J. van de Goor, Using march tests to test SRAMs, IEEE Design and Test of Computers 10(1), 8 to 14, 1993, the families of march tests, the reduced March C with 10N operations, and the fault classes each test detects
  6. A. J. van de Goor, Testing Semiconductor Memories, Theory and Practice, Wiley, 1991, the chapters on functional fault models, address decoder faults and march tests

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example