from migen import *
+# Helpers ------------------------------------------------------------------------------------------
def compute_m_n(k):
m = 1
i += 2*p
return r
+# SECDED (Single Error Detection, Double Error Detection) ------------------------------------------
class SECDED:
def place_data(self, data, codeword):
self.comb += parity.eq(reduce(xor,
[codeword[i] for i in range(len(codeword))]))
+# ECC Encoder --------------------------------------------------------------------------------------
class ECCEncoder(SECDED, Module):
def __init__(self, k):
# output codeword + parity
self.comb += o.eq(Cat(parity, codeword_d_p))
+# ECC Decoder --------------------------------------------------------------------------------------
class ECCDecoder(SECDED, Module):
def __init__(self, k):