// Retains significant digits while dividing
override def div2(a: Interval, n: Int): Interval = {
require(a.widthKnown, "Interval point width must be known for div2")
require(a.binaryPoint.known, "Binary point must be known for div2")
val newBP = a.binaryPoint.get + n
// Normal shift loses significant digits; this version doesn't
val inLong = Wire(Interval((a.getWidth + n).W, newBP.BP))
inLong := a
val outFull = Wire(Interval(a.getWidth.W, newBP.BP))
// Upper n bits don't contain meaningful data following shift, so remove
outFull := inLong >> n
// Note: The above doesn't rely on tools to expand, shrink correctly; the version below does.
// Assumes setBinaryPoint zero-extends. BUT Chisel doesn't seem to get widths properly and
// some other ops rely on width correctness... (even though Firrtl is right...)
//a.setBinaryPoint(newBP) >> n
trimBinary(outFull, Some(a.binaryPoint.get + context.binaryPointGrowth))
}
Note comment in IntervalTypeClass