Change BitSequence comparison to use int value & pad bytes in tobytes()
This is a fix for issue #253 (BitSequence having erroneous comparison functions) as well as issue #245 (tobytes() should pad to byte length), since they both affect the test cases in tests/bits.py. A few more test cases have also been added.
Changes:
- BitSequence and BitZSequence
_cmp()now compares sequences based on their int value (more about this below) - BitSequence
tobytes()appends 0 before the MSB so that the sequence length is a multiple of 8.tobytes()should now return bytes that can be used byint.from_bytes()to get the int value of the original sequence.
The comparison methods being changed to use int value worked fine for BitSequence, however BitZSequence also uses the same _cmp() function which did not work because they cannot be converted to int. I wasn't sure how to fix this, so I added a function to calculate "int" value of BitZSequences by treating them as ternary strings (they cannot be compared with another BitSequence if they have Z bits, however)
Sorry, JTAG support had been unsupported for many years.
It is now part of the PyJtagTools sub-project, and BitZSequence has been deprecated, as BitSequence management has been rewritten from scratch.
If BitZSequence is still needed (?) I think we should rewrite it as a secondary BitSequence mask.