ucb-bar / constellation

A Chisel RTL generator for network-on-chip interconnects
http://constellation.readthedocs.io
BSD 3-Clause "New" or "Revised" License
177 stars 25 forks source link

fix: use bitwise not instead of logical not #56

Closed ToruNiina closed 1 year ago

ToruNiina commented 1 year ago

Hi all, First of all, thank you for developing and maintaining this interesting project.

Some days ago, I found a suspicious part that seems to be a bug. The code actually does work, but not in an intended way I think. The mask reg in SwitchArbiter seems to be used to choose ports in serial order depending on the history. However, since logical not operator is used here instead of bitwise not, the type of inverted mask becomes Bool and masked flags will almost always be zero (or just one if mask === 0). So the PriorityEncoder effectively does not use the mask. This introduces unintended priority into the input ports and might decrease performance of some network path.

Could you check it when you have time? Thank you.

jerryz123 commented 1 year ago

Thanks for the catch!