fix SMI converter
This commit is contained in:
		@@ -113,7 +113,6 @@ class SmiIONastiReadIOConverter(val dataWidth: Int, val addrWidth: Int)
 | 
				
			|||||||
  val id = Reg(UInt(width = nastiRIdBits))
 | 
					  val id = Reg(UInt(width = nastiRIdBits))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val byteOff = Reg(UInt(width = byteOffBits))
 | 
					  val byteOff = Reg(UInt(width = byteOffBits))
 | 
				
			||||||
  val sendInd = Reg(init = UInt(0, wordCountBits))
 | 
					 | 
				
			||||||
  val recvInd = Reg(init = UInt(0, wordCountBits))
 | 
					  val recvInd = Reg(init = UInt(0, wordCountBits))
 | 
				
			||||||
  val sendDone = Reg(init = Bool(false))
 | 
					  val sendDone = Reg(init = Bool(false))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -136,32 +135,30 @@ class SmiIONastiReadIOConverter(val dataWidth: Int, val addrWidth: Int)
 | 
				
			|||||||
  when (io.ar.fire()) {
 | 
					  when (io.ar.fire()) {
 | 
				
			||||||
    when (io.ar.bits.size < UInt(byteOffBits)) {
 | 
					    when (io.ar.bits.size < UInt(byteOffBits)) {
 | 
				
			||||||
      nWords := UInt(0)
 | 
					      nWords := UInt(0)
 | 
				
			||||||
      byteOff := io.ar.bits.addr(byteOffBits - 1, 0)
 | 
					 | 
				
			||||||
    } .otherwise {
 | 
					    } .otherwise {
 | 
				
			||||||
      nWords := calcWordCount(io.ar.bits.size)
 | 
					      nWords := calcWordCount(io.ar.bits.size)
 | 
				
			||||||
      byteOff := UInt(0)
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    nBeats := io.ar.bits.len
 | 
					    nBeats := io.ar.bits.len
 | 
				
			||||||
    addr := io.ar.bits.addr(addrOffBits - 1, byteOffBits)
 | 
					    addr := io.ar.bits.addr(addrOffBits - 1, byteOffBits)
 | 
				
			||||||
 | 
					    recvInd := io.ar.bits.addr(wordCountBits + byteOffBits - 1, byteOffBits)
 | 
				
			||||||
    id := io.ar.bits.id
 | 
					    id := io.ar.bits.id
 | 
				
			||||||
    state := s_read
 | 
					    state := s_read
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  when (io.smi.req.fire()) {
 | 
					  when (io.smi.req.fire()) {
 | 
				
			||||||
    addr := addr + UInt(1)
 | 
					    addr := addr + UInt(1)
 | 
				
			||||||
    sendInd := sendInd + UInt(1)
 | 
					    sendDone := (nWords === UInt(0))
 | 
				
			||||||
    sendDone := (sendInd === nWords)
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  when (io.smi.resp.fire()) {
 | 
					  when (io.smi.resp.fire()) {
 | 
				
			||||||
    recvInd := recvInd + UInt(1)
 | 
					    recvInd := recvInd + UInt(1)
 | 
				
			||||||
    buffer(recvInd) := io.smi.resp.bits >> Cat(byteOff, UInt(0, 3))
 | 
					    nWords := nWords - UInt(1)
 | 
				
			||||||
    when (recvInd === nWords) { state := s_resp }
 | 
					    buffer(recvInd) := io.smi.resp.bits
 | 
				
			||||||
 | 
					    when (nWords === UInt(0)) { state := s_resp }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  when (io.r.fire()) {
 | 
					  when (io.r.fire()) {
 | 
				
			||||||
    recvInd := UInt(0)
 | 
					    recvInd := UInt(0)
 | 
				
			||||||
    sendInd := UInt(0)
 | 
					 | 
				
			||||||
    sendDone := Bool(false)
 | 
					    sendDone := Bool(false)
 | 
				
			||||||
    // clear all the registers in the buffer
 | 
					    // clear all the registers in the buffer
 | 
				
			||||||
    buffer.foreach(_ := Bits(0))
 | 
					    buffer.foreach(_ := Bits(0))
 | 
				
			||||||
@@ -183,19 +180,19 @@ class SmiIONastiWriteIOConverter(val dataWidth: Int, val addrWidth: Int)
 | 
				
			|||||||
  private val maxWordsPerBeat = nastiXDataBits / dataWidth
 | 
					  private val maxWordsPerBeat = nastiXDataBits / dataWidth
 | 
				
			||||||
  private val byteOffBits = log2Floor(dataBytes)
 | 
					  private val byteOffBits = log2Floor(dataBytes)
 | 
				
			||||||
  private val addrOffBits = addrWidth + byteOffBits
 | 
					  private val addrOffBits = addrWidth + byteOffBits
 | 
				
			||||||
 | 
					  private val nastiByteOffBits = log2Ceil(nastiXDataBits / 8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  assert(!io.aw.valid || io.aw.bits.size >= UInt(byteOffBits),
 | 
					  assert(!io.aw.valid || io.aw.bits.size >= UInt(byteOffBits),
 | 
				
			||||||
    "Nasti size must be >= Smi size")
 | 
					    "Nasti size must be >= Smi size")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val id = Reg(UInt(width = nastiWIdBits))
 | 
					  val id = Reg(UInt(width = nastiWIdBits))
 | 
				
			||||||
  val addr = Reg(UInt(width = addrWidth))
 | 
					  val addr = Reg(UInt(width = addrWidth))
 | 
				
			||||||
 | 
					  val offset = Reg(UInt(width = nastiByteOffBits))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def makeStrobe(size: UInt, strb: UInt) = {
 | 
					  def makeStrobe(offset: UInt, size: UInt, strb: UInt) = {
 | 
				
			||||||
    val sizemask = (UInt(1) << (UInt(1) << size)) - UInt(1)
 | 
					    val sizemask = (UInt(1) << (UInt(1) << size)) - UInt(1)
 | 
				
			||||||
    val bytemask = sizemask & strb
 | 
					    val bytemask = strb & (sizemask << offset)
 | 
				
			||||||
    Vec.tabulate(maxWordsPerBeat){i => bytemask(dataBytes * i)}.toBits
 | 
					    Vec.tabulate(maxWordsPerBeat){i => bytemask(dataBytes * i)}.toBits
 | 
				
			||||||
    //val strbmask = Vec.tabulate(maxWordsPerBeat){i => strb(dataBytes * i)}.toBits
 | 
					 | 
				
			||||||
    //sizemask & strbmask
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val size = Reg(UInt(width = nastiXSizeBits))
 | 
					  val size = Reg(UInt(width = nastiXSizeBits))
 | 
				
			||||||
@@ -222,7 +219,13 @@ class SmiIONastiWriteIOConverter(val dataWidth: Int, val addrWidth: Int)
 | 
				
			|||||||
    else UInt(1)
 | 
					    else UInt(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  when (io.aw.fire()) {
 | 
					  when (io.aw.fire()) {
 | 
				
			||||||
 | 
					    if (dataWidth == nastiXDataBits) {
 | 
				
			||||||
      addr := io.aw.bits.addr(addrOffBits - 1, byteOffBits)
 | 
					      addr := io.aw.bits.addr(addrOffBits - 1, byteOffBits)
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      addr := Cat(io.aw.bits.addr(addrOffBits - 1, nastiByteOffBits),
 | 
				
			||||||
 | 
					                  UInt(0, nastiByteOffBits - byteOffBits))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    offset := io.aw.bits.addr(nastiByteOffBits - 1, 0)
 | 
				
			||||||
    id := io.aw.bits.id
 | 
					    id := io.aw.bits.id
 | 
				
			||||||
    size := io.aw.bits.size
 | 
					    size := io.aw.bits.size
 | 
				
			||||||
    last := Bool(false)
 | 
					    last := Bool(false)
 | 
				
			||||||
@@ -231,7 +234,7 @@ class SmiIONastiWriteIOConverter(val dataWidth: Int, val addrWidth: Int)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  when (io.w.fire()) {
 | 
					  when (io.w.fire()) {
 | 
				
			||||||
    last := io.w.bits.last
 | 
					    last := io.w.bits.last
 | 
				
			||||||
    strb := makeStrobe(size, io.w.bits.strb)
 | 
					    strb := makeStrobe(offset, size, io.w.bits.strb)
 | 
				
			||||||
    data := io.w.bits.data
 | 
					    data := io.w.bits.data
 | 
				
			||||||
    state := s_send
 | 
					    state := s_send
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -259,7 +262,9 @@ class SmiIONastiIOConverter(val dataWidth: Int, val addrWidth: Int)
 | 
				
			|||||||
    val smi = new SmiIO(dataWidth, addrWidth)
 | 
					    val smi = new SmiIO(dataWidth, addrWidth)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  require(isPow2(dataWidth), "Smi data width must be power of 2")
 | 
					  require(isPow2(dataWidth), "SMI data width must be power of 2")
 | 
				
			||||||
 | 
					  require(dataWidth <= nastiXDataBits,
 | 
				
			||||||
 | 
					    "SMI data width must be less than or equal to NASTI data width")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val reader = Module(new SmiIONastiReadIOConverter(dataWidth, addrWidth))
 | 
					  val reader = Module(new SmiIONastiReadIOConverter(dataWidth, addrWidth))
 | 
				
			||||||
  reader.io.ar <> io.nasti.ar
 | 
					  reader.io.ar <> io.nasti.ar
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user