soc/cores/ecc: improve readibility, uniformize with others cores
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sun, 29 Sep 2019 14:02:04 +0000 (16:02 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sun, 29 Sep 2019 14:02:04 +0000 (16:02 +0200)
litex/soc/cores/ecc.py

index 0a63c086a9f05d91fe97fb69d42da96a9cbc6f60..7471687e5d77779ea02962d63f0a320c4005c2eb 100644 (file)
@@ -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):