
This project is a single-cycle SEC-DED (Single Error Correction, Double Error Detection) error-correcting code block based on the (13,8) extended Hamming code. It protects 8 bits of data with 5 check bits. Any single flipped bit in the 13-bit codeword is corrected, and any two flipped bits are detected and flagged. This is the same class of ECC used in DRAM, SRAM caches, SSD controllers and safety-critical automotive memories.
The design has two modes, selected by the MODE pin (uio[5]). All outputs are registered, so each encode or decode operation completes in exactly one clock cycle, and the whole design runs on the single clk clock domain.
Encode mode (MODE = 0): the 8-bit data on ui_in is used to compute four Hamming parity bits (P1, P2, P4, P8) and one overall parity bit (P0). After one clock edge, the data appears on uo_out and the 5 check bits are driven out on uio[4:0].
Codeword bit positions:
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | overall |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Bit | P1 | P2 | D0 | P4 | D1 | D2 | D3 | P8 | D4 | D5 | D6 | D7 | P0 |
Each parity bit Pn covers every position whose index has bit n set (P1 covers positions 3, 5, 7, 9, 11; P2 covers 3, 6, 7, 10, 11; P4 covers 5, 6, 7, 12; P8 covers 9, 10, 11, 12). P0 is the XOR of all 12 bits.
Decode mode (MODE = 1): the received data is applied on ui_in and the received check bits on uio[4:0]. The decoder recomputes the parity to form a 4-bit syndrome and also recomputes the overall parity:
| Syndrome | Overall parity | Meaning | Action |
|---|---|---|---|
| 0 | 0 | No error | Data passed through, SEC = 0, DED = 0 |
| any 1-12 | 1 | Single-bit error | Bit at position = syndrome is flipped, SEC = 1 |
| 0 | 1 | Error in P0 only | Data already correct, SEC = 1 |
| non-zero | 0 | Double-bit error | Data not corrected, DED = 1 |
| 13-15 | 1 | Uncorrectable error | Data not corrected, DED = 1 |
The corrected data appears on uo_out and the SEC (uio[6]) and DED (uio[7]) flags are updated on the next clock edge.
The cocotb testbench in the test folder verifies the design exhaustively: all 256 data values in encode mode, all 256 clean codewords, all 3,328 single-bit error cases (256 x 13 positions) and all 19,968 double-bit error cases (256 x 78 position pairs), checked against an independent Python golden model.
No external hardware is required. The DIP switches and the bidirectional PMOD header on the Tiny Tapeout demo board can be used to drive the data, check bits and MODE inputs, and the 7-segment display or a logic analyser can be used to observe uo_out and the SEC/DED flags.
We gratefully acknowledge the Center of Excellence (CoE) in Integrated Circuits and Systems (ICAS) and the Department of Electronics and Communication Engineering (ECE) for providing the necessary resources and guidance. Special thanks to Dr. H V Ravish Aradhya (HoD - ECE), Dr. K R Usha Rani (Associate Dean - PG), Dr. K. S. Geetha (Vice Principal) and Dr. K. N. Subramanya (Principal) for their constant encouragement and support in facilitating this Tiny Tapeout SKY26C submission.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | DATA_IN[0] | DATA_OUT[0] | CHECK[0] P1 (out in encode, in in decode) |
| 1 | DATA_IN[1] | DATA_OUT[1] | CHECK[1] P2 (out in encode, in in decode) |
| 2 | DATA_IN[2] | DATA_OUT[2] | CHECK[2] P4 (out in encode, in in decode) |
| 3 | DATA_IN[3] | DATA_OUT[3] | CHECK[3] P8 (out in encode, in in decode) |
| 4 | DATA_IN[4] | DATA_OUT[4] | CHECK[4] P0 overall parity (out in encode, in in decode) |
| 5 | DATA_IN[5] | DATA_OUT[5] | MODE (in) 0 = encode, 1 = decode |
| 6 | DATA_IN[6] | DATA_OUT[6] | SEC (out) single error corrected |
| 7 | DATA_IN[7] | DATA_OUT[7] | DED (out) double error detected |