From e6c1bcfedd844f717827dcd5d09cf954d57894c5 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 19 Sep 2016 15:54:17 -0700 Subject: [PATCH] Expose carry-out bits from WideCounter --- src/main/scala/rocket/util.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/scala/rocket/util.scala b/src/main/scala/rocket/util.scala index e40da39a..a311364a 100644 --- a/src/main/scala/rocket/util.scala +++ b/src/main/scala/rocket/util.scala @@ -137,11 +137,18 @@ case class WideCounter(width: Int, inc: UInt = UInt(1), reset: Boolean = true) private val large = if (isWide) { val r = if (reset) Reg(init=UInt(0, width - smallWidth)) else Reg(UInt(width = width - smallWidth)) - when (nextSmall(smallWidth)) { r := r + UInt(1) } + when (nextSmall(smallWidth)) { r := r +& UInt(1) } r } else null val value = if (isWide) Cat(large, small) else small + lazy val carryOut = { + val lo = (small ^ nextSmall) >> 1 + if (!isWide) lo else { + val hi = Mux(nextSmall(smallWidth), large ^ (large +& UInt(1)), UInt(0)) >> 1 + Cat(hi, lo) + } + } def := (x: UInt) = { small := x