2014-09-12 19:15:04 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
2014-09-02 22:51:57 +02:00
|
|
|
package rocketchip
|
2014-08-25 04:30:53 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2015-07-30 02:56:19 +02:00
|
|
|
import junctions._
|
2014-08-25 04:30:53 +02:00
|
|
|
import uncore._
|
|
|
|
|
2015-10-07 01:26:58 +02:00
|
|
|
class MemDessert extends Module {
|
|
|
|
implicit val p = params
|
2015-10-06 19:47:38 +02:00
|
|
|
val io = new MemDesserIO(p(HtifKey).width)
|
|
|
|
val x = Module(new MemDesser(p(HtifKey).width))
|
2014-08-25 04:30:53 +02:00
|
|
|
io.narrow <> x.io.narrow
|
|
|
|
io.wide <> x.io.wide
|
|
|
|
}
|
|
|
|
|
|
|
|
object VLSIUtils {
|
2015-06-26 08:17:35 +02:00
|
|
|
def doOuterMemorySystemSerdes(
|
2015-10-02 23:23:42 +02:00
|
|
|
llcs: Seq[NastiIO],
|
|
|
|
mems: Seq[NastiIO],
|
2015-06-26 08:17:35 +02:00
|
|
|
backup: MemSerializedIO,
|
|
|
|
en: Bool,
|
2015-07-30 02:56:19 +02:00
|
|
|
nMemChannels: Int,
|
2015-08-06 21:51:18 +02:00
|
|
|
htifWidth: Int,
|
2015-10-02 23:23:42 +02:00
|
|
|
blockOffsetBits: Int)
|
|
|
|
(implicit p: Parameters) {
|
2015-08-06 21:51:18 +02:00
|
|
|
|
2015-10-02 23:23:42 +02:00
|
|
|
val arb = Module(new NastiArbiter(nMemChannels))
|
|
|
|
val conv = Module(new MemIONastiIOConverter(blockOffsetBits))
|
2015-07-30 02:56:19 +02:00
|
|
|
val mem_serdes = Module(new MemSerdes(htifWidth))
|
2015-08-06 21:51:18 +02:00
|
|
|
|
|
|
|
conv.io.nasti <> arb.io.slave
|
|
|
|
mem_serdes.io.wide <> conv.io.mem
|
2015-08-04 03:54:56 +02:00
|
|
|
backup <> mem_serdes.io.narrow
|
2014-08-25 04:30:53 +02:00
|
|
|
|
2015-08-06 21:51:18 +02:00
|
|
|
llcs zip mems zip arb.io.master foreach { case ((llc, mem), wide) =>
|
|
|
|
llc.ar.ready := Mux(en, wide.ar.ready, mem.ar.ready)
|
|
|
|
mem.ar.valid := llc.ar.valid && !en
|
|
|
|
mem.ar.bits := llc.ar.bits
|
|
|
|
wide.ar.valid := llc.ar.valid && en
|
|
|
|
wide.ar.bits := llc.ar.bits
|
|
|
|
|
|
|
|
llc.aw.ready := Mux(en, wide.aw.ready, mem.aw.ready)
|
|
|
|
mem.aw.valid := llc.aw.valid && !en
|
|
|
|
mem.aw.bits := llc.aw.bits
|
|
|
|
wide.aw.valid := llc.aw.valid && en
|
|
|
|
wide.aw.bits := llc.aw.bits
|
|
|
|
|
|
|
|
llc.w.ready := Mux(en, wide.w.ready, mem.w.ready)
|
|
|
|
mem.w.valid := llc.w.valid && !en
|
|
|
|
mem.w.bits := llc.w.bits
|
|
|
|
wide.w.valid := llc.w.valid && en
|
|
|
|
wide.w.bits := llc.w.bits
|
2014-08-25 04:30:53 +02:00
|
|
|
|
2015-08-06 21:51:18 +02:00
|
|
|
llc.b.valid := Mux(en, wide.b.valid, mem.b.valid)
|
|
|
|
llc.b.bits := Mux(en, wide.b.bits, mem.b.bits)
|
|
|
|
mem.b.ready := llc.b.ready && !en
|
|
|
|
wide.b.ready := llc.b.ready && en
|
2014-08-25 04:30:53 +02:00
|
|
|
|
2015-08-06 21:51:18 +02:00
|
|
|
llc.r.valid := Mux(en, wide.r.valid, mem.r.valid)
|
|
|
|
llc.r.bits := Mux(en, wide.r.bits, mem.r.bits)
|
|
|
|
mem.r.ready := llc.r.ready && !en
|
|
|
|
wide.r.ready := llc.r.ready && en
|
2015-06-26 08:17:35 +02:00
|
|
|
}
|
2014-08-25 04:30:53 +02:00
|
|
|
}
|
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
def padOutHTIFWithDividedClock(
|
2015-08-06 21:51:18 +02:00
|
|
|
htif: HostIO,
|
|
|
|
scr: SCRIO,
|
2015-06-26 08:17:35 +02:00
|
|
|
child: MemSerializedIO,
|
|
|
|
parent: MemBackupCtrlIO,
|
|
|
|
host: HostIO,
|
|
|
|
htifW: Int) {
|
2014-08-25 04:30:53 +02:00
|
|
|
val hio = Module((new SlowIO(512)) { Bits(width = htifW+1) })
|
2015-08-06 21:51:18 +02:00
|
|
|
hio.io.set_divisor.valid := scr.wen && (scr.waddr === UInt(63))
|
|
|
|
hio.io.set_divisor.bits := scr.wdata
|
|
|
|
scr.rdata(63) := hio.io.divisor
|
2014-08-25 04:30:53 +02:00
|
|
|
|
2015-08-06 21:51:18 +02:00
|
|
|
hio.io.out_fast.valid := htif.out.valid || child.req.valid
|
|
|
|
hio.io.out_fast.bits := Cat(htif.out.valid, Mux(htif.out.valid, htif.out.bits, child.req.bits))
|
|
|
|
htif.out.ready := hio.io.out_fast.ready
|
|
|
|
child.req.ready := hio.io.out_fast.ready && !htif.out.valid
|
2014-08-25 04:30:53 +02:00
|
|
|
host.out.valid := hio.io.out_slow.valid && hio.io.out_slow.bits(htifW)
|
|
|
|
host.out.bits := hio.io.out_slow.bits
|
2015-06-26 08:17:35 +02:00
|
|
|
parent.out_valid := hio.io.out_slow.valid && !hio.io.out_slow.bits(htifW)
|
|
|
|
hio.io.out_slow.ready := Mux(hio.io.out_slow.bits(htifW), host.out.ready, parent.out_ready)
|
2014-08-25 04:30:53 +02:00
|
|
|
|
2015-06-26 08:17:35 +02:00
|
|
|
val mem_backup_resp_valid = parent.en && parent.in_valid
|
2014-08-25 04:30:53 +02:00
|
|
|
hio.io.in_slow.valid := mem_backup_resp_valid || host.in.valid
|
|
|
|
hio.io.in_slow.bits := Cat(mem_backup_resp_valid, host.in.bits)
|
|
|
|
host.in.ready := hio.io.in_slow.ready
|
|
|
|
child.resp.valid := hio.io.in_fast.valid && hio.io.in_fast.bits(htifW)
|
|
|
|
child.resp.bits := hio.io.in_fast.bits
|
2015-08-06 21:51:18 +02:00
|
|
|
htif.in.valid := hio.io.in_fast.valid && !hio.io.in_fast.bits(htifW)
|
|
|
|
htif.in.bits := hio.io.in_fast.bits
|
|
|
|
hio.io.in_fast.ready := Mux(hio.io.in_fast.bits(htifW), Bool(true), htif.in.ready)
|
2014-08-25 04:30:53 +02:00
|
|
|
host.clk := hio.io.clk_slow
|
|
|
|
host.clk_edge := Reg(next=host.clk && !Reg(next=host.clk))
|
|
|
|
}
|
|
|
|
}
|