This implements saturating addition/subtraction with inferred widths.
The problem is that you need to know the width of a number to be able to implement saturating add/sub. If the width is inferred, the frontend can't know what the max and min are.
To deal with this, we implement a pass that inserts a dummy operation with the right width inference behavior. This dummy operation is used in by FIRRTL for width inference, and then a later pass comes in and removes the dummy operation, replacing it with a saturating add/sub
implementation.
FixedPoint and Interval support depend on this FIRRTL PR. This is because width inference and FixedPoint/Interval lowering both occur in the High->Mid stage of the compiler. This PR also depends somewhat on resolving this chisel issue because the dummy op would ideally be a +% b for FixedPoint, which is broken.
This implements saturating addition/subtraction with inferred widths.
The problem is that you need to know the width of a number to be able to implement saturating add/sub. If the width is inferred, the frontend can't know what the max and min are.
To deal with this, we implement a pass that inserts a dummy operation with the right width inference behavior. This dummy operation is used in by FIRRTL for width inference, and then a later pass comes in and removes the dummy operation, replacing it with a saturating add/sub implementation.
FixedPoint
andInterval
support depend on this FIRRTL PR. This is because width inference andFixedPoint
/Interval
lowering both occur in the High->Mid stage of the compiler. This PR also depends somewhat on resolving this chisel issue because the dummy op would ideally bea +% b
forFixedPoint
, which is broken.