1
0

make unit test debug output more meaningful

This commit is contained in:
Howard Mao 2016-07-15 15:40:11 -07:00
parent def740406c
commit 3ea299b062

View File

@ -15,6 +15,10 @@ abstract class UnitTest extends Module {
val finished = Bool(OUTPUT)
val start = Bool(INPUT)
}
when (io.start) {
printf(s"Started UnitTest ${this.getClass.getName}\n")
}
}
case object UnitTests extends Field[Parameters => Seq[UnitTest]]
@ -22,22 +26,30 @@ case object UnitTests extends Field[Parameters => Seq[UnitTest]]
class UnitTestSuite(implicit p: Parameters) extends GroundTest()(p) {
val tests = p(UnitTests)(p)
val s_idle :: s_start :: s_wait :: Nil = Enum(Bits(), 3)
val s_idle :: s_start :: s_wait :: s_done :: Nil = Enum(Bits(), 4)
val state = Reg(init = s_idle)
val test_idx = Reg(init = UInt(0, log2Up(tests.size)))
val test_finished = Vec(tests.map(_.io.finished))
when (state === s_idle) { state := s_start }
when (state === s_start) { state := s_wait }
when (state === s_wait && test_finished(test_idx)) {
state := s_start
test_idx := test_idx + UInt(1)
state := Mux(test_idx === UInt(tests.size - 1), s_done, s_start)
}
io.status.timeout.valid := Bool(false)
tests.zipWithIndex.foreach { case (mod, i) =>
mod.io.start := (state === s_start)
mod.io.start := (state === s_start) && test_idx === UInt(i)
val timeout = Timer(1000, mod.io.start, mod.io.finished)
assert(!timeout, s"UnitTest $i timed out")
assert(!timeout, s"UnitTest ${mod.getClass.getName} timed out")
when (timeout) {
io.status.timeout.valid := Bool(true)
io.status.timeout.bits := UInt(i)
}
}
io.status.finished := tests.map(_.io.finished).reduce(_ && _)
io.status.finished := (state === s_done)
io.status.error.valid := Bool(false)
}