-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbch127_8.py
More file actions
31 lines (23 loc) · 1.19 KB
/
bch127_8.py
File metadata and controls
31 lines (23 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import bch_utils
class BCH127_8:
def __init__(self):
self.n = 127
self.k = 8
self.t = 31
self.generator = [1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1,
1, 1, 1,
0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1,
0, 0, 1,
0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1,
0, 1, 1,
0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1]
def encode(self, data, output="codeword"):
return bch_utils.encode(data, self.generator, self.n, self.k, output=output)
def validation_encode(self, data, output="codeword"):
return bch_utils.validation_encode(data, self.n, self.k, output=output)
def decode(self, codeword):
return bch_utils.decode(codeword, self.generator, self.t)
def validation_decode(self, codeword):
return bch_utils.validation_decode(codeword, self.n, self.k)
if __name__ == "__main__":
bch_utils.run_bch_interaction(BCH127_8())