
V PERIPHERAL MODULES 3 (INTERFACE): CARD INTERFACE (CARD)
V-4-8
EPSON
S1C33E07 TECHNICAL MANUAL
V.4.6 ECC Generator
In order to improve the card interface reliability, an ECC (Error Correction Code) generator is embedded in this
module. The ECC generator generates a 22-bit ECC parity data, which consists of a 6-bit column parity code (CP)
and a 16-bit line parity code (LP), for each 256 bytes (in the case of 8-bit devices) or 128 words (in the case of
16-bit devices) of card data area.
When reading data from a card, software can compare the ECC data read from the card with the data generated by
the ECC generator. It makes it possible to detect two bit errors and correct one bit errors.
When writing data to a card, software can write the ECC data generated by the ECC generator to the redundant area
of the card.
ECC algorithm
The card data is treated as bit streams, and ECC parity data is generated as follows:
‘^’ denotes the XOR (exclusive OR) operation.
ECC for 8-bit card device:
CP[0] = Din[0] ^ Din[2] ^ Din[4] ^ Din[6] ^ org[0]
CP[1] = Din[1] ^ Din[3] ^ Din[5] ^ Din[7] ^ org[1]
CP[2] = Din[0] ^ Din[1] ^ Din[4] ^ Din[5] ^ org[2]
CP[3] = Din[2] ^ Din[3] ^ Din[6] ^ Din[7] ^ org[3]
CP[4] = Din[0] ^ Din[1] ^ Din[2] ^ Din[3] ^ org[4]
CP[5] = Din[4] ^ Din[5] ^ Din[6] ^ Din[7] ^ org[5]
Dall = Din[0] ^ Din[1] ^ Din[2] ^ Din[3] ^ Din[4] ^ Din[5] ^ Din[6] ^ Din[7]
Count [8:0] = Count [8:0] +1
LP[0]
=
( ~Count[0] & Dall ) ^ org[0]
LP[2]
=
( ~Count[1] & Dall ) ^ org[2]
LP[4]
=
( ~Count[2] & Dall ) ^ org[4]
LP[6]
=
( ~Count[3] & Dall ) ^ org[6]
LP[8]
=
( ~Count[4] & Dall ) ^ org[8]
LP[10] =
( ~Count[5] & Dall ) ^ org[10]
LP[12] =
( ~Count[6] & Dall ) ^ org[12]
LP[14] =
( ~Count[7] & Dall ) ^ org[14]
LP[1]
=
(
Count[0] & Dall ) ^ org[1]
LP[3]
=
(
Count[1] & Dall ) ^ org[3]
LP[5]
=
(
Count[2] & Dall ) ^ org[5]
LP[7]
=
(
Count[3] & Dall ) ^ org[7]
LP[9]
=
(
Count[4] & Dall ) ^ org[9]
LP[11] =
(
Count[5] & Dall ) ^ org[11]
LP[13] =
(
Count[6] & Dall ) ^ org[13]
LP[15] =
(
Count[7] & Dall ) ^ org[15]
ECC for 16-bit card device:
CP[0] = Din[0] ^ Din[2] ^ Din[4] ^ Din[6] ^ Din[8]
^ Din[10] ^ Din[12] ^ Din[14] ^ org[0]
CP[1] = Din[1] ^ Din[3] ^ Din[5] ^ Din[7] ^ Din[9]
^ Din[11] ^ Din[13] ^ Din[15] ^ org[1]
CP[2] = Din[0] ^ Din[1] ^ Din[4] ^ Din[5] ^ Din[8]
^ Din[9]
^ Din[12] ^ Din[13] ^ org[2]
CP[3] = Din[2] ^ Din[3] ^ Din[6] ^ Din[7] ^ Din[10] ^ Din[11] ^ Din[14] ^ Din[15] ^ org[3]
CP[4] = Din[0] ^ Din[1] ^ Din[2] ^ Din[3] ^ Din[8]
^ Din[9]
^ Din[10] ^ Din[11] ^ org[4]
CP[5] = Din[4] ^ Din[5] ^ Din[6] ^ Din[7] ^ Din[12] ^ Din[13] ^ Din[14] ^ Din[15] ^ org[5]
Dall_low
= Din[0] ^ Din[1] ^ Din[2] ^ Din[3] ^ Din[4] ^ Din[5] ^ Din[6] ^ Din[7]
Dall_high = Din[8] ^ Din[9] ^ Din[10] ^ Din[11] ^ Din[12] ^ Din[13] ^ Din[14] ^ Din[15]
Dall
= Dall_low ^ Dall_high
Count [8:0] = Count [8:0] +2
LP[0]
=
( Dall_low ) ^ org[0]
LP[2]
=
( ~Count[1] & Dall ) ^ org[2]
LP[4]
=
( ~Count[2] & Dall ) ^ org[4]
LP[6]
=
( ~Count[3] & Dall ) ^ org[6]
LP[8]
=
( ~Count[4] & Dall ) ^ org[8]
LP[10] =
( ~Count[5] & Dall ) ^ org[10]
LP[12] =
( ~Count[6] & Dall ) ^ org[12]
LP[14] =
( ~Count[7] & Dall ) ^ org[14]
LP[1]
=
(
Dall_high ) ^ org[1]
LP[3]
=
(
Count[1] & Dall ) ^ org[3]
LP[5]
=
(
Count[2] & Dall ) ^ org[5]
LP[7]
=
(
Count[3] & Dall ) ^ org[7]
LP[9]
=
(
Count[4] & Dall ) ^ org[9]
LP[11] =
(
Count[5] & Dall ) ^ org[11]
LP[13] =
(
Count[6] & Dall ) ^ org[13]
LP[15] =
(
Count[7] & Dall ) ^ org[15]