MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
|
#include <Parity2D_4x4.h>
Public Types | |
enum | { W = 4, H = 4, DATA_BITS = W * H, ECC_BITS = W + H + 1, TABLE_SIZE = 1 << DATA_BITS, INDEX_MASK = TABLE_SIZE - 1, ECC_MASK = (1 << ECC_BITS) - 1 } |
Static Public Member Functions | |
static u32 | Compute2DParity (u32 dataBits) |
static u32 | ComputeParitySlow (u32 dataBits) |
static u32 | Add2DParity (u32 dataBits) |
static bool | Remove2DParity (u32 allBits, u32 &dataBits) |
static bool | Check2DParity (const u32 allBits) |
static u32 | CheckAndCorrect2DParity (const u32 allBits) |
static u32 | Correct2DParityIfPossible (u32 allBits) |
Static Public Attributes | |
static const u8 | indices2D [H+1][W+1] |
Parity2D_4x4 is an all-static class for manipulating (one particular instance of) two-dimensional parity error detection and correction. This class handles error detection and correction only of sixteen bit quantities being protected with nine additional bits. In addition, this class assumes the nine ECC bits will be placed to the left of the sixteen data bits when they are joined into a 25-bit quantity.
Redundancy at the level of nine bits protecting sixteen bits ensures that all single bit errors are correctable and all double bit errors are detectable. Most all triple bit errors are detectable as well.
This class uses a table lookup to accelerate the generation and checking of the parity bits. In particular, Compute2DParity and Check2DParity are both likely inlined and fast enough to use with impunity virtually anywhere. In addition, CheckAndCorrect2DParity and Remove2DParityFrom are fast if no errors are detected, but note only moderate effort has been made to accelerate Correct2DParityIfPossible, which is the routine that actually performs the error correction to the degree possible.
|
inlinestatic |
Return the 25 bit quantity formed by prefixing the nine bits of 2D parity to the 16 bits of dataBits.
|
inlinestatic |
Check the 2D parity of allBits, assuming it is laid out in bit number order from its most significant bit on the left to its least significant bit on the right, using the data bit and parity bit definitions given in the documentation for Compute2DParity.
|
inlinestatic |
Check the 2D parity of allBits, assuming it is laid out in bit number order from its most significant bit on the left to its least significant bit on the right, using the data bit and parity bit definitions given in the documentation for Compute2DParity.
The value returned is equal to allBits if the parity checks, is 0 if the parity does not check but allBits is so damaged it cannot be repaired. Otherwise the value returned is non-zero and not equal to allBits, and it represents the error-corrected value of allBits.
|
inlinestatic |
Compute the nine bit quantity representing the 2D parity of the bottom 16 bits of dataBits. Assume 0..f represent the bottom sixteen bits of dataBits from least significant (0) to most significant (f) bit, and assume g..o represent the bottom nine bits of the computed 2D parity, from least significant (g) to most significant (o) bit. Then given this layout:
f e d c j b a 9 8 i 7 6 5 4 h 3 2 1 0 g k l m n o
this function returns the nine bits (corresponding to g..o) such that each 5-element row and 5-element column has odd parity, and the overall group of 25 bits has even parity (but is never all zero).
|
static |
Attempt to error-correct allBits. Note: Usually callers will prefer to call CheckAndCorrect2DParity, because it's fast if the parity is correct, while this method is slow in all cases.
The value returned is equal to allBits if the parity checks, is 0 if the parity does not check but allBits is so damaged it cannot be repaired. Otherwise the value returned is non-zero and not equal to allBits, and it represents the error-corrected value of allBits.
|
inlinestatic |
Remove the nine parity bits from allBits if possible, storing the (possibly error-corrected) resulting sixteen bits in dataBits.
|
static |