1
0

move AtosConverterTest into UnitTestSuite

This commit is contained in:
Howard Mao 2016-02-23 16:42:19 -08:00
parent d19aaf8d89
commit ee66da603a
2 changed files with 129 additions and 136 deletions

View File

@ -1,135 +0,0 @@
package groundtest
import Chisel._
import junctions._
import junctions.StreamUtils._
import cde.Parameters
class AtosConverterTestFrontend(implicit p: Parameters) extends NastiModule()(p) {
val io = new Bundle {
val nasti = new NastiIO
val finished = Bool(OUTPUT)
}
val n_words = 4
val test_data = Vec.tabulate(n_words) { i => UInt(i * 48) }
val (s_idle :: s_waddr :: s_wdata :: s_wresp ::
s_raddr :: s_rresp :: s_done :: Nil) = Enum(Bits(), 7)
val state = Reg(init = s_idle)
when (state === s_idle) { state := s_waddr }
when (io.nasti.aw.fire()) { state := s_wdata }
when (io.nasti.w.fire() && io.nasti.w.bits.last) { state := s_wresp }
when (io.nasti.b.fire()) { state := s_raddr }
when (io.nasti.ar.fire()) { state := s_rresp }
when (io.nasti.r.fire() && io.nasti.r.bits.last) { state := s_done }
val (w_count, w_last) = Counter(io.nasti.w.fire(), n_words)
io.nasti.aw.valid := (state === s_waddr)
io.nasti.aw.bits := NastiWriteAddressChannel(
id = UInt(0),
addr = UInt(0),
size = UInt(log2Up(nastiXDataBits / 8)),
len = UInt(n_words - 1))
io.nasti.w.valid := (state === s_wdata)
io.nasti.w.bits := NastiWriteDataChannel(
data = test_data(w_count),
last = w_count === UInt(n_words - 1))
io.nasti.ar.valid := (state === s_raddr)
io.nasti.ar.bits := NastiReadAddressChannel(
id = UInt(0),
addr = UInt(0),
size = UInt(log2Up(nastiXDataBits / 8)),
len = UInt(n_words - 1))
io.nasti.b.ready := (state === s_wresp)
io.nasti.r.ready := (state === s_rresp)
io.finished := (state === s_done)
val (r_count, r_last) = Counter(io.nasti.r.fire(), n_words)
assert(!io.nasti.r.valid || io.nasti.r.bits.data === test_data(r_count),
"AtosConverterTest: returned data doesn't match expected")
}
class AtosConverterTestBackend(implicit p: Parameters) extends NastiModule()(p) {
val io = new Bundle {
val nasti = (new NastiIO).flip
val finished = Bool(OUTPUT)
}
val (s_waddr :: s_wdata :: s_wresp ::
s_raddr :: s_rresp :: s_done :: Nil) = Enum(Bits(), 6)
val state = Reg(init = s_waddr)
val n_words = 4
val test_data = Reg(Vec(n_words, UInt(width = nastiXDataBits)))
val req_id = Reg(UInt(width = nastiXIdBits))
val (w_count, w_last) = Counter(io.nasti.w.fire(), n_words)
val (r_count, r_last) = Counter(io.nasti.r.fire(), n_words)
when (io.nasti.aw.fire()) {
req_id := io.nasti.aw.bits.id
state := s_wdata
}
when (io.nasti.w.fire()) {
test_data(w_count) := io.nasti.w.bits.data
when (io.nasti.w.bits.last) { state := s_wresp }
}
when (io.nasti.b.fire()) { state := s_raddr }
when (io.nasti.ar.fire()) {
req_id := io.nasti.ar.bits.id
state := s_rresp
}
when (io.nasti.r.fire() && io.nasti.r.bits.last) { state := s_done }
io.nasti.aw.ready := (state === s_waddr)
io.nasti.w.ready := (state === s_wdata)
io.nasti.ar.ready := (state === s_raddr)
io.nasti.b.valid := (state === s_wresp)
io.nasti.b.bits := NastiWriteResponseChannel(id = req_id)
io.nasti.r.valid := (state === s_rresp)
io.nasti.r.bits := NastiReadDataChannel(
id = req_id,
data = test_data(r_count),
last = r_last)
io.finished := (state === s_done)
}
class AtosConverterTest(implicit p: Parameters) extends GroundTest()(p) {
disablePorts()
val frontend = Module(new AtosConverterTestFrontend)
val backend = Module(new AtosConverterTestBackend)
val fe_ser = Module(new Serializer(new AtosRequest))
val fe_des = Module(new Deserializer(new AtosResponse))
val be_des = Module(new Deserializer(new AtosRequest))
val be_ser = Module(new Serializer(new AtosResponse))
val client_conv = Module(new AtosClientConverter)
val manager_conv = Module(new AtosManagerConverter)
client_conv.io.nasti <> frontend.io.nasti
fe_ser.io.in <> client_conv.io.atos.req
client_conv.io.atos.resp <> fe_des.io.out
be_des.io.in <> fe_ser.io.out
fe_des.io.in <> be_ser.io.out
manager_conv.io.atos.req <> be_des.io.out
be_ser.io.in <> manager_conv.io.atos.resp
backend.io.nasti <> manager_conv.io.nasti
io.finished := frontend.io.finished && backend.io.finished
}

View File

@ -287,13 +287,141 @@ class TileLinkToSmiConverterTest(implicit p: Parameters) extends UnitTest {
io.finished := driver.io.finished
}
class AtosConverterTestFrontend(implicit p: Parameters) extends NastiModule()(p) {
val io = new Bundle {
val nasti = new NastiIO
val finished = Bool(OUTPUT)
}
val n_words = 4
val test_data = Vec.tabulate(n_words) { i => UInt(i * 48) }
val (s_idle :: s_waddr :: s_wdata :: s_wresp ::
s_raddr :: s_rresp :: s_done :: Nil) = Enum(Bits(), 7)
val state = Reg(init = s_idle)
when (state === s_idle) { state := s_waddr }
when (io.nasti.aw.fire()) { state := s_wdata }
when (io.nasti.w.fire() && io.nasti.w.bits.last) { state := s_wresp }
when (io.nasti.b.fire()) { state := s_raddr }
when (io.nasti.ar.fire()) { state := s_rresp }
when (io.nasti.r.fire() && io.nasti.r.bits.last) { state := s_done }
val (w_count, w_last) = Counter(io.nasti.w.fire(), n_words)
io.nasti.aw.valid := (state === s_waddr)
io.nasti.aw.bits := NastiWriteAddressChannel(
id = UInt(0),
addr = UInt(0),
size = UInt(log2Up(nastiXDataBits / 8)),
len = UInt(n_words - 1))
io.nasti.w.valid := (state === s_wdata)
io.nasti.w.bits := NastiWriteDataChannel(
data = test_data(w_count),
last = w_count === UInt(n_words - 1))
io.nasti.ar.valid := (state === s_raddr)
io.nasti.ar.bits := NastiReadAddressChannel(
id = UInt(0),
addr = UInt(0),
size = UInt(log2Up(nastiXDataBits / 8)),
len = UInt(n_words - 1))
io.nasti.b.ready := (state === s_wresp)
io.nasti.r.ready := (state === s_rresp)
io.finished := (state === s_done)
val (r_count, r_last) = Counter(io.nasti.r.fire(), n_words)
assert(!io.nasti.r.valid || io.nasti.r.bits.data === test_data(r_count),
"AtosConverterTest: returned data doesn't match expected")
}
class AtosConverterTestBackend(implicit p: Parameters) extends NastiModule()(p) {
val io = new Bundle {
val nasti = (new NastiIO).flip
val finished = Bool(OUTPUT)
}
val (s_waddr :: s_wdata :: s_wresp ::
s_raddr :: s_rresp :: s_done :: Nil) = Enum(Bits(), 6)
val state = Reg(init = s_waddr)
val n_words = 4
val test_data = Reg(Vec(n_words, UInt(width = nastiXDataBits)))
val req_id = Reg(UInt(width = nastiXIdBits))
val (w_count, w_last) = Counter(io.nasti.w.fire(), n_words)
val (r_count, r_last) = Counter(io.nasti.r.fire(), n_words)
when (io.nasti.aw.fire()) {
req_id := io.nasti.aw.bits.id
state := s_wdata
}
when (io.nasti.w.fire()) {
test_data(w_count) := io.nasti.w.bits.data
when (io.nasti.w.bits.last) { state := s_wresp }
}
when (io.nasti.b.fire()) { state := s_raddr }
when (io.nasti.ar.fire()) {
req_id := io.nasti.ar.bits.id
state := s_rresp
}
when (io.nasti.r.fire() && io.nasti.r.bits.last) { state := s_done }
io.nasti.aw.ready := (state === s_waddr)
io.nasti.w.ready := (state === s_wdata)
io.nasti.ar.ready := (state === s_raddr)
io.nasti.b.valid := (state === s_wresp)
io.nasti.b.bits := NastiWriteResponseChannel(id = req_id)
io.nasti.r.valid := (state === s_rresp)
io.nasti.r.bits := NastiReadDataChannel(
id = req_id,
data = test_data(r_count),
last = r_last)
io.finished := (state === s_done)
}
class AtosConverterTest(implicit p: Parameters) extends UnitTest {
val frontend = Module(new AtosConverterTestFrontend)
val backend = Module(new AtosConverterTestBackend)
val fe_ser = Module(new Serializer(new AtosRequest))
val fe_des = Module(new Deserializer(new AtosResponse))
val be_des = Module(new Deserializer(new AtosRequest))
val be_ser = Module(new Serializer(new AtosResponse))
val client_conv = Module(new AtosClientConverter)
val manager_conv = Module(new AtosManagerConverter)
client_conv.io.nasti <> frontend.io.nasti
fe_ser.io.in <> client_conv.io.atos.req
client_conv.io.atos.resp <> fe_des.io.out
be_des.io.in <> fe_ser.io.out
fe_des.io.in <> be_ser.io.out
manager_conv.io.atos.req <> be_des.io.out
be_ser.io.in <> manager_conv.io.atos.resp
backend.io.nasti <> manager_conv.io.nasti
io.finished := frontend.io.finished && backend.io.finished
}
class UnitTestSuite(implicit p: Parameters) extends GroundTest()(p) {
disablePorts()
val tests = Seq(
Module(new MultiWidthFifoTest),
Module(new NastiIOHostIOConverterTest),
Module(new TileLinkToSmiConverterTest))
Module(new TileLinkToSmiConverterTest),
Module(new AtosConverterTest))
val s_idle :: s_start :: s_wait :: Nil = Enum(Bits(), 3)
val state = Reg(init = s_idle)