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

fix binstr returning 0 for value=0 #2990

Closed
wants to merge 1 commit into from
Closed

fix binstr returning 0 for value=0 #2990

wants to merge 1 commit into from

Conversation

brunbruns
Copy link

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 None
Since 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

previously for a binary value initialized to 0 the binstr was empty, to be closer to vhdl now it return a vector of zeros (one zero if n_bits isn't specified)
This pull request was closed.
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.

None yet

1 participant