scripts/libbtbb-2015-10-R1/python/utils/gen_barker_correct.py

24 lines
543 B
Python
Raw Normal View History

2016-12-17 04:18:30 -05:00
#!/usr/bin/env python
# Reverse the binary of thesebarker codes for the host code
barkers = (0x0d, 0x72)
distances = []
corrections = []
def count_bits(x):
i = 0
while x:
i += 1
x &= x - 1
return i
for i in range(128):
diffs = [(count_bits(barkers[0] ^ i), barkers[0]),
(count_bits(barkers[1] ^ i), barkers[1])]
diffs.sort()
distances.append(diffs[0][0])
corrections.append(diffs[0][1])
print "Barker distance:", distances
print "Barker correct:", ["0x%x" % c for c in corrections]