Binary Codes & Error Detection


Shared context
Convert one valid BCD digit d∈{0,…,9} to d mod 6. Input bits I₄I₃I₂I₁ have weights 8,4,2,1; output bits R₃R₂R₁ have weights 4,2,1. Illegal BCD inputs need not be detected.
Answer & solution
Answer: Outputs for inputs 0…9: 000,001,010,011,100,101,000,001,010,011. (no official key was published)
1. For d=0,…,5 the output equals d. For d=6,…,9 subtract six once, giving 0,1,2,3.
2. Table (decimal d: I₄I₃I₂I₁ → R₃R₂R₁): 0:0000→000; 1:0001→001; 2:0010→010; 3:0011→011; 4:0100→100; 5:0101→101; 6:0110→000; 7:0111→001; 8:1000→010; 9:1001→011.
3. Inputs 1010,1011,1100,1101,1110,1111 may all be assigned XXX (don’t-care), not mandatory zero. No fourth output bit is needed because the maximum remainder is 5; if a four-bit interface is desired, R₄=0 for valid inputs.
4. In particular parity is unchanged by subtracting six, so the least significant bit is simply R₁=I₁. This provides a useful check on every row.