我有一个奇怪的通信通道,我需要检测错误并消除通道中的某些序列。
每条消息长 12 位,分成 3 个半字节(每个 4 位)。我需要从中提取至少 450 个不同的代码,这样我的汉明距离就可以达到 3。
但是,我不能让两个半字节序列相同,因此以下序列无效:
0xf 0xf 0xf - Three of the same nibbles in sequence
0x8 0x8 0x0 - Two of the same nibbles in sequence
0xf 0x3 0x3 - Two of the same nibbles in sequence
此外,消息可以不间断地相互跟随,因此一个序列的开头不能与最后一个序列的结尾具有相同的第一个半字节:
0x327 0x743 - Even though they are not in the same message, two sequential nibbles are the same in the message stream
但是以下序列很好:
0x1 0x2 0x1 - Two nibbles same, but separated by another nibble
0x0 0x1 0x2 - All nibbles different
0xf 0x8 0x3 - All nibbles different
以下一系列消息很好:
0x121 0x012 0xf83 - No two adjacent nibbles are the same is the stream of messages
我的第一个想法是为我的消息使用 9 位,分成三个 3 位部分作为每个半字节的最高位:
mmmc mmmc mmmc - Each character is a bit, m bits are message, c bits are checksum/parity/etc
然后设计一个 512 条目表,给我三个要填充的位c
,这将创建汉明距离,同时消除麻烦的序列。
但是,这将在低端嵌入式处理器上运行,如果我可以使用算术动态生成c
位,它将节省内存(以换取更多的处理器时间),这在这种情况下更有价值。
有没有我可以执行的一些数学运算可以在没有表格的情况下解决这个问题?
或者,是否有另一种符合要求的数学打包方法?