chipsalliance / firrtl-spec

The specification for the FIRRTL language
38 stars 27 forks source link

Missing specification of how bit numbers are determined #197

Open programmerjake opened 5 months ago

programmerjake commented 5 months ago

the FIRRTL specification doesn't specify how to determine if bits(UInt<8>(0hF0), 3, 0) returns 0hF or 0h0 -- specifying this is needed because some significant specifications (the PowerISA specification in particular) counts bits starting from 0 at the MSB end and counting up to the LSB end, and most others count bits starting from 0 at the LSB end, though I expect some start counting at 1.

mmaloney-sf commented 5 months ago

Thanks for the report.

To be sure, we label the LSB as bit 0 and the MSB as width - 1. The bits primop is inclusive on both sides.

That's interesting to hear that PowerISA does it as it does. We can add verbiage to make the convention we use explicit.

mmaloney-sf commented 5 months ago

Just as a note to myself (or anyone who snipes the issue from me), this note is probably best given as a language-wide convention, rather than a footnote on bits (although we should crossreference it wherever we make use of it).

darthscsi commented 5 months ago

the PowerISA specification in particular

And to be clear, this is a separate issue from endian, which refers to the storage (in memory) ordering of Bytes of a word. In-register operations do not depend on the endian.

darthscsi commented 5 months ago

Which is to say, please don't use "endian' to describe the bit ordering in firrtl. Also, 1.3.2 of the Power spec for those curious to check and it's weird when numerically equivalent words of different sizes have their common bits in different numerical positions.

mmaloney-sf commented 5 months ago

I was under the impression that the One True meaning of "endian" was from which end you ate your boiled eggs.