CRC – Verification & Test Vectors
Verification is a critical part of any CRC implementation. Even small differences in reflection rules, initialization values, or final XOR settings can cause mismatches between hardware and reference models. This page provides standard test vectors, verification strategies, and guidelines for validating both serial and parallel CRC implementations.
1. Why Verification Matters
CRC implementations differ across protocols because of:
- generator polynomial
- initial value
- final XOR
- input and output reflection
- bit ordering (LSB-first vs MSB-first)
- parallel width (4, 8, 16, 32 bits)
Two CRCs with the same width may produce completely different results. Verification ensures that:
- the RTL matches the intended CRC variant
- parallel equations are correct
- reflection and XOR rules are applied properly
- the implementation is compatible with protocol specifications
2. Standard Test Vector: “123456789”
The ASCII string:
“123456789”
is the universal test vector used to validate CRC implementations.
It is recommended because:
- it exercises a wide range of bit transitions
- it is short and easy to reproduce
- reference values exist for all common CRCs
3. Reference Results for Common CRCs
| CRC Variant | Expected Result for “123456789” |
|---|---|
| CRC-8 ATM | 0xF4 |
| CRC-8 Maxim | 0xA1 |
| CRC-16 IBM | 0xBB3D |
| CRC-16 CCITT (0xFFFF init) | 0x29B1 |
| CRC-16 USB | 0xB4C8 |
| CRC-32 Ethernet | 0xCBF43926 |
| CRC-32 Castagnoli | 0xE3069283 |
| CRC-32 MPEG-2 | 0x0376E6E7 |
| CRC-64 ECMA | 0x6C40DF5F0B497347 |
These values are essential for validating both serial and parallel implementations.
4. Verification Strategy
A robust verification flow includes:
- Golden model
A software reference (Python, C, MATLAB) implementing the exact CRC variant. - Serial RTL model
Used as a reference for parallel versions. - Parallel RTL model
The implementation under test (4‑bit, 8‑bit, 32‑bit). - Self-checking testbench
Compares RTL output with golden model output. - Randomized testing
Random frames of varying lengths. - Corner cases
- empty frame
- single byte
- all zeros
- all ones
- alternating patterns
5. Python Reference Model (Golden Model)
A minimal Python implementation for CRC‑32 Ethernet:
def crc32_eth(data):
crc = 0xFFFFFFFF
for b in data:
crc ^= b
for _ in range(8):
if crc & 1:
crc = (crc >> 1) ^ 0xEDB88320
else:
crc >>= 1
return crc ^ 0xFFFFFFFF
This model is ideal for generating test vectors and validating RTL.
6. Testbench Guidelines
A typical VHDL or SystemVerilog testbench should:
- feed bytes into the CRC block with
data_valid = 1 - assert
data_laston the final byte - capture
crc_outwhencrc_valid = 1 - compare against the golden model
- report mismatches with full context
For parallel CRCs:
- test all possible byte alignments
- test multiple frame lengths
- test back‑to‑back frames
7. Debugging Common Issues
Most CRC mismatches come from:
- incorrect reflection (RefIn / RefOut)
- wrong initial value
- missing final XOR
- incorrect bit ordering
- wrong polynomial representation
- incorrect unrolling of parallel equations
Reflection errors are the most frequent cause of failure.
8. Related Pages
- CRC – Mathematical Background
Algebraic foundations of CRCs, including GF(2) polynomial arithmetic, reflection rules, and serial/parallel formulations. - CRC — Overview, Families & Architecture
Architectural principles for CRC computation, including polynomial division, reflection rules, parallel architectures, and integration into streaming datapaths. - CRC – Reference Table
A compact collection of CRC polynomials, initialization values, reflection settings, and expected results for standard test vectors. - CRC – RTL Architecture & Implementation Notes
Practical guidelines for implementing CRC generators and checkers in hardware, derived from the underlying algebraic and parallelization rules. - LFSR & PRBS — Overview, Families & Architecture
Provides a unified view of Linear Feedback Shift Registers and Pseudo‑Random Binary Sequences, covering architectural principles, polynomial families, implementation trade‑offs, and their role in line coding, scrambling, and verification flows. - Data Path – Architecture & Fundamentals
Integration of CRC computation into streaming datapaths, including placement, pipelining, and flow‑control considerations. - Flow Control – Architecture & Fundamentals
Mechanisms that regulate data movement and ensure correct CRC alignment, insertion, and checking within streaming pipelines. - Pipelining – Architecture & Fundamentals
Architectural techniques used to balance CRC computation latency, improve timing closure, and maintain full‑rate throughput.