From 8a8d52da4f2da4c01d40e54390eddd9b807f9724 Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Thu, 10 Sep 2015 17:32:40 -0700 Subject: [PATCH] add convenient constructors for NASTI channels --- junctions/src/main/scala/nasti.scala | 69 ++++++++++++++++++++++++++++ junctions/src/main/scala/smi.scala | 11 ++--- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/junctions/src/main/scala/nasti.scala b/junctions/src/main/scala/nasti.scala index bddf5b0e..26d198b9 100644 --- a/junctions/src/main/scala/nasti.scala +++ b/junctions/src/main/scala/nasti.scala @@ -113,6 +113,75 @@ class NASTIReadDataChannel extends NASTIResponseChannel with HasNASTIData { val user = UInt(width = nastiRUserBits) } +object NASTIWriteAddressChannel { + def apply(id: UInt, addr: UInt, size: UInt, len: UInt) = { + val aw = Wire(new NASTIWriteAddressChannel) + aw.id := id + aw.addr := addr + aw.len := len + aw.size := size + aw.burst := UInt("b01") + aw.lock := Bool(false) + aw.cache := UInt("b0000") + aw.prot := UInt("b000") + aw.qos := UInt("b0000") + aw.region := UInt("b0000") + aw.user := UInt(0) + aw + } +} + +object NASTIReadAddressChannel { + def apply(id: UInt, addr: UInt, size: UInt, len: UInt) = { + val ar = Wire(new NASTIReadAddressChannel) + ar.id := id + ar.addr := addr + ar.len := len + ar.size := size + ar.burst := UInt("b01") + ar.lock := Bool(false) + ar.cache := UInt(0) + ar.prot := UInt(0) + ar.qos := UInt(0) + ar.region := UInt(0) + ar.user := UInt(0) + ar + } +} + +object NASTIWriteDataChannel { + def apply(strb: UInt, data: UInt, last: Bool) = { + val w = Wire(new NASTIWriteDataChannel) + w.strb := strb + w.data := data + w.last := last + w.user := UInt(0) + w + } +} + +object NASTIReadDataChannel { + def apply(id: UInt, data: UInt, last: Bool, resp: UInt = UInt(0)) = { + val r = Wire(new NASTIReadDataChannel) + r.id := id + r.data := data + r.last := last + r.resp := resp + r.user := UInt(0) + r + } +} + +object NASTIWriteResponseChannel { + def apply(id: UInt, resp: UInt = UInt(0)) = { + val b = Wire(new NASTIWriteResponseChannel) + b.id := id + b.resp := resp + b.user := UInt(0) + b + } +} + class MemIONASTISlaveIOConverter(cacheBlockOffsetBits: Int) extends MIFModule with NASTIParameters { val io = new Bundle { val nasti = new NASTISlaveIO diff --git a/junctions/src/main/scala/smi.scala b/junctions/src/main/scala/smi.scala index f3495ccc..2b653bb3 100644 --- a/junctions/src/main/scala/smi.scala +++ b/junctions/src/main/scala/smi.scala @@ -121,10 +121,10 @@ class SMIIONASTIReadIOConverter(val dataWidth: Int, val addrWidth: Int) io.smi.resp.ready := (state === s_read) io.r.valid := (state === s_resp) - io.r.bits.resp := Bits(0) - io.r.bits.data := buffer.toBits - io.r.bits.id := id - io.r.bits.last := (nBeats === UInt(0)) + io.r.bits := NASTIReadDataChannel( + id = id, + data = buffer.toBits, + last = (nBeats === UInt(0))) when (io.ar.fire()) { when (io.ar.bits.size < UInt(byteOffBits)) { @@ -207,8 +207,7 @@ class SMIIONASTIWriteIOConverter(val dataWidth: Int, val addrWidth: Int) io.smi.req.bits.data := data(dataWidth - 1, 0) io.smi.resp.ready := (state === s_ack) io.b.valid := (state === s_resp) - io.b.bits.resp := Bits(0) - io.b.bits.id := id + io.b.bits := NASTIWriteResponseChannel(id) val jump = PriorityMux(strb(maxWordsPerBeat - 1, 1), (1 until maxWordsPerBeat).map(UInt(_)))