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. Parity Datapath

Part 7 · Memory & Buses · Intermediate

Parity Datapath

Store one parity bit with each word, check it on reads, and provide deliberate error injection.

Why this matters

Parity looks cheap, but it misses any even number of flipped bits and cannot say which bit is wrong. A design that returns the data without an error flag turns a detected fault into silent corruption.

After this lesson you can: write the even-parity store and check path for a 32-bit memory, and say exactly what it covers.

Even parity

p=d0​⊕d1​⊕⋯⊕dN−1​

For the running SRAM, each write stores 32 data bits plus one even-parity bit. The read path uses continuous unpacking and checking so the snippet is valid RTL rather than an unscoped procedural assignment.

Even parity on an 8-bit example: a tree of XOR gates makes p on the write side; on the read side a test-only mask can flip bits before a second XOR tree and a final XOR with the stored p raise parity_error

Read the top half from the inputs down: each XOR gate outputs the small number beside it. The bottom half is the read path, top to bottom.

  • Generate: the tree reduces eight bits to one. Four ones give p = 0, so the stored nine bits hold an even number of ones. A 32-bit word uses the same tree with more levels.

  • Inject: the mask XOR sits after storage and before the checker. A mask with one 1 flips one bit and must raise parity_error; production keeps the mask at zero and locked.

  • Check: the read tree recomputes parity over the data and XORs it with the stored p. Any odd number of flips gives 1; an even number gives 0 and escapes.

design.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
// snippet: even parity store and check
logic [DW:0] mem [0:DEPTH-1];
logic [DW:0] protected_word;
logic [DW-1:0] raw_data;
logic stored_parity;

always_ff @(posedge clk)
  if (write_en) mem[write_addr] <= {^write_data, write_data};

assign protected_word = mem[read_addr]; // asynchronous-read teaching model
assign {stored_parity, raw_data} = protected_word;
assign parity_error = (^raw_data) ^ stored_parity;
assign read_data = raw_data;

A target SRAM with registered reads moves protected_word into the clocked read stage; the parity equation and reporting policy remain unchanged. The implementation lesson must match the selected macro latency.

Parity detects any odd number of bit flips but cannot identify the bad bit. An even number of flips can cancel, so the protection claim must say exactly what is covered.

  • Latch address, the stored parity/check result, and operation context with the error.

  • Count errors with a saturating counter.

  • Provide a controlled injection XOR before the checker, disabled and locked in production.

  • Do not silently return corrupt data without a valid/error indication.

Check yourself Two bits flip in one parity-protected word. Must parity detect it?

No. Two flips preserve parity. This is why parity's diagnostic claim is weaker than SECDED.

Remember

  • Store 32 data bits plus one even-parity bit. Check the XOR on read.

  • Parity detects any odd number of flips. Two flips cancel.

  • On an error, latch the address and context, count with a saturating counter, and never return the data without an error indication.

Rule of thumb: state the exact fault coverage in the claim, not just the word protected.

Keep going

  • Practice: ECC memory RTL design

  • Code lab: Even parity generator

  • Interview: run a mock interview on this topic

Related topics

  • SECDED encode and syndrome

Previous

233 / 350

Next: SECDED Encode and Syndrome

Up next

Up nextSECDED Encode and Syndrome

Sign in to save progress

Practice this lessonReport an error

See also

  • Correction and Reporting
  • Partial Writes and Scrubbing
  • Initialization, Injection, and Signoff