soc/cores/ecc: improve readibility, uniformize with others cores
This commit is contained in:
parent
c6fe3f3145
commit
7575ecc6ad
|
@ -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):
|
||||||
|
|
Loading…
Reference in New Issue