2012-02-26 02:09:26 +01:00
|
|
|
package rocket
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-10-08 05:15:54 +02:00
|
|
|
import Chisel._
|
2012-10-02 01:08:41 +02:00
|
|
|
import uncore._
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2013-08-12 19:39:11 +02:00
|
|
|
class HellaCacheArbiter(n: Int)(implicit conf: RocketConfiguration) extends Module
|
2012-10-08 22:06:45 +02:00
|
|
|
{
|
2012-11-06 08:52:32 +01:00
|
|
|
val io = new Bundle {
|
2013-08-12 19:39:11 +02:00
|
|
|
val requestor = Vec.fill(n){new HellaCacheIO()(conf.dcache)}.flip
|
2013-01-07 22:38:59 +01:00
|
|
|
val mem = new HellaCacheIO()(conf.dcache)
|
2012-11-06 08:52:32 +01:00
|
|
|
}
|
2012-10-08 22:06:45 +02:00
|
|
|
|
2013-08-16 00:28:15 +02:00
|
|
|
val r_valid = io.requestor.map(r => Reg(next=r.req.valid))
|
2012-11-06 17:13:44 +01:00
|
|
|
|
|
|
|
io.mem.req.valid := io.requestor.map(_.req.valid).reduce(_||_)
|
|
|
|
io.requestor(0).req.ready := io.mem.req.ready
|
|
|
|
for (i <- 1 until n)
|
|
|
|
io.requestor(i).req.ready := io.requestor(i-1).req.ready && !io.requestor(i-1).req.valid
|
|
|
|
|
|
|
|
io.mem.req.bits := io.requestor(n-1).req.bits
|
2013-08-12 19:39:11 +02:00
|
|
|
io.mem.req.bits.tag := Cat(io.requestor(n-1).req.bits.tag, UInt(n-1, log2Up(n)))
|
2012-11-06 17:13:44 +01:00
|
|
|
for (i <- n-2 to 0 by -1) {
|
|
|
|
val req = io.requestor(i).req
|
|
|
|
when (req.valid) {
|
|
|
|
io.mem.req.bits.cmd := req.bits.cmd
|
|
|
|
io.mem.req.bits.typ := req.bits.typ
|
|
|
|
io.mem.req.bits.addr := req.bits.addr
|
|
|
|
io.mem.req.bits.phys := req.bits.phys
|
2013-08-12 19:39:11 +02:00
|
|
|
io.mem.req.bits.tag := Cat(req.bits.tag, UInt(i, log2Up(n)))
|
2012-11-06 17:13:44 +01:00
|
|
|
}
|
|
|
|
when (r_valid(i)) {
|
|
|
|
io.mem.req.bits.kill := req.bits.kill
|
|
|
|
io.mem.req.bits.data := req.bits.data
|
|
|
|
}
|
2012-10-08 22:06:45 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 17:13:44 +01:00
|
|
|
for (i <- 0 until n) {
|
|
|
|
val resp = io.requestor(i).resp
|
2013-08-12 19:39:11 +02:00
|
|
|
val tag_hit = io.mem.resp.bits.tag(log2Up(n)-1,0) === UInt(i)
|
2012-11-06 17:13:44 +01:00
|
|
|
resp.valid := io.mem.resp.valid && tag_hit
|
|
|
|
io.requestor(i).xcpt := io.mem.xcpt
|
2013-09-15 07:34:53 +02:00
|
|
|
io.requestor(i).ordered := io.mem.ordered
|
2012-11-06 17:13:44 +01:00
|
|
|
resp.bits := io.mem.resp.bits
|
2013-08-12 19:39:11 +02:00
|
|
|
resp.bits.tag := io.mem.resp.bits.tag >> UInt(log2Up(n))
|
2012-11-16 11:39:33 +01:00
|
|
|
resp.bits.nack := io.mem.resp.bits.nack && tag_hit
|
2012-11-06 17:13:44 +01:00
|
|
|
resp.bits.replay := io.mem.resp.bits.replay && tag_hit
|
2014-01-14 13:02:43 +01:00
|
|
|
resp.bits.load_replay_next := io.mem.resp.bits.load_replay_next && tag_hit
|
2012-10-08 22:06:45 +02:00
|
|
|
}
|
|
|
|
}
|