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 reversed bit order in PriorityEncoder #640

Closed
wants to merge 1 commit into from
Closed

fix reversed bit order in PriorityEncoder #640

wants to merge 1 commit into from

Conversation

hansfbaier
Copy link

@hansfbaier hansfbaier commented Oct 9, 2021

After the change it works as expected:
image
Slicing already has reversed bit numbering in comparison to verilog,
so the reversed function was not necessary.
Or, rather, because the last m.d.comb wins, that did the reversing.

@hansfbaier
Copy link
Author

with reversed(..) it looks like this:
image

@whitequark
Copy link
Member

This PR breaks the testsuite.

@hansfbaier
Copy link
Author

Ah now I see what the module and the test is doing. It gets the bit number of the least significant nonzero bit. I was expecting to get the most significant nonzero bit according to https://en.m.wikipedia.org/wiki/Priority_encoder
Is that intentional?

@whitequark
Copy link
Member

whitequark commented Oct 9, 2021

Yes. PriorityEncoder has an invariant:

Assert(enc.n | enc.i.bit_select(enc.o, 1))

@hansfbaier
Copy link
Author

Ok,. Thanks

@hansfbaier hansfbaier closed this Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants