Lines Matching refs:parity
28 bytes. This is done by calculating several parity bits over the rows and
29 columns. The parity used is even parity which means that the parity bit = 1
30 if the data over which the parity is calculated is 1 and the parity bit = 0
31 if the data over which the parity is calculated is 0. So the total
32 number of bits over the data over which the parity is calculated + the
33 parity bit is even. (see wikipedia if you can't follow this).
53 cp is my abbreviation for column parity, rp for row parity.
55 Let's start to explain column parity.
56 cp0 is the parity that belongs to all bit0, bit2, bit4, bit6.
59 cp2 is the parity over bit0, bit1, bit4 and bit5
60 cp3 is the parity over bit2, bit3, bit6 and bit7.
61 cp4 is the parity over bit0, bit1, bit2 and bit3.
62 cp5 is the parity over bit4, bit5, bit6 and bit7.
65 Row parity actually works almost the same.
66 rp0 is the parity of all even bytes (0, 2, 4, 6, ... 252, 254)
67 rp1 is the parity of all odd bytes (1, 3, 5, 7, ..., 253, 255)
68 rp2 is the parity of all bytes 0, 1, 4, 5, 8, 9, ...
72 so rp4 calculates parity over bytes 0, 1, 2, 3, 8, 9, 10, 11, 16, ...)
86 In the end the parity bits are grouped together in three bytes as
95 nicer picture.(but they use line parity as term where I use row parity)
103 Implementing the parity calculation is pretty simple.
159 For the column parity this is easy. We can just xor the bytes and in the
170 const char parity[256] = {
218 (parity[rp7] << 7) |
219 (parity[rp6] << 6) |
220 (parity[rp5] << 5) |
221 (parity[rp4] << 4) |
222 (parity[rp3] << 3) |
223 (parity[rp2] << 2) |
224 (parity[rp1] << 1) |
225 (parity[rp0]);
227 (parity[rp15] << 7) |
228 (parity[rp14] << 6) |
229 (parity[rp13] << 5) |
230 (parity[rp12] << 4) |
231 (parity[rp11] << 3) |
232 (parity[rp10] << 2) |
233 (parity[rp9] << 1) |
234 (parity[rp8]);
236 (parity[par & 0xf0] << 7) |
237 (parity[par & 0x0f] << 6) |
238 (parity[par & 0xcc] << 5) |
239 (parity[par & 0x33] << 4) |
240 (parity[par & 0xaa] << 3) |
241 (parity[par & 0x55] << 2);
251 I also introduced the parity lookup. I expected this to be the fastest
252 way to calculate the parity, but I will investigate alternatives later
271 Of course this means some modification as the row parity is byte by
273 for the column parity we use the par variable. When extending to 32 bits
296 extern const char parity[256];
326 long; also the column parity calculation needs to be changed.
350 (parity[rp7] << 7) |
351 (parity[rp6] << 6) |
352 (parity[rp5] << 5) |
353 (parity[rp4] << 4) |
354 (parity[rp3] << 3) |
355 (parity[rp2] << 2) |
356 (parity[rp1] << 1) |
357 (parity[rp0]);
359 (parity[rp15] << 7) |
360 (parity[rp14] << 6) |
361 (parity[rp13] << 5) |
362 (parity[rp12] << 4) |
363 (parity[rp11] << 3) |
364 (parity[rp10] << 2) |
365 (parity[rp9] << 1) |
366 (parity[rp8]);
368 (parity[par & 0xf0] << 7) |
369 (parity[par & 0x0f] << 6) |
370 (parity[par & 0xcc] << 5) |
371 (parity[par & 0x33] << 4) |
372 (parity[par & 0xaa] << 3) |
373 (parity[par & 0x55] << 2);
379 The parity array is not shown any more. Note also that for these
396 rp14). That is why some places refer to inverse parity.
509 statements. Why not keep a running parity and only keep the last if
545 As you can see tmppar is used to accumulate the parity within a for
550 contains the running parity for this iteration. So instead of having:
645 We can simply calculate the total parity. If this is 0 then rp4 = rp5
646 etc. If the parity is 1, then rp4 = !rp5;
657 kind of other things, like having dedicated parity arrays to avoid the
658 shift after parity[rp7] << 7; No gain.
659 Change the lookup using the parity array by using shift operators (e.g.
660 replace parity[rp7] << 7 with:
667 The only marginal change was inverting the parity bits, so we can remove