test AtoS conversions and SERDES
This commit is contained in:
parent
d5153bf42e
commit
d19aaf8d89
135
groundtest/src/main/scala/atostest.scala
Normal file
135
groundtest/src/main/scala/atostest.scala
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user