RTL Studio Open IDE

Parity

Odd/Even Parity Select 8-bit — L1 Upgrade — L2 Upgrade

8-bit parity checker with selectable odd/even mode, LSB correction, and sticky error flag.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Odd/Even Parity Select 8-bit — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Parity catalog. Even/odd parity generators, checkers, and error-detection helpers. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP core implements an 8-bit parity checker that supports both odd and even parity modes. It calculates a syndrome to detect single-bit errors.

Critical Note: This design employs a heuristic correction strategy. Upon detecting a parity mismatch, it assumes the error is in the Least Significant Bit (LSB) and flips it.

  • Use Case: Suitable only when LSB errors are statistically more probable or when the LSB serves as a dedicated parity bit in a broader system context.
  • Warning: If the error is in any bit other than the LSB, the data will be corrupted further by this "correction." Do not use for general multi-bit error correction.

The design includes registered outputs and supports active-low asynchronous reset. A sticky error flag latches any detected error for system-level monitoring.

  • Parity Modes: Configurable via parity_mode input (0: Even, 1: Odd).
  • Error Detection: Identifies parity mismatches using syndrome calculation (XOR of all bits).
  • Heuristic Correction: Automatically flips the LSB (data_in[0]) if a parity mismatch is detected.
  • Sticky Flag: sticky_error remains high until reset, ensuring no error is missed.
  • Registered Output: All outputs are registered on the clock edge for timing stability.
  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Odd/Even Parity Select 8-bit — L1 Upgrade — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: 8-bit parity checker with selectable odd/even mode, LSB correction, and sticky error flag.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Architecture

The module computes the XOR of all 8 input data bits to form a syndrome. It compares the syndrome against the selected parity mode to determine validity.

  • Even Parity Mode (parity_mode=0): The syndrome (XOR of bits) should be 0. If syndrome != 0, an error is detected.
  • Odd Parity Mode (parity_mode=1): The syndrome (XOR of bits) should be 1. If syndrome != 1, an error is detected.

If an error is detected, the LSB of the data is flipped to "correct" it. The sticky error register retains the error state until a reset occurs.

Interface

The following table describes the port interface.

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
rd_enInput1Read enable to sample data
data_inInput8Input data bus
parity_modeInput10 for Even, 1 for Odd parity
data_outOutput8Output data (corrected if error)
parity_okOutput1High if parity matches mode
error_detectedOutput1High if current cycle has error
sticky_errorOutput1Latched error flag

Verification

The testbench covers five key scenarios to ensure correct operation.

Test CaseDescriptionExpected Result
TC1Even parity, no errorparity_ok=1, error=0, sticky=0
TC2Even parity, error present (LSB flipped)parity_ok=0, error=1, sticky=1, data_out corrected
TC3Odd parity, no errorparity_ok=1, error=0, sticky=0
TC4Odd parity, error present (LSB flipped)parity_ok=0, error=1, sticky=1, data_out corrected
TC5Reset assertionsticky_error=0

All tests passed successfully in the Icarus Verilog simulation environment. The simulation log confirms no mismatches in data, parity, or error flags.

More in Parity

All Parity blocks