1
0
rocket-chip/uncore/src/main/scala/scr.scala

43 lines
1.2 KiB
Scala
Raw Normal View History

2015-09-01 23:47:18 +02:00
package uncore
import Chisel._
2016-01-12 01:18:44 +01:00
import junctions.{SmiIO, MMIOBase}
2015-10-22 03:16:44 +02:00
import cde.Parameters
2015-09-01 23:47:18 +02:00
2015-10-06 06:41:46 +02:00
class SCRIO(implicit p: Parameters) extends HtifBundle()(p) {
2016-01-14 22:47:47 +01:00
val rdata = Vec(nSCR, Bits(INPUT, scrDataBits))
2015-09-01 23:47:18 +02:00
val wen = Bool(OUTPUT)
val waddr = UInt(OUTPUT, log2Up(nSCR))
2015-10-06 06:41:46 +02:00
val wdata = Bits(OUTPUT, scrDataBits)
2015-09-01 23:47:18 +02:00
}
2015-10-06 06:41:46 +02:00
class SCRFile(implicit p: Parameters) extends HtifModule()(p) {
2015-09-01 23:47:18 +02:00
val io = new Bundle {
2016-01-12 01:18:44 +01:00
val smi = new SmiIO(scrDataBits, scrAddrBits).flip
2015-09-01 23:47:18 +02:00
val scr = new SCRIO
}
2016-01-14 22:47:47 +01:00
val scr_rdata = Wire(Vec(io.scr.rdata.size, Bits(width=scrDataBits)))
2015-09-01 23:47:18 +02:00
for (i <- 0 until scr_rdata.size)
scr_rdata(i) := io.scr.rdata(i)
scr_rdata(0) := UInt(nCores)
2015-10-06 06:41:46 +02:00
scr_rdata(1) := UInt(p(MMIOBase) >> 20)
2015-09-01 23:47:18 +02:00
val read_addr = Reg(init = UInt(0, scrAddrBits))
val resp_valid = Reg(init = Bool(false))
io.smi.req.ready := !resp_valid
io.smi.resp.valid := resp_valid
io.smi.resp.bits := scr_rdata(read_addr)
io.scr.wen := io.smi.req.fire() && io.smi.req.bits.rw
io.scr.wdata := io.smi.req.bits.data
io.scr.waddr := io.smi.req.bits.addr
when (io.smi.req.fire()) {
read_addr := io.smi.req.bits.addr
resp_valid := Bool(true)
}
when (io.smi.resp.fire()) { resp_valid := Bool(false) }
}