**Instruction for Bi-Residue
coder/decoder**

**Introduction**:

For Residue code, one can refer to the course
webpages. A separate code with two residue checks is called
bi-residue code. We study [N, |N|** _{A1}**, |N|

**Theorem**: Consider
a biresidue code with k-bit data, that is, N \in **2 ^{k}-1**,

The theorem tells us in order to single-bit error correction, the bits of encoder/decoder and two check bases has the least common multiple relations. For example, if the input data bit width is 24, we can choose (c=8,d=6) or (c=12,d=8). If we want the data bit width is 32, we have to choose (c=32, d=2 or 4 or ...). Obviously, this is not a good choose.

**Syndrome and error correction**:

The syndrome of a 3-turple **(x,y,z)** is given by **S(x,y,z)=(s _{1},s_{2})=(|x-y|_{A1},|x-z|_{A2})**.
It is assumed that the three components of the code are processed in separate
units, called the adder, check_1, and check_2, respectively, and therefore at
most one of the components of the result will be erroneous at any given time. We
have the following rules:

**s**: no error._{1}=0, s_{2}=0**s**: error in the adder._{1}!=0, s_{2}!=0**s**: error in check_1._{1}!=0, s_{2}=0**s**: error in check_2._{1}=0, s_{2}!=0

The following table is a detailed example of syndromes to detect and correct
the error for the adder. Here, k=6, c=2, d=3. That is, A_{1}=3, A_{2}=7.
Input data is in the range of (0-63).

error bit-i | 0-->1 error | 1-->0 error |

0 | (1,1) | (2,6) |

1 | (2,2) | (1,5) |

2 | (1,4) | (2,3) |

3 | (2,1) | (1,6) |

4 | (1,2) | (2,5) |

5 | (2,4) | (1,3) |

**How the Bi-Residue error correction program
works**

** step 1**: Input the data word (DEC), with the corresponding
encoded bit width. Also input the bit width of the two check bases. If the LCM
requirement between the three inputs are not meet, a pop-up window indicating
errors will be shown.

** step 2**: Click the

__ step 3__: The user can change at most one bit error in
received word. If more than one errors are injected or the length of received
words is longer than the original encoded one, a pop-up window indicating errors
will be appear.

** step 4**: Click the

** step 5**: (optional) If the user clicks the

กก