DexterLab

🚨 New downloadable modules coming soon📘 Electrical Signaling & PHY Interfaces — new overview📘 Electrical I/O Standards — new overview📘 Integration between Theory and Design Library in progress

CRC – Mathematical Background

Introduction

Cyclic Redundancy Checks (CRCs) are based on polynomial arithmetic over the Galois Field GF(2). Although hardware implementations use shift registers and XOR gates, the underlying theory is purely algebraic. Understanding this mathematical foundation explains why different CRC variants exist, why reflection changes behavior, and how parallel CRC equations are derived.

Polynomials over GF(2)

A binary message is interpreted as a polynomial whose coefficients are 0 or 1.
For example, the bit string:

1101001

represents the polynomial:

x6+x5+x3+1x^6+x^5+x^3+1

Arithmetic in GF(2) uses:

  • addition = XOR
  • subtraction = XOR
  • multiplication = AND + XOR
  • no carries or borrows

This makes CRCs extremely efficient in hardware and mathematically elegant.

Generator Polynomial

A CRC is defined by a generator polynomial G(x).
For example, CRC‑32 Ethernet uses:

G(x)=x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x+1G(x)=x^{32}+x^{26}+x^{23}+x^{22}+x^{16}+x^{12}+x^{11}+x^{10}+x^8+x^7+x^5+x^4+x^2+x+1

which corresponds to the hexadecimal representation:

0x04C11DB7

The generator polynomial determines:

  • error‑detecting capability
  • structure of the LFSR
  • parallel XOR equations
  • syndrome properties

Polynomial Division

CRC computation is equivalent to dividing the message polynomial M(x) by the generator polynomial G(x):

The remainder of this division is the CRC value.

In hardware, this division is implemented using:

  • shift registers
  • XOR feedback
  • conditional taps

which form the LFSR representation of the polynomial.

Reflection (Bit Reversal)

Many CRCs use bit reflection:

  • RefIn: input bytes are reversed bit‑wise
  • RefOut: the final CRC is reversed bit‑wise

Reflection changes:

  • the direction of the LFSR
  • the order of taps
  • the parallel XOR equations

Example:

  • CRC‑32 Ethernet → reflected
  • CRC‑32 MPEG‑2 → non‑reflected

Two CRCs with the same polynomial can behave differently solely due to reflection rules.

Initial Value and Final XOR

Two additional parameters influence CRC behavior:

  • Init — initial value loaded into the CRC register
  • XOR Out — value XORed with the CRC at the end

These parameters allow:

  • detection of leading zeros
  • compatibility with legacy protocols
  • simplified verification

Example:

  • CRC‑32 Ethernet: Init = 0xFFFFFFFF, XOR Out = 0xFFFFFFFF
  • CRC‑32 MPEG‑2: Init = 0xFFFFFFFF, XOR Out = 0x00000000

LFSR Representation

The generator polynomial maps directly to an LFSR:

  • each non‑zero term corresponds to a feedback tap
  • the highest‑order term x^n defines the register width
  • XOR gates implement modulo‑2 addition

This representation is the foundation for:

  • serial CRC
  • parallel CRC
  • pipelined CRC

Unrolling the LFSR (Basis for Parallel CRC)

Parallel CRCs are derived by unrolling the LFSR for N steps.
Mathematically:

CRCnext=ANCRCcurrent⊕︎(k=0N1AkBdata[k])\mathrm{CRC_{next}}=A^N\cdot \mathrm{CRC_{current}}\oplus \left( \sum _{k=0}^{N-1}A^kB\cdot \mathrm{data}[k]\right)

where:

  • A is the state transition matrix
  • B is the input influence vector

This formulation is the theoretical basis for the XOR matrices used in hardware.

Error‑Detection Properties

CRCs detect:

  • all single‑bit errors
  • all double‑bit errors
  • all odd‑numbered bit errors (for many polynomials)
  • all burst errors shorter than the polynomial degree
  • most longer burst errors with extremely high probability

Example:
CRC‑32 Ethernet detects all burst errors up to 32 bits.

Why Many CRC Variants Exist

Different protocols choose different parameters to optimize:

  • error‑detection capability
  • hardware complexity
  • compatibility with legacy systems
  • bit ordering
  • throughput

This is why CRC‑32 Ethernet, CRC‑32 Castagnoli, and CRC‑32 MPEG‑2 are all 32‑bit CRCs but behave differently.

Related Pages