fix binstr returning 0 for value=0 #2990
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I pull some minor changes:
I was using cocotb.binary to concatenate 2 vectors for a complex input on a single axistream bus. Each part (im/re) is on 8 bits and is concatenate on a 16 bits BinaryValue. In a more general case I use binaryValue to make the conversion to binstring since python only return signed magnitude of int.
If you use the present version you will notice that for :
Inbin=BinaryValue(n_bits=8,binaryRepresentation=BinaryRepresentation.TWOS_COMPLEMENT,bigEndian=False)
Inbin.value=0
print(Inbin.binstr)
will return NoneSince BinaryValue provide a way to handle and use binary representation it's an issue.
My very few modification force at least 1 zero in _str when the value is set to 0. If a n_bits is specified the size will be adapted by existing function.
Change made are minor, if it is really needed I can provide a test case as requested still at this moment it don't seem a necessity