circt icon indicating copy to clipboard operation
circt copied to clipboard

[HWArith] Implement remaining operators

Open mortbopet opened this issue 3 years ago • 3 comments
trafficstars

This issue serves as a tracking commit for implementing the remaining operations in hwarith

  • [ ] hwarith.shl
  • [ ] hwarith.shr (sign extending on si and zero extending on ui)
  • [x] Comparison operators <,>,==,<=,>=.
  • [x] Casting:
    • between signed, unsigned, and signless,
    • truncation/extension)

mortbopet avatar Jul 18 '22 11:07 mortbopet

For shr and shl, how would they differ from the existing comb operators?

teqdruid avatar Jul 18 '22 18:07 teqdruid

For shr and shl, how would they differ from the existing comb operators?

I think the main reason for having hwarith shifts is that the comb operators don't accept the ui/si types, so in order to use them inside hwarith land, you'd have to cast operands and results all the time.

Also, in hwarith, we only need one op for the right shift, the operands may have different bitwidths, and we have to discuss what happens in case the shift amount is a negative value.

jopperm avatar Jul 20 '22 07:07 jopperm

Regarding negative (signed) shift amount operands, I would approach this in a pragmatic way. Unless/until someone find an issue with this, I’d take the approach of Chisel, wherein the shift amount must be an unsigned value – simplifies rules, understanding, and lowering. If shifting with a signed shift amount is needed, I’d expect a user (or a front-end) to decide the semantics of that.

mortbopet avatar Aug 01 '22 07:08 mortbopet