From 98c5a14abe4bd13b4d281957763cc27c1d57fc89 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Tue, 19 Mar 2019 17:29:26 +0200 Subject: Update datatypes --- src/lib.rs | 52 +++++++++++++++++++++++++--------------------------- 1 file 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 { - 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 { + 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 } } -- cgit v1.3.1