summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2019-03-19 17:29:26 +0200
committerYuval Adam <_@yuv.al>2019-03-19 18:17:35 +0200
commit98c5a14abe4bd13b4d281957763cc27c1d57fc89 (patch)
tree405b65c9add713f4351ad0e703700361793083df /src/lib.rs
parentc0473e14960b354d2773304c9aa435b3d373300e (diff)
Update datatypes
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8e03ac8..4a10962 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,35 +1,31 @@
pub struct GfPoly {
+pub struct BCH {
+ m: i16,
+ t: i16,
+ prim_poly: u16
}
-pub struct BCH<'a> {
- m: u32,
- n: u32,
- t: u32,
- ecc_bits: u32,
- ecc_bytes: u32,
+impl BCH {
- a_pow_tab: u16,
- a_log_tab: u16,
- mod8_tab: u32,
- ecc_buf: u32,
- ecc_buf2: u32,
- xi_tab: u32,
- syn: u32,
- cache: u32,
- elp: GfPoly,
- poly_2t: GfPoly,
-}
+ pub fn build_gf_tables(self) {
+ let i: u16 = 1;
+ let x: u16 = 1;
+ //const k: u16 = 1 << deg(self.po);
+ }
-impl BCH {
- pub fn new(m: u32, _t: u32, _prim_poly: u32) -> Option<BCH> {
- let _err: u32 = 0;
- let _i: u32;
- let _words: u32;
- let _genpoly: u32;
+ /// Create a new BCH object initialized with
+ /// `m` - the Galois field order, must be in the 5-15 range
+ /// `t` - maximum error correction capability in bits
+ /// `prim_poly` - user-provided primitive polynomial
+ pub fn new(m: i16, t: i16, prim_poly: u16) -> Option<BCH> {
+ let err: u16 = 0;
+ let i: u16;
+ let words: u16;
+ let genpoly: u32;
- const MIN_M: u32 = 5;
- const MAX_M: u32 = 15;
+ const MIN_M: i16 = 5;
+ const MAX_M: i16 = 15;
if (m < MIN_M) || (m > MAX_M) {
// `m` values must be between5 and 15 in this implementation
@@ -37,11 +33,13 @@ impl BCH {
}
Some(BCH {
- m
+ m,
+ t,
+ prim_poly
})
}
- pub fn decode(self) -> u32{
+ pub fn decode(self) -> i16{
return self.m
}
}