So I made the circuit using CircuiJS, click here !

The OR-combination of d0-d1 seems to work well enough, parity works...
So this actually works as a 15-bit popcount, d0 would act like another parity-affecting bit after all, the popcount has a little bias but it's still a great system.
| d0 | d1 | d2-d15 | total | invert | result |
| 0 | 0 | 0-7 | 0-7 | 1 | 9-16 |
| 0 | 0 | 8-14 | 8-14 | 0 | 8-14 |
| 0 | 1 | 0-6 | 1-7 | 1 | 9-15 |
| 0 | 1 | 7-14 | 8-15 | 0 | 8-15 |
| 1 | 0 | 0-6 | 1-7 | 1 | 9-15 |
| 1 | 0 | 7-14 | 8-15 | 0 | 8-15 |
| 1 | 1 | 0-6 | 2-8 | 1 | 8-14 |
| 1 | 1 | 7-14 | 9-16 | 0 | 9-16 |
So this is proven : despite the compression with OR, NO case results in less than 8 set bits and at least one half of the bits are set on the data word.
The worst cases now are 8 consecutive 0 bits, or 9 cases, or 18 cases when considering the inversion.
0000000011111111 1000000001111111 1100000000111111 1110000000011111 1111000000001111 1111100000000111 1111110000000011 1111111000000001 1111111100000000
So when possible, this should be broken up, somehow...
Parity is even so it should not be contiguous because this increases the run length in the last case.
But at least we have a first estimate of the maximum run length.
For one word.
Because two words could be combined to clear more than 16 bits in a row:
data packet1 : 1111111100000000 parity packet1 : 0 header packet2 : 00 flip packet2 : 0 data packet2 : 0000000011111111
The worst case is 20 consecutive bits !
and there is 50% chances the sequence is stuck to level -1 or +1.
A double or triple parity could solve this...
OR drop the parity and implement a double, half-size popcount.
Yann Guidon / YGDES
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.