Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change BitSequence comparison to use int value & pad bytes in tobytes() #255

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

addinh
Copy link

@addinh addinh commented Jul 5, 2021

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 by int.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)

@eblot
Copy link
Owner

eblot commented Nov 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants