1
0

add multi-transaction timer and add to Comparator

This commit is contained in:
Howard Mao 2016-06-30 17:39:10 -07:00
parent e83b3d2472
commit f46efb671d
2 changed files with 28 additions and 15 deletions

View File

@ -283,6 +283,13 @@ class ComparatorClient(val target: Long)(implicit val p: Parameters) extends Mod
val (idx, acq_done) = Counter(
io.tl.acquire.fire() && io.tl.acquire.bits.first(), nOperations)
debug(idx)
val timer = Module(new Timer(8192, xacts))
timer.io.start.valid := io.tl.acquire.fire() && io.tl.acquire.bits.first()
timer.io.start.bits := xact_id
timer.io.stop.valid := io.tl.grant.fire() && io.tl.grant.bits.first()
timer.io.stop.bits := io.tl.grant.bits.client_xact_id
assert(!timer.io.timeout, "Comparator TL client timed out")
}
class ComparatorSink(implicit val p: Parameters) extends Module

View File

@ -7,36 +7,42 @@ import Chisel._
// ============
// Timer with a statically-specified period.
// Can take multiple inflight start-stop events with ID
// Will continue to count down so long as at least one inflight event
class Timer(initCount: Int) extends Module {
class Timer(initCount: Int, maxInflight: Int) extends Module {
val io = new Bundle {
val start = Bool(INPUT)
val stop = Bool(INPUT)
val start = Valid(UInt(width = log2Up(maxInflight))).flip
val stop = Valid(UInt(width = log2Up(maxInflight))).flip
val timeout = Bool(OUTPUT)
}
val inflight = Reg(init = Vec.fill(maxInflight) { Bool(false) })
val countdown = Reg(UInt(width = log2Up(initCount)))
val active = Reg(init = Bool(false))
val active = inflight.reduce(_ || _)
when (io.start) {
countdown := UInt(initCount - 1)
active := Bool(true)
}
.elsewhen (io.stop) {
active := Bool(false)
}
.elsewhen (active) {
when (active) {
countdown := countdown - UInt(1)
}
when (io.start.valid) {
inflight(io.start.bits) := Bool(true)
countdown := UInt(initCount - 1)
}
when (io.stop.valid) {
inflight(io.stop.bits) := Bool(false)
}
io.timeout := countdown === UInt(0) && active
}
object Timer {
def apply(initCount: Int, start: Bool, stop: Bool): Bool = {
val timer = Module(new Timer(initCount))
timer.io.start := start
timer.io.stop := stop
val timer = Module(new Timer(initCount, 1))
timer.io.start.valid := start
timer.io.start.bits := UInt(0)
timer.io.stop.valid := stop
timer.io.stop.bits := UInt(0)
timer.io.timeout
}
}