soc/cores/ecc: improve readibility, uniformize with others cores

This commit is contained in:
Florent Kermarrec 2019-09-29 16:02:04 +02:00
parent c6fe3f3145
commit 7575ecc6ad
1 changed files with 4 additions and 0 deletions

View File

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