diff --git a/specs/data.md b/specs/data.md new file mode 100644 index 0000000..a62a35b --- /dev/null +++ b/specs/data.md @@ -0,0 +1,30 @@ +# Data card + +The data card deals with binary data, thus there must be a simple format. + +## Hamming ECC + +Each nibble (4-bit sequence) uses a Hamming (7, 4) code encoded in 1 byte, with the ability to detect 2 bit errors (but not correct them) + +Given N bytes to encode, the final encoded output will take 2N bytes. +This also means when decoding, the length must be even. + +A byte is split into 2 nibbles, with the one comprised of the lowest bits first. +Each nibble is ECC encoded separately. +In a nibble there are 4 bits d0, d1, d2 and d3, where dN refers to the bit with value 2^N (2 to the N). +In the output, there are p0, p1, p2, p3 bits, where p1 and above represent hamming code parity data, and p0 is a parity check on the whole block. + +### Nibble arrangement + +``` +| d0 | d1 | d2 | d3 | +``` + +### Hamming code arrangement + +``` +| p0 | p1 | p2 | d0 | +| p3 | d1 | d2 | d3 | +``` + +This creates a fairly generic hamming code structure. Do note that p0 is the bit for checking the whole block's parity.