Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
    • SRAM and ROM
    • Register Files
    • Valid/Ready Handshake
    • AXI-Lite
    • AXI-Stream
    • Bus Integration
    • Synchronous FIFO
    • Register-Map and CSR RTL
    • Memory Reliability
      • Failure Model and Protection Choice
      • Parity Datapath
      • SECDED Encode and Syndrome
      • Correction and Reporting
      • Partial Writes and Scrubbing
      • Initialization, Injection, and Signoff
      • SECDED on a 32-bit Word, Worked
    • Peripheral RTL Integration
    • Full AXI4: RTL Roadmap
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Memory Reliability
  1. Topics
  2. RTL Design
  3. Memory & Buses
  4. Memory Reliability
  5. SECDED Encode and Syndrome

Part 7 · Memory & Buses · Intermediate

SECDED Encode and Syndrome

Hamming check bits plus overall parity distinguish no error, correctable single-bit errors, and detected double-bit errors.

On this page

    Why this matters

    A decoder that corrects when the overall parity says the error was a double flip changes valid bits and returns bad data as good. The syndrome and the overall parity bit must be read together.

    After this lesson you can: derive extended Hamming check bits for 32 data bits, compute the syndrome, and classify clean, correctable and uncorrectable words.

    For m data bits, choose r Hamming check bits such that 2^r >= m + r + 1, then add one overall parity bit for SECDED.

    For the 32-bit SRAM, six Hamming check bits satisfy the inequality and one overall parity bit produces a 39-bit protected word. Numbering and coverage must be frozen in an encoder/decoder package so storage, injection, syndrome reporting, and verification use the same layout.

    Derive extended Hamming (8,4)

    Use even parity, Hamming positions 1..7, and overall parity at position 8. Put p1/p2/p4 at 1/2/4; put d0/d1/d2/d3 at 3/5/6/7. Position numbers are not SystemVerilog bit indices: a packed vector [7:0] stores position j at bit j-1.

    Extended Hamming (8,4) for d[3:0] = 1011: positions 1 to 8 hold p1 p2 d0 p4 d1 d2 d3 P with values 1 0 1 0 1 0 1 0, and each check row shows the bits it XORs

    Read each check row across: it XORs only the bits shown in it. Position k is in check s_j when bit j of the number k is 1.

    • Clean word: every check row holds an even number of ones (four in s0, two in s1 and s2, four overall), so each XOR is 0.

    • One flip: flip position 5 and rows s0 and s2 each gain an odd count. The syndrome s2 s1 s0 = 101 = 5 points at the flipped position.

    • Overall row: it decides single versus double. One flip makes it odd; two flips leave it even with a nonzero syndrome, which is a detected UE.

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    // snippet: combinational equations for the frozen (8,4) convention
    // c[1:7] are positional bits here; c[8] is overall parity.
    c[3] = d[0]; c[5] = d[1]; c[6] = d[2]; c[7] = d[3];
    c[1] = c[3] ^ c[5] ^ c[7];
    c[2] = c[3] ^ c[6] ^ c[7];
    c[4] = c[5] ^ c[6] ^ c[7];
    c[8] = c[1] ^ c[2] ^ c[3] ^ c[4] ^ c[5] ^ c[6] ^ c[7];
    // Compute these checks from received bits, not regenerated data parity.
    s[0] = r[1] ^ r[3] ^ r[5] ^ r[7];
    s[1] = r[2] ^ r[3] ^ r[6] ^ r[7];
    s[2] = r[4] ^ r[5] ^ r[6] ^ r[7];
    overall_bad = r[1] ^ r[2] ^ r[3] ^ r[4] ^ r[5] ^ r[6] ^ r[7] ^ r[8];

    Illustrative input/fault

    Positions 1..8 / checks

    Decode

    d[3:0]=1011

    1,0,1,0,1,0,1,0; s=000, overall_bad=0

    Codeword clean

    Flip position 5 (d1)

    Coverage checks 1 and 4 fail: s=101=5; overall_bad=1

    Flip received position 5 back, recover 1011

    Flip position 8 only

    s=000; overall_bad=1

    Repair overall bit; data unchanged

    Flip positions 3 and 5

    s=3 XOR 5=6; overall_bad=0

    UE; do not flip position 6

    Try it: flip received bits

    The calculator starts on the figure's word: d[3:0] = 1011, stored as 1 0 1 0 1 0 1 0 with nothing flipped. Click a received position to flip it and watch the check rows, the syndrome and the overall parity.

    SECDED (8,4) calculator

    Loading secded calculator…

    Each check row XORs the received bits shown in it; an odd count of ones sets that syndrome bit. The overall row decides single versus double.
    • Flip position 5 (d1): rows s0 and s2 turn odd, the syndrome is 101 = 5 and overall parity is odd, so the decoder flips position 5 back and returns 1011.

    • Flip position 3 as well: the syndrome becomes 110 = 6 with even overall parity, a double-bit error. No data is returned and position 6 is left alone.

    • Clear, then flip positions 1, 2 and 3: the syndrome is 0 with odd overall parity, so the decoder calls it an overall-bit error and returns 1010 with d0 wrong. Three flips are outside the at-most-two-bit model.

    Wider words and the classification

    For 39 bits, use Hamming positions 1..38 with parity at 1,2,4,8,16,32; place the 32 data bits in remaining positions in ascending order, then overall parity at 39. Each check k XORs received positions whose binary position has bit k set. Encoding sets each parity bit to XOR of the other positions it covers; overall parity XORs positions 1..38. An odd-parity nonzero syndrome beyond position 38 must be rejected as UE, never used as an array index.

    The classification table assumes at most two flipped bits per codeword between trusted writes/repairs. It reports decoder classes under that model, not measured physical fault count. For example flips at positions 1,2,3 yield syndrome 1 XOR 2 XOR 3=0 with odd overall parity, aliasing the overall-parity-only CE row even though d0 is corrupt. Four flips at 1,2,4,7 have zero syndrome and even parity, aliasing clean. Higher-weight and correlated faults need a separate protection/risk analysis.

    Syndrome

    Overall parity mismatch

    Meaning

    Action

    0

    0

    No error

    Return data

    nonzero

    1

    Single-bit error in Hamming codeword

    Correct indexed bit

    0

    1

    Overall parity bit error

    Data already correct

    nonzero

    0

    Double-bit error

    Detect, do not correct

    Data passes through ECC encoder and syndrome decoder around protected memory.
    ECC spans write encoding, protected storage, read decode, correction, and reporting.

    Common pitfall

    Never correct a nonzero syndrome when overall parity says the error is double-bit. That would miscorrect valid bits and turn a detected failure into silent corruption.

    Check yourself Syndrome is zero but overall parity fails. What happened?

    Under the at-most-two-bit model, the overall parity bit flipped and data is unchanged (CE). Outside that model, positions 1/2/3 can alias the same row with corrupt data; the label does not prove the actual fault count.

    Remember

    • 32 data bits need six Hamming check bits and one overall parity bit, 39 bits in all.

    • Nonzero syndrome with odd overall parity is a single-bit error: correct it, and reject a position beyond 38.

    • Nonzero syndrome with even overall parity is a double-bit error: report it and never correct.

    Rule of thumb: freeze the bit layout in one package that encoder, decoder, injection and tests all use.

    Keep going

    • Practice: ECC memory RTL design

    • Code lab: SECDED encode

    • Code lab: SECDED decode

    • Interview: run a mock interview on this topic

    Related topics

    • Correction and reporting

    • SECDED on a 32-bit word, worked

    Previous

    234 / 350

    Next: Correction and Reporting

    Up next

    Up nextCorrection and Reporting

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Failure Model and Protection Choice
    • Partial Writes and Scrubbing
    • Initialization, Injection, and Signoff