From 7575ecc6adb07ece0072f609b1eea64b3036725f Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Sun, 29 Sep 2019 16:02:04 +0200 Subject: [PATCH] soc/cores/ecc: improve readibility, uniformize with others cores --- litex/soc/cores/ecc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litex/soc/cores/ecc.py b/litex/soc/cores/ecc.py index 0a63c086..7471687e 100644 --- a/litex/soc/cores/ecc.py +++ b/litex/soc/cores/ecc.py @@ -14,6 +14,7 @@ from operator import xor from migen import * +# Helpers ------------------------------------------------------------------------------------------ def compute_m_n(k): m = 1 @@ -50,6 +51,7 @@ def compute_cover_positions(m, p): i += 2*p return r +# SECDED (Single Error Detection, Double Error Detection) ------------------------------------------ class SECDED: def place_data(self, data, codeword): @@ -82,6 +84,7 @@ class SECDED: self.comb += parity.eq(reduce(xor, [codeword[i] for i in range(len(codeword))])) +# ECC Encoder -------------------------------------------------------------------------------------- class ECCEncoder(SECDED, Module): def __init__(self, k): @@ -109,6 +112,7 @@ class ECCEncoder(SECDED, Module): # output codeword + parity self.comb += o.eq(Cat(parity, codeword_d_p)) +# ECC Decoder -------------------------------------------------------------------------------------- class ECCDecoder(SECDED, Module): def __init__(self, k): -- 2.30.2