1
0

fix serializer/deserializer and add Atos serdes/desser

This commit is contained in:
Howard Mao 2016-02-24 21:33:51 -08:00
parent d66d8f0cd4
commit 1dc8af894e
2 changed files with 52 additions and 11 deletions

View File

@ -96,7 +96,7 @@ class AtosRequest(implicit p: Parameters)
def is_last(dummy: Int = 0) =
typ === AtosRequest.arType || (typ === AtosRequest.wType && last())
def nbytes: Int = atosRequestBytes
def nbits: Int = atosRequestBits
def resp_len(dummy: Int = 0) =
MuxLookup(typ, UInt(0), Seq(
@ -138,7 +138,7 @@ class AtosResponse(implicit p: Parameters)
def is_last(dummy: Int = 0) = !has_data() || last
def nbytes: Int = atosResponseBytes
def nbits: Int = atosResponseBits
}
class AtosIO(implicit p: Parameters) extends AtosBundle()(p) {
@ -289,3 +289,39 @@ class AtosManagerConverter(implicit p: Parameters) extends AtosModule()(p) {
resp_enc.io.b <> io.nasti.b
resp_enc.io.r <> io.nasti.r
}
class AtosSerializedIO(w: Int)(implicit p: Parameters) extends ParameterizedBundle()(p) {
val req = Decoupled(Bits(width = w))
val resp = Decoupled(Bits(width = w)).flip
override def cloneType = new AtosSerializedIO(w)(p).asInstanceOf[this.type]
}
class AtosSerdes(w: Int)(implicit p: Parameters) extends AtosModule()(p) {
val io = new Bundle {
val wide = (new AtosIO).flip
val narrow = new AtosSerializedIO(w)
}
val ser = Module(new Serializer(w, new AtosRequest))
ser.io.in <> io.wide.req
io.narrow.req <> ser.io.out
val des = Module(new Deserializer(w, new AtosResponse))
des.io.in <> io.narrow.resp
io.wide.resp <> des.io.out
}
class AtosDesser(w: Int)(implicit p: Parameters) extends AtosModule()(p) {
val io = new Bundle {
val narrow = new AtosSerializedIO(w).flip
val wide = new AtosIO
}
val des = Module(new Deserializer(w, new AtosRequest))
des.io.in <> io.narrow.req
io.wide.req <> des.io.out
val ser = Module(new Serializer(w, new AtosResponse))
ser.io.in <> io.wide.resp
io.narrow.resp <> ser.io.out
}

View File

@ -151,31 +151,36 @@ object StreamUtils {
}
trait Serializable {
def nbytes: Int
def nbits: Int
}
class Serializer[T <: Data with Serializable](typ: T) extends Module {
class Serializer[T <: Data with Serializable](w: Int, typ: T) extends Module {
val io = new Bundle {
val in = Decoupled(typ).flip
val out = Decoupled(new StreamChannel(8))
val out = Decoupled(Bits(width = w))
}
val narrower = Module(new StreamNarrower(typ.nbytes * 8, 8))
val narrower = Module(new StreamNarrower(typ.nbits, w))
narrower.io.in.bits.data := io.in.bits.toBits
narrower.io.in.bits.last := Bool(true)
narrower.io.in.valid := io.in.valid
io.in.ready := narrower.io.in.ready
io.out <> narrower.io.out
io.out.valid := narrower.io.out.valid
io.out.bits := narrower.io.out.bits.data
narrower.io.out.ready := io.out.ready
}
class Deserializer[T <: Data with Serializable](typ: T) extends Module {
class Deserializer[T <: Data with Serializable](w: Int, typ: T) extends Module {
val io = new Bundle {
val in = Decoupled(new StreamChannel(8)).flip
val in = Decoupled(Bits(width = w)).flip
val out = Decoupled(typ)
}
val expander = Module(new StreamExpander(8, 8 * typ.nbytes))
expander.io.in <> io.in
val expander = Module(new StreamExpander(w, typ.nbits))
expander.io.in.valid := io.in.valid
expander.io.in.bits.data := io.in.bits
expander.io.in.bits.last := Bool(true)
io.in.ready := expander.io.in.ready
io.out.valid := expander.io.out.valid
io.out.bits := typ.cloneType.fromBits(expander.io.out.bits.data)
expander.io.out.ready := io.out.ready