Data structurecore
Multiple-input signature register
Also called MISR, signature register.
An LFSR that XORs several circuit outputs into its stages every clock, compressing a long response stream into one signature compared at the end of BIST.
- Time
- O(m (k / w + 1)) worst · average · best
- Space
- O(k / w + 1) extra
- Where
- k = the number of stages; m = the number of input words; w = the word size in bits
- Model
- Word RAM
- Properties
- deterministiciterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- B. Könemann, J. Mucha, G. Zwiehoff, 1979
A multiple-input signature register, or MISR, is a linear feedback shift register with stages and one extra XOR at the input of every stage, so that it takes a -bit word from the circuit under test at each clock. Read as a polynomial over GF(2), one clock computes for a feedback polynomial of degree , so after a whole test the register holds the remainder of one long polynomial, built from all input streams, divided by . It is the usual response compactor of built-in self-test and of scan compression. This page is about the register as a data structure: its state, its operations, why the signature is a remainder, and which errors it can and cannot lose. How often a random error is lost is on the page signature aliasing probability.
In plain words
A test produces millions of output bits. Storing all of them and the right answers is costly. A signature register keeps only a short summary.
It is a row of a few flip-flops. At every clock, each flip-flop takes the bit from its neighbor, mixes in one output bit of the circuit, and, when the last flip-flop holds a 1, also mixes in a fixed feedback pattern. After the test, the row holds a short code, the signature, and the chip compares it with the code of a good chip.
The code works like the remainder of a long division. A single wrong bit always changes it. But some patterns of several wrong bits leave it unchanged, and then a bad chip passes.
The abstract type
The type has two fixed parameters and one value.
- The number of stages , and the feedback polynomial over GF(2), of degree exactly .
- The value is a register of bits, read as the polynomial of degree less than . An input word is read the same way.
The operations are:
RESET(s): set to the seed , usually 0.CLOCK(w): one clock with the input word .SIGNATURE(): return .
The specification is the formula of the signature. After RESET(s) and the clocks CLOCK(w_0), ..., CLOCK(w_{m-1}),
There is a second way to read the same sum. Write the stream of input as the polynomial , where is bit of word , so the first bit has the highest power, as in long division. Then . A MISR is a single-input signature register fed with the XOR of the input streams, stream shifted up by places. This one line explains both the strength and the weakness of the register, below.
Representation
The register is one -bit word, with bit for stage , and the low part of the polynomial is a second -bit constant. This is the internal-XOR form, also called the Galois form, of an LFSR: stage 0 takes , and stage takes . In hardware it is flip-flops, one XOR per input, and one XOR per nonzero coefficient with . All stages change on the same clock, so the register takes one word per clock at the full clock rate.
Operations
CLOCK(r, w)- 1
msb ← bit k − 1 of r - 2
r ← r shifted one place toward stage k − 1, bit k − 1 dropped and stage 0 set to 0 - 3
if msb = 1 then r ← r XOR (q − x^k) - 4
r ← r XOR w
RESET(s) stores in and SIGNATURE() returns , each in one word operation.
Lines L1 to L3 compute . The shift multiplies by . If the top stage was 0, then has degree less than and is already reduced. If it was 1, then , and , since over GF(2) minus is plus, so line L3 adds the low part of . Line L4 adds the input word. So one clock is
This is one step of long division of a polynomial by , in the same way as the single-input register on the built-in self-test page and the cyclic redundancy check, except that new bits enter at once.
Example
Take and , so , the word 011. Start from and clock five words. Words and registers are written , high stage first.
| clock | before | msb | after L2 | after L3 | after L4 | |
|---|---|---|---|---|---|---|
| 0 | 000 | 0 | 000 | 000 | 101 | 101 |
| 1 | 101 | 1 | 010 | 001 | 011 | 010 |
| 2 | 010 | 0 | 100 | 100 | 110 | 010 |
| 3 | 010 | 0 | 100 | 100 | 001 | 101 |
| 4 | 101 | 1 | 010 | 001 | 100 | 101 |
The signature is 101, the polynomial . The formula gives the same value. The words are , , , and , so
Modulo , , and , and the sum reduces to .
Now put errors on the stream. An error on input 0 at clock 3, so that , adds to the polynomial, and the signature becomes . The error is caught. Two errors, one on input 0 at clock 1 and one on input 1 at clock 2, add and , the same monomial twice. They cancel, and the signature stays 101, although two bits of the stream are wrong. The second error reaches stage 1 at the clock when the first error, shifted up from stage 0, is also there.
Correctness
Facts 1 and 2 hold for every of degree , and fact 3 needs . They are proved on the proof page.
- The signature is a remainder. After clocks from the seed , the register holds . The proof is by induction on the clocks, with the step .
- Linearity, and the error polynomial. If the good circuit gives the words and a faulty one gives , then the two signatures differ by , where . The faulty chip passes exactly when divides . The seed drops out.
- A single wrong bit never aliases. A single wrong bit gives . Since , is not a power of , and the only irreducible factor of is , so does not divide .
Fact 2 also says which pairs of errors alias. The error bit , at clock on input , gives the monomial , so the two error bits and give the same monomial and always cancel, whatever is. Two error bits with different exponents alias exactly when divides , that is when divides . For a primitive this happens exactly when divides , since is then the least for which divides .
Proof: The MISR signature is a remainder, and a single wrong bit always changes itfull
We use the notation of the page. The ring is GF(2)[x], so plus and minus are the same. The register and the input words are polynomials of degree less than , and has degree exactly . For a polynomial , is the unique polynomial of degree less than with .
Lemma 1 (one clock). For a register and a word , lines L1 to L4 of CLOCK leave .
Proof. Write with . Line L1 reads . Line L2 forms , which has degree less than . If , then and line L3 does nothing. If , then , and line L3 forms . In both cases the result after line L3 has degree less than and differs from by a multiple of , so it is . Line L4 adds , which has degree less than , so the sum still has degree less than and differs from by a multiple of . So it is .
Theorem 1 (the signature). After RESET(s) and the clocks with , the register holds
Proof. By induction on . For , RESET(s) stores , and has degree less than , so . Assume the claim for . By Lemma 1 the next clock gives
since differs from times the polynomial in the claim for by a multiple of . The sum is , which is the claim for .
Corollary 1 (the stream view). Write for the coefficient of in and . Then , so the signature is .
Theorem 2 (errors). Let the good words be and the faulty words , with the same seed . The two signatures differ by , where
So the faulty signature equals the good one exactly when divides .
Proof. The map is linear over GF(2): if and then . By Theorem 1 the faulty signature is , which is the good signature plus . The two are equal exactly when , that is when .
Theorem 3 (single wrong bits). If , then a stream with exactly one wrong bit never gives the good signature.
Proof. One wrong bit, at clock on input , gives with . Suppose , so for some . Put . If the left side is 0 and the right side is , so and , and we may divide both sides by and repeat with . After steps we reach , which is impossible since . So , and by Theorem 2 the signatures differ.
Theorem 4 (pairs of wrong bits). Two wrong bits and give the exponents and .
- If , the pair always aliases. This happens in particular for and .
- If and , the pair aliases exactly when .
Proof. If , then , and divides 0. For the exponent is . If , then . As in Theorem 3, means that and have no common factor other than 1, since every common factor divides and so is a power of , and . So exactly when .
For a primitive of degree , the least with is , and exactly when divides . So with a primitive , two wrong bits with different exponents alias exactly when their exponents differ by a multiple of .
Complexity
For , the word size, each operation is word operations, so a stream of words costs time. For larger , a clock touches words. The extra space is the register itself. In hardware, one clock is one word, so the register keeps up with the circuit at full speed, and the area is flip-flops and XOR gates. The signature is bits however long the test is.
Variants
- Single-input register. With circuit outputs and a one-bit input, first XOR the outputs into one bit, then divide. A MISR saves this XOR tree and keeps more information, since the outputs enter at different stages.
- External-XOR form. The feedback can also be taken as one XOR of tapped stages into stage 0, the Fibonacci form of the LFSR, with the input words still XORed into every stage. The map from streams to signatures is again linear and onto, so the count of aliasing streams is the same, but the set of aliasing streams is a different one, and the signature is not the plain remainder of fact 1.
- Space compactor first. With hundreds of scan chains and a 32-bit or 64-bit MISR, an XOR network first reduces the chain outputs to the width of the register. The X-compact network is one with proved properties when some outputs are unknown.
- Masking. A mask register forces chosen chain outputs to 0 on chosen clocks, so that unknown values do not enter the register.
- Several signatures. Reading the signature after every pattern or every block, instead of once at the end, shortens the stream that one aliasing event can hide and gives data for diagnosis.
- BILBO. The register of Könemann, Mucha and Zwiehoff works as a normal register, a scan register, a pattern generator with the inputs held at 0, or a MISR.
When to use it
Use a MISR whenever a long response must be checked on the chip or carried out through few pins: the output side of built-in self-test, the output side of scan compression such as embedded deterministic test, and checks of memory contents. The pattern side of these schemes uses the same register with the inputs off, as in LFSR reseeding. Do not use it when every response bit is needed, for example for diagnosis with a fault dictionary, unless the signature is read often or the test is run again with the register bypassed.
Pitfalls
- Unknown values. One unknown bit on an input makes every later state of the register unknown, since the next state depends on it linearly and nothing removes it. Block or mask every source of before the register.
- Errors in neighbor stages. Fact 2 shows that an error on input at clock and one on input at clock cancel. A fault that drives two neighbor scan chains in this pattern aliases for every polynomial. Do not connect outputs that share logic to neighbor stages, or use a space compactor that mixes them first.
- A polynomial without the term 1. If , then divides , the step is not one to one, and the register forgets part of its past. For it is a plain shift register, and an error on input 2 at clock 0 is gone after one more clock. For , two wrong bits on input 2 at any two neighbor clocks give with , a multiple of , and alias.
- The good signature depends on everything. The seed, the number of clocks, the order of the inputs and every bit of the good response enter the signature. A change in any of them needs a new good signature from simulation.
- One signature hides where the error was. Pass or fail is all that a final signature tells. Diagnosis needs the failing clocks, which means reading the register more often or running the test again in a mode that bypasses it.
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.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/multiple-input-signature-register/. The authors are listed in prov/CM81DK.jsonl.
"""A multiple-input signature register (MISR) with internal XOR feedback.
The register has k stages r_0, ..., r_(k-1). Read as a polynomial over GF(2),
r(x) = r_0 + r_1 x + ... + r_(k-1) x^(k-1). The feedback polynomial is
q(x) = x^k + q_(k-1) x^(k-1) + ... + q_0, stored as an int with bit i equal to
the coefficient of x^i (so bit k is set). One clock with the input word
w = (w_0, ..., w_(k-1)) does
r <- (x * r(x) + w(x)) mod q(x),
which in hardware is a shift toward the high stage, an XOR of the low k bits
of q into the stages when the top stage was 1, and an XOR of the input word.
After m clocks from the seed s, the register holds
(x^m s(x) + sum_t x^(m-1-t) w_t(x)) mod q(x).
Each clock costs O(1) operations on k-bit words (O(k) bit operations).
"""
from __future__ import annotations
from typing import Iterable
class MISR:
"""A k-bit MISR with feedback polynomial q of degree k."""
def __init__(self, k: int, q: int, seed: int = 0) -> None:
"""Precondition: k >= 1, q has degree exactly k, and 0 <= seed < 2^k."""
if k < 1 or q >> k != 1:
raise ValueError("q must have degree exactly k")
self.k = k
self.q = q
self.mask = (1 << k) - 1
self.low = q & self.mask # q(x) - x^k
self.r = 0
self.reset(seed)
def reset(self, seed: int = 0) -> None:
"""Load a seed into the stages. O(1)."""
if not 0 <= seed <= self.mask:
raise ValueError("the seed must have k bits")
self.r = seed
def clock(self, w: int) -> None:
"""One clock with the k-bit input word w (bit i enters stage i). O(1) word operations."""
if not 0 <= w <= self.mask:
raise ValueError("the input word must have k bits")
msb = (self.r >> (self.k - 1)) & 1 # @line L1
self.r = (self.r << 1) & self.mask # @line L2
if msb:
self.r ^= self.low # @line L3
self.r ^= w # @line L4
def compact(self, words: Iterable[int]) -> int:
"""Clock every word of a response stream and return the signature. O(m) for m words."""
for w in words:
self.clock(w)
return self.r
def signature(self) -> int:
"""The current contents of the register."""
return self.r
def check_invariant(self) -> bool:
return 0 <= self.r <= self.mask and self.q >> self.k == 1
def signature_of(k: int, q: int, words: Iterable[int], seed: int = 0) -> int:
"""The signature of a whole stream from a seed."""
return MISR(k, q, seed).compact(words)
test_multiple_input_signature_register.py 170 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/multiple-input-signature-register/. The authors are listed in prov/CM81DK.jsonl.
import random
from itertools import product
import pytest
from multiple_input_signature_register import MISR, signature_of
Q3 = 0b1011 # x^3 + x + 1, primitive
Q4 = 0b10011 # x^4 + x + 1, primitive
Q8 = 0x11D # x^8 + x^4 + x^3 + x^2 + 1, primitive
def polymod(a: int, q: int) -> int:
"""Reference: remainder of a(x) by q(x) over GF(2), by long division from the top bit."""
dq = q.bit_length() - 1
while a and a.bit_length() - 1 >= dq:
a ^= q << (a.bit_length() - 1 - dq)
return a
def folded(words, seed: int) -> int:
"""The polynomial x^m s(x) + sum_t x^(m-1-t) w_t(x) of a stream of m words."""
m = len(words)
d = seed << m
for t, w in enumerate(words):
d ^= w << (m - 1 - t)
return d
def test_page_example():
# The example of the page: k = 3, q = x^3 + x + 1, five words, seed 0.
words = [0b101, 0b011, 0b110, 0b001, 0b100]
m = MISR(3, Q3)
states = []
for w in words:
m.clock(w)
states.append(m.signature())
assert m.check_invariant()
assert states == [0b101, 0b010, 0b010, 0b101, 0b101]
assert m.signature() == polymod(folded(words, 0), Q3)
def test_one_stage_is_parity():
# k = 1, q = x + 1: the register is the parity of all input bits.
rng = random.Random(1)
for _ in range(200):
words = [rng.randint(0, 1) for _ in range(rng.randint(0, 20))]
assert signature_of(1, 0b11, words) == sum(words) % 2
def test_empty_stream_keeps_seed():
assert signature_of(4, Q4, [], seed=0b1010) == 0b1010
def test_bad_arguments():
with pytest.raises(ValueError):
MISR(3, 0b111) # degree 2, not 3
with pytest.raises(ValueError):
MISR(3, Q3).clock(8)
with pytest.raises(ValueError):
MISR(3, Q3, seed=9)
@pytest.mark.parametrize("k", [1, 2, 3, 4, 5, 8, 16])
def test_signature_is_remainder(k):
rng = random.Random(100 + k)
for _ in range(300):
q = (1 << k) | rng.randrange(1 << k) # any polynomial of degree k, primitive or not
seed = rng.randrange(1 << k)
words = [rng.randrange(1 << k) for _ in range(rng.randint(0, 40))]
assert signature_of(k, q, words, seed) == polymod(folded(words, seed), q)
def test_linearity():
rng = random.Random(7)
for _ in range(500):
k = rng.randint(1, 8)
q = (1 << k) | rng.randrange(1 << k)
n = rng.randint(1, 20)
good = [rng.randrange(1 << k) for _ in range(n)]
err = [rng.randrange(1 << k) for _ in range(n)]
seed = rng.randrange(1 << k)
bad = [g ^ e for g, e in zip(good, err)]
assert signature_of(k, q, bad, seed) == signature_of(k, q, good, seed) ^ signature_of(k, q, err)
@pytest.mark.parametrize("k,q,m", [(2, 0b111, 3), (3, Q3, 3), (3, 0b1001, 3), (2, 0b100, 4), (4, Q4, 2)])
def test_exhaustive_alias_count(k, q, m):
# Every nonzero error stream of m words: exactly 2^(mk - k) - 1 of them alias, for every q of degree k.
count = 0
for err in product(range(1 << k), repeat=m):
if any(err) and signature_of(k, q, list(err)) == 0:
count += 1
assert count == 2 ** (m * k - k) - 1
def test_single_bit_errors_never_alias():
rng = random.Random(3)
for _ in range(200):
k = rng.randint(1, 8)
q = (1 << k) | rng.randrange(1 << k)
if q == 1 << k:
continue
m = rng.randint(1, 12)
for t in range(m):
for i in range(k):
err = [0] * m
err[t] = 1 << i
assert signature_of(k, q, err) != 0
def test_monomial_feedback_aliases_single_bits():
# q = x^k is a plain shift register: a bit that leaves the top stage is lost.
err = [0b100, 0, 0]
assert signature_of(3, 0b1000, err) == 0
def test_cancelling_pair_always_aliases():
# An error in stage i at clock t and in stage i + 1 at clock t + 1 cancels, for every q.
rng = random.Random(11)
for _ in range(300):
k = rng.randint(2, 10)
q = (1 << k) | rng.randrange(1 << k)
m = rng.randint(2, 15)
t = rng.randrange(m - 1)
i = rng.randrange(k - 1)
err = [0] * m
err[t] ^= 1 << i
err[t + 1] ^= 1 << (i + 1)
assert signature_of(k, q, err) == 0
def test_alias_rate_random_streams():
# Equally likely nonzero error streams: the measured rate is close to (2^(mk-k) - 1)/(2^(mk) - 1), about 2^-k.
rng = random.Random(2024)
k, m, n = 8, 16, 40000
hits = 0
for _ in range(n):
err = [rng.randrange(1 << k) for _ in range(m)]
if not any(err):
continue
if signature_of(k, Q8, err) == 0:
hits += 1
p = 2.0 ** -k
sigma = (p * (1 - p) / n) ** 0.5
assert abs(hits / n - p) < 5 * sigma
def test_against_model_random_operations():
# Long random sequences of reset and clock, against a model that keeps the folded polynomial.
rng = random.Random(99)
for _ in range(100):
k = rng.randint(1, 12)
q = (1 << k) | rng.randrange(1 << k)
m = MISR(k, q)
words, seed = [], 0
for _ in range(60):
if rng.random() < 0.1:
seed = rng.randrange(1 << k)
m.reset(seed)
words = []
else:
w = rng.randrange(1 << k)
m.clock(w)
words.append(w)
assert m.check_invariant()
assert m.signature() == polymod(folded(words, seed), q)
History
The BILBO register of Könemann, Mucha and Zwiehoff (1979) put a signature mode with one input per stage into the registers of the circuit itself, and this is the multiple-input signature register of logic BIST. The description as polynomial division over GF(2), and the count of aliasing error streams under the model in which all of them are equally likely, are in Smith (1980) and in the book of Bardell, McAnney and Savir (1987).
References
- B. Könemann, J. Mucha and G. Zwiehoff, Built-in logic block observation techniques, Digest of Papers, 1979 Test Conference, 37 to 41, 1979, the BILBO register and its signature mode with one input per stage
- Paul H. Bardell, William H. McAnney and Jacob Savir, Built-In Test for VLSI, Pseudorandom Techniques, Wiley-Interscience, 1987, the chapters Test Response Compression Techniques and Shift-Register Polynomial Division (the multiple-input register as polynomial division)
- Miron Abramovici, Melvin A. Breuer and Arthur D. Friedman, Digital Systems Testing and Testable Design, IEEE Press, 1994, the chapter Compression Techniques (signature analysis and parallel signature analysis)
- J. E. Smith, Measures of the effectiveness of fault signature analysis, IEEE Transactions on Computers C-29(6), 510 to 514, 1980, the count of aliasing error streams when all of them are equally likely
Where this leads
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag CM81DK Edit this page History Report an error Markdown