2012-02-26 02:09:26 +01:00
|
|
|
package rocket
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
import Chisel._;
|
|
|
|
import Node._;
|
|
|
|
import Constants._;
|
|
|
|
|
2012-03-06 09:31:44 +01:00
|
|
|
class ioUncachedRequestor extends Bundle {
|
2012-06-07 03:22:56 +02:00
|
|
|
val xact_init = (new FIFOIO) { new TransactionInit }
|
|
|
|
val xact_abort = (new FIFOIO) { new TransactionAbort }.flip
|
2012-07-18 07:55:00 +02:00
|
|
|
val xact_rep = (new FIFOIO) { new TransactionReply }.flip
|
2012-06-07 03:22:56 +02:00
|
|
|
val xact_finish = (new FIFOIO) { new TransactionFinish }
|
2012-03-06 09:31:44 +01:00
|
|
|
}
|
|
|
|
|
2012-02-20 09:51:48 +01:00
|
|
|
class rocketMemArbiter(n: Int) extends Component {
|
2012-02-29 12:08:04 +01:00
|
|
|
val io = new Bundle {
|
2012-03-06 09:31:44 +01:00
|
|
|
val mem = new ioUncachedRequestor
|
2012-04-03 21:03:05 +02:00
|
|
|
val requestor = Vec(n) { new ioUncachedRequestor }.flip
|
2012-02-29 12:08:04 +01:00
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-03-06 09:31:44 +01:00
|
|
|
var xi_val = Bool(false)
|
|
|
|
var xi_rdy = io.mem.xact_init.ready
|
2012-02-20 09:51:48 +01:00
|
|
|
for (i <- 0 until n)
|
|
|
|
{
|
2012-03-06 09:31:44 +01:00
|
|
|
io.requestor(i).xact_init.ready := xi_rdy
|
|
|
|
xi_val = xi_val || io.requestor(i).xact_init.valid
|
|
|
|
xi_rdy = xi_rdy && !io.requestor(i).xact_init.valid
|
2012-02-20 09:51:48 +01:00
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-05-24 19:33:15 +02:00
|
|
|
var xi_bits = new TransactionInit
|
2012-03-06 09:31:44 +01:00
|
|
|
xi_bits := io.requestor(n-1).xact_init.bits
|
2012-06-06 21:47:17 +02:00
|
|
|
xi_bits.tile_xact_id := Cat(io.requestor(n-1).xact_init.bits.tile_xact_id, UFix(n-1, log2Up(n)))
|
2012-03-06 09:31:44 +01:00
|
|
|
for (i <- n-2 to 0 by -1)
|
2012-02-29 03:59:15 +01:00
|
|
|
{
|
2012-05-24 19:33:15 +02:00
|
|
|
var my_xi_bits = new TransactionInit
|
2012-03-06 09:31:44 +01:00
|
|
|
my_xi_bits := io.requestor(i).xact_init.bits
|
2012-06-06 21:47:17 +02:00
|
|
|
my_xi_bits.tile_xact_id := Cat(io.requestor(i).xact_init.bits.tile_xact_id, UFix(i, log2Up(n)))
|
2012-03-06 09:31:44 +01:00
|
|
|
|
|
|
|
xi_bits = Mux(io.requestor(i).xact_init.valid, my_xi_bits, xi_bits)
|
2012-02-29 03:59:15 +01:00
|
|
|
}
|
|
|
|
|
2012-03-06 09:31:44 +01:00
|
|
|
io.mem.xact_init.valid := xi_val
|
|
|
|
io.mem.xact_init.bits := xi_bits
|
2012-02-29 12:08:04 +01:00
|
|
|
|
2012-03-06 09:31:44 +01:00
|
|
|
var xf_val = Bool(false)
|
|
|
|
var xf_rdy = io.mem.xact_finish.ready
|
|
|
|
for (i <- 0 until n)
|
|
|
|
{
|
|
|
|
io.requestor(i).xact_finish.ready := xf_rdy
|
|
|
|
xf_val = xf_val || io.requestor(i).xact_finish.valid
|
|
|
|
xf_rdy = xf_rdy && !io.requestor(i).xact_finish.valid
|
2012-02-20 09:51:48 +01:00
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-03-06 09:31:44 +01:00
|
|
|
var xf_bits = io.requestor(n-1).xact_finish.bits
|
2012-02-29 12:08:04 +01:00
|
|
|
for (i <- n-2 to 0 by -1)
|
2012-03-06 09:31:44 +01:00
|
|
|
xf_bits = Mux(io.requestor(i).xact_finish.valid, io.requestor(i).xact_finish.bits, xf_bits)
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2012-03-06 09:31:44 +01:00
|
|
|
io.mem.xact_finish.valid := xf_val
|
|
|
|
io.mem.xact_finish.bits := xf_bits
|
2012-02-29 03:59:15 +01:00
|
|
|
|
2012-02-20 09:51:48 +01:00
|
|
|
for (i <- 0 until n)
|
|
|
|
{
|
2012-02-29 12:08:04 +01:00
|
|
|
val tag = io.mem.xact_rep.bits.tile_xact_id
|
2012-06-06 21:47:17 +02:00
|
|
|
io.requestor(i).xact_rep.valid := io.mem.xact_rep.valid && tag(log2Up(n)-1,0) === UFix(i)
|
2012-03-06 09:31:44 +01:00
|
|
|
io.requestor(i).xact_rep.bits := io.mem.xact_rep.bits
|
2012-06-06 21:47:17 +02:00
|
|
|
io.requestor(i).xact_rep.bits.tile_xact_id := tag >> UFix(log2Up(n))
|
2012-02-20 09:51:48 +01:00
|
|
|
}
|
2012-03-06 09:31:44 +01:00
|
|
|
|
|
|
|
for (i <- 0 until n)
|
|
|
|
{
|
|
|
|
val tag = io.mem.xact_abort.bits.tile_xact_id
|
2012-06-06 21:47:17 +02:00
|
|
|
io.requestor(i).xact_abort.valid := io.mem.xact_abort.valid && tag(log2Up(n)-1,0) === UFix(i)
|
2012-03-06 09:31:44 +01:00
|
|
|
io.requestor(i).xact_abort.bits := io.mem.xact_abort.bits
|
2012-06-06 21:47:17 +02:00
|
|
|
io.requestor(i).xact_abort.bits.tile_xact_id := tag >> UFix(log2Up(n))
|
2012-03-06 09:31:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
io.mem.xact_abort.ready := Bool(true)
|
2012-07-18 07:55:00 +02:00
|
|
|
io.mem.xact_rep.ready := Bool(true)
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|