iamczx
Member level 3
hamming code for flash memories
for a 512 byte,using hamming code to fix 1 bit ,detect 2 bit error.
The st application note (AN1823 Error Correction Code in Single Level Cell NAND Flash Memories) give the following code, and I am puzzling the last judement of
if(i & A0) which I think should be if (i &0x100). Anyone ever do this job?please tell me which is true. Thanks in advance
for a 512 byte,using hamming code to fix 1 bit ,detect 2 bit error.
The st application note (AN1823 Error Correction Code in Single Level Cell NAND Flash Memories) give the following code, and I am puzzling the last judement of
if(i & A0) which I think should be if (i &0x100). Anyone ever do this job?please tell me which is true. Thanks in advance
Code:
Pseudo Code for ECC Generation
The following code implements the Parity Generation shown in Figure 4.
For i = 1 to 256(1)
begin
if (i & 0x01)
LP1 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP1;
else
LP0 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP1;
if (i & 0x02)
LP3 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP3;
else
LP2 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP2;
if (i & 0x04)
LP5 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP5;
else
LP4 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP4;
if (i & 0x08)
LP7 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP7;
else
LP6 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP6;
if (i & 0x10)
LP9 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP9;
else
LP8 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP8;
if (i & 0x20)
LP11 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP11;
else
LP10 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP10;
if (i & 0x40)
LP13 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP13;
else
LP12 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP12;
if (i & 0x80)
LP15 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP15;
else
LP14 = bit7 xor bit6 xor bit5 xor bit4 xor bit3 xor bit2 xor bit1 xor bit0 xor LP14;
//*************************************************************
if(i & A0) //here I think it should be 0x100
//*************************************************************
LP17 = bit7 (Xor) bit6 (Xor) bit5 (Xor) bit4 (Xor) bit3 (Xor) bit2 (Xor) bit1
(Xor) bit0 (Xor) LP17
else
LP16 = bit7 (Xor) bit6 (Xor) bit5 (Xor) bit4 (Xor) bit3 (Xor) bit2 (Xor) bit1
(Xor) bit0 (Xor) LP16(2)
CP0 = bit6 xor bit4 xor bit2 xor bit0 xor CP0;
CP1 = bit7 xor bit5 xor bit3 xor bit1 xor CP1;
CP2 = bit5 xor bit4 xor bit1 xor bit0 xor CP2;
CP3 = bit7 xor bit6 xor bit3 xor bit2 xor CP3
CP4 = bit3 xor bit2 xor bit1 xor bit0 xor CP4
CP5 = bit7 xor bit6 xor bit5 xor bit4 xor CP5
end
Where xor means bitwise XOR operation.
1. For 512 Byte Inputs the "i" range is from 1 to 512 Bytes.
2. The last controll "if(i & A0)" is execute only in the case of 512 Byte Inputs.