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._
|
2012-10-12 01:54:28 +02:00
|
|
|
import Util._
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2014-09-01 22:28:58 +02:00
|
|
|
case object ECCCode extends Field[Option[Code]]
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2014-09-01 22:28:58 +02:00
|
|
|
abstract trait L1CacheParameters extends CacheParameters with CoreParameters {
|
2014-12-07 12:09:54 +01:00
|
|
|
val outerDataBeats = params(TLDataBeats)
|
2015-03-01 02:00:05 +01:00
|
|
|
val outerDataBits = params(TLDataBits)
|
|
|
|
val code = params(ECCCode).getOrElse(new IdentityCode)
|
|
|
|
val refillCyclesPerBeat = outerDataBits/rowBits
|
2014-12-17 23:28:05 +01:00
|
|
|
val refillCycles = refillCyclesPerBeat*outerDataBeats
|
2014-09-01 22:28:58 +02:00
|
|
|
}
|
2014-08-12 03:36:23 +02:00
|
|
|
|
2014-09-01 22:28:58 +02:00
|
|
|
abstract trait FrontendParameters extends L1CacheParameters
|
2014-08-12 03:36:23 +02:00
|
|
|
abstract class FrontendBundle extends Bundle with FrontendParameters
|
|
|
|
abstract class FrontendModule extends Module with FrontendParameters
|
|
|
|
|
2014-09-01 22:28:58 +02:00
|
|
|
class FrontendReq extends CoreBundle {
|
2015-02-02 05:04:13 +01:00
|
|
|
val pc = UInt(width = vaddrBits+1)
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 22:28:58 +02:00
|
|
|
class FrontendResp extends CoreBundle {
|
2015-02-02 05:04:13 +01:00
|
|
|
val pc = UInt(width = vaddrBits+1) // ID stage PC
|
2014-09-17 23:24:03 +02:00
|
|
|
val data = Vec.fill(coreFetchWidth) (Bits(width = coreInstBits))
|
|
|
|
val mask = Bits(width = coreFetchWidth)
|
2012-10-10 06:35:03 +02:00
|
|
|
val xcpt_ma = Bool()
|
|
|
|
val xcpt_if = Bool()
|
|
|
|
}
|
2012-01-12 04:20:20 +01:00
|
|
|
|
2015-02-02 05:04:13 +01:00
|
|
|
class CPUFrontendIO extends Bundle {
|
2013-08-12 19:39:11 +02:00
|
|
|
val req = Valid(new FrontendReq)
|
|
|
|
val resp = Decoupled(new FrontendResp).flip
|
2014-08-08 21:23:02 +02:00
|
|
|
val btb_resp = Valid(new BTBResp).flip
|
|
|
|
val btb_update = Valid(new BTBUpdate)
|
2014-11-17 07:02:27 +01:00
|
|
|
val bht_update = Valid(new BHTUpdate)
|
2014-11-11 12:34:05 +01:00
|
|
|
val ras_update = Valid(new RASUpdate)
|
2014-08-08 21:23:02 +02:00
|
|
|
val ptw = new TLBPTWIO().flip
|
2012-11-16 10:55:45 +01:00
|
|
|
val invalidate = Bool(OUTPUT)
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
|
|
|
|
2014-11-11 12:34:05 +01:00
|
|
|
class Frontend(btb_updates_out_of_order: Boolean = false) extends FrontendModule
|
2012-10-10 06:35:03 +02:00
|
|
|
{
|
|
|
|
val io = new Bundle {
|
2014-08-08 21:23:02 +02:00
|
|
|
val cpu = new CPUFrontendIO().flip
|
2013-03-20 22:05:12 +01:00
|
|
|
val mem = new UncachedTileLinkIO
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
2014-09-28 14:16:36 +02:00
|
|
|
|
2014-11-11 12:34:05 +01:00
|
|
|
val btb = Module(new BTB(btb_updates_out_of_order))
|
2013-08-12 19:39:11 +02:00
|
|
|
val icache = Module(new ICache)
|
2015-02-02 05:04:13 +01:00
|
|
|
val tlb = Module(new TLB)
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2013-09-13 02:55:58 +02:00
|
|
|
val s1_pc_ = Reg(UInt())
|
|
|
|
val s1_pc = s1_pc_ & SInt(-2) // discard LSB of PC (throughout the pipeline)
|
2013-08-12 19:39:11 +02:00
|
|
|
val s1_same_block = Reg(Bool())
|
2013-08-16 00:28:15 +02:00
|
|
|
val s2_valid = Reg(init=Bool(true))
|
|
|
|
val s2_pc = Reg(init=UInt(START_ADDR))
|
2014-04-02 00:01:27 +02:00
|
|
|
val s2_btb_resp_valid = Reg(init=Bool(false))
|
|
|
|
val s2_btb_resp_bits = Reg(btb.io.resp.bits.clone)
|
2013-08-16 00:28:15 +02:00
|
|
|
val s2_xcpt_if = Reg(init=Bool(false))
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2014-08-12 03:36:23 +02:00
|
|
|
val msb = vaddrBits-1
|
2014-10-21 03:45:23 +02:00
|
|
|
val lsb = log2Up(coreFetchWidth*coreInstBytes)
|
2014-04-02 02:15:46 +02:00
|
|
|
val btbTarget = Cat(btb.io.resp.bits.target(msb), btb.io.resp.bits.target)
|
2014-10-21 03:45:23 +02:00
|
|
|
val ntpc_0 = s1_pc + UInt(coreInstBytes*coreFetchWidth)
|
|
|
|
val ntpc = Cat(s1_pc(msb) & ntpc_0(msb), ntpc_0(msb,lsb), Bits(0,lsb)) // unsure
|
2012-10-10 06:35:03 +02:00
|
|
|
val icmiss = s2_valid && !icache.io.resp.valid
|
2014-09-17 23:24:03 +02:00
|
|
|
val predicted_npc = Mux(btb.io.resp.bits.taken, btbTarget, ntpc)
|
2013-08-12 19:39:11 +02:00
|
|
|
val npc = Mux(icmiss, s2_pc, predicted_npc).toUInt
|
2014-09-17 23:24:03 +02:00
|
|
|
val s0_same_block = !icmiss && !io.cpu.req.valid && !btb.io.resp.bits.taken && ((ntpc & rowBytes) === (s1_pc & rowBytes))
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2012-10-12 01:54:28 +02:00
|
|
|
val stall = io.cpu.resp.valid && !io.cpu.resp.ready
|
2012-10-10 06:35:03 +02:00
|
|
|
when (!stall) {
|
2012-10-12 01:54:28 +02:00
|
|
|
s1_same_block := s0_same_block && !tlb.io.resp.miss
|
2013-09-13 02:55:58 +02:00
|
|
|
s1_pc_ := npc
|
2012-10-10 06:35:03 +02:00
|
|
|
s2_valid := !icmiss
|
2013-05-22 03:59:21 +02:00
|
|
|
when (!icmiss) {
|
|
|
|
s2_pc := s1_pc
|
2014-04-02 00:01:27 +02:00
|
|
|
s2_btb_resp_valid := btb.io.resp.valid
|
|
|
|
when (btb.io.resp.valid) { s2_btb_resp_bits := btb.io.resp.bits }
|
2013-05-22 03:59:21 +02:00
|
|
|
s2_xcpt_if := tlb.io.resp.xcpt_if
|
|
|
|
}
|
2011-11-05 04:52:21 +01:00
|
|
|
}
|
2012-10-10 06:35:03 +02:00
|
|
|
when (io.cpu.req.valid) {
|
2012-10-12 01:54:28 +02:00
|
|
|
s1_same_block := Bool(false)
|
2013-09-13 02:55:58 +02:00
|
|
|
s1_pc_ := io.cpu.req.bits.pc
|
2012-10-10 06:35:03 +02:00
|
|
|
s2_valid := Bool(false)
|
2011-11-05 04:52:21 +01:00
|
|
|
}
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2014-09-30 06:41:07 +02:00
|
|
|
btb.io.req.valid := !stall && !icmiss
|
|
|
|
btb.io.req.bits.addr := s1_pc & SInt(-coreInstBytes)
|
2014-11-17 07:02:27 +01:00
|
|
|
btb.io.btb_update := io.cpu.btb_update
|
|
|
|
btb.io.bht_update := io.cpu.bht_update
|
2014-11-11 12:34:05 +01:00
|
|
|
btb.io.ras_update := io.cpu.ras_update
|
2012-11-16 10:55:45 +01:00
|
|
|
btb.io.invalidate := io.cpu.invalidate || io.cpu.ptw.invalidate
|
2012-10-10 06:35:03 +02:00
|
|
|
|
|
|
|
tlb.io.ptw <> io.cpu.ptw
|
|
|
|
tlb.io.req.valid := !stall && !icmiss
|
2014-08-12 03:36:23 +02:00
|
|
|
tlb.io.req.bits.vpn := s1_pc >> UInt(pgIdxBits)
|
2013-08-12 19:39:11 +02:00
|
|
|
tlb.io.req.bits.asid := UInt(0)
|
2012-11-06 17:13:44 +01:00
|
|
|
tlb.io.req.bits.passthrough := Bool(false)
|
2012-10-10 06:35:03 +02:00
|
|
|
tlb.io.req.bits.instruction := Bool(true)
|
|
|
|
|
|
|
|
icache.io.mem <> io.mem
|
2012-10-12 01:54:28 +02:00
|
|
|
icache.io.req.valid := !stall && !s0_same_block
|
2012-10-10 06:35:03 +02:00
|
|
|
icache.io.req.bits.idx := Mux(io.cpu.req.valid, io.cpu.req.bits.pc, npc)
|
2012-11-16 10:55:45 +01:00
|
|
|
icache.io.invalidate := io.cpu.invalidate
|
2012-10-10 06:35:03 +02:00
|
|
|
icache.io.req.bits.ppn := tlb.io.resp.ppn
|
2015-01-05 01:40:16 +01:00
|
|
|
icache.io.req.bits.kill := io.cpu.req.valid || tlb.io.resp.miss || icmiss || io.cpu.ptw.invalidate
|
2012-10-12 01:54:28 +02:00
|
|
|
icache.io.resp.ready := !stall && !s1_same_block
|
2012-10-10 06:35:03 +02:00
|
|
|
|
|
|
|
io.cpu.resp.valid := s2_valid && (s2_xcpt_if || icache.io.resp.valid)
|
2014-09-01 22:28:58 +02:00
|
|
|
io.cpu.resp.bits.pc := s2_pc & SInt(-coreInstBytes) // discard PC LSBs
|
2014-09-17 23:24:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
val fetch_data = icache.io.resp.bits.datablock >> (s2_pc(log2Up(rowBytes)-1,log2Up(coreFetchWidth*coreInstBytes)) << log2Up(coreFetchWidth*coreInstBits))
|
|
|
|
for (i <- 0 until coreFetchWidth) {
|
|
|
|
io.cpu.resp.bits.data(i) := fetch_data(i*coreInstBits+coreInstBits-1, i*coreInstBits)
|
|
|
|
}
|
|
|
|
|
2014-11-03 10:13:22 +01:00
|
|
|
val all_ones = UInt((1 << (coreFetchWidth+1))-1)
|
2014-10-15 03:10:29 +02:00
|
|
|
val msk_pc = if (coreFetchWidth == 1) all_ones else all_ones << s2_pc(log2Up(coreFetchWidth) -1+2,2)
|
2014-10-21 03:45:23 +02:00
|
|
|
io.cpu.resp.bits.mask := Mux(s2_btb_resp_valid, msk_pc & s2_btb_resp_bits.mask, msk_pc)
|
2014-09-17 23:24:03 +02:00
|
|
|
|
2014-09-01 22:28:58 +02:00
|
|
|
io.cpu.resp.bits.xcpt_ma := s2_pc(log2Up(coreInstBytes)-1,0) != UInt(0)
|
2012-10-10 06:35:03 +02:00
|
|
|
io.cpu.resp.bits.xcpt_if := s2_xcpt_if
|
2014-04-02 00:01:27 +02:00
|
|
|
|
|
|
|
io.cpu.btb_resp.valid := s2_btb_resp_valid
|
|
|
|
io.cpu.btb_resp.bits := s2_btb_resp_bits
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
|
|
|
|
2014-08-12 03:36:23 +02:00
|
|
|
class ICacheReq extends FrontendBundle {
|
|
|
|
val idx = UInt(width = pgIdxBits)
|
2015-02-02 05:04:13 +01:00
|
|
|
val ppn = UInt(width = ppnBits) // delayed one cycle
|
2013-08-12 19:39:11 +02:00
|
|
|
val kill = Bool() // delayed one cycle
|
|
|
|
}
|
|
|
|
|
2014-08-12 03:36:23 +02:00
|
|
|
class ICacheResp extends FrontendBundle {
|
2014-09-01 22:28:58 +02:00
|
|
|
val data = Bits(width = coreInstBits)
|
2014-08-12 03:36:23 +02:00
|
|
|
val datablock = Bits(width = rowBits)
|
2013-08-12 19:39:11 +02:00
|
|
|
}
|
|
|
|
|
2014-08-12 03:36:23 +02:00
|
|
|
class ICache extends FrontendModule
|
2012-10-10 06:35:03 +02:00
|
|
|
{
|
|
|
|
val io = new Bundle {
|
2013-08-12 19:39:11 +02:00
|
|
|
val req = Valid(new ICacheReq).flip
|
|
|
|
val resp = Decoupled(new ICacheResp)
|
2012-11-16 10:55:45 +01:00
|
|
|
val invalidate = Bool(INPUT)
|
2013-03-20 22:05:12 +01:00
|
|
|
val mem = new UncachedTileLinkIO
|
2012-01-25 00:13:49 +01:00
|
|
|
}
|
2014-08-08 21:23:02 +02:00
|
|
|
require(isPow2(nSets) && isPow2(nWays))
|
2014-09-01 22:28:58 +02:00
|
|
|
require(isPow2(coreInstBytes))
|
2014-08-12 03:36:23 +02:00
|
|
|
require(pgIdxBits >= untagBits)
|
2012-01-25 00:13:49 +01:00
|
|
|
|
2013-09-10 19:51:35 +02:00
|
|
|
val s_ready :: s_request :: s_refill_wait :: s_refill :: Nil = Enum(UInt(), 4)
|
2013-08-16 00:28:15 +02:00
|
|
|
val state = Reg(init=s_ready)
|
2013-08-12 19:39:11 +02:00
|
|
|
val invalidated = Reg(Bool())
|
2012-10-10 06:35:03 +02:00
|
|
|
val stall = !io.resp.ready
|
|
|
|
val rdy = Bool()
|
|
|
|
|
2013-08-16 00:28:15 +02:00
|
|
|
val s2_valid = Reg(init=Bool(false))
|
2014-08-12 03:36:23 +02:00
|
|
|
val s2_addr = Reg(UInt(width = paddrBits))
|
2012-10-12 01:54:28 +02:00
|
|
|
val s2_any_tag_hit = Bool()
|
2011-10-26 08:02:47 +02:00
|
|
|
|
2013-08-16 00:28:15 +02:00
|
|
|
val s1_valid = Reg(init=Bool(false))
|
2014-08-12 03:36:23 +02:00
|
|
|
val s1_pgoff = Reg(UInt(width = pgIdxBits))
|
2013-08-12 19:39:11 +02:00
|
|
|
val s1_addr = Cat(io.req.bits.ppn, s1_pgoff).toUInt
|
2014-08-12 03:36:23 +02:00
|
|
|
val s1_tag = s1_addr(tagBits+untagBits-1,untagBits)
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2012-11-16 10:55:45 +01:00
|
|
|
val s0_valid = io.req.valid || s1_valid && stall
|
2013-11-24 23:19:46 +01:00
|
|
|
val s0_pgoff = Mux(s1_valid && stall, s1_pgoff, io.req.bits.idx)
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2012-11-16 10:55:45 +01:00
|
|
|
s1_valid := io.req.valid && rdy || s1_valid && stall && !io.req.bits.kill
|
2012-10-10 06:35:03 +02:00
|
|
|
when (io.req.valid && rdy) {
|
2013-11-24 23:19:46 +01:00
|
|
|
s1_pgoff := io.req.bits.idx
|
2011-11-05 04:52:21 +01:00
|
|
|
}
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2012-10-12 01:54:28 +02:00
|
|
|
s2_valid := s1_valid && rdy && !io.req.bits.kill || io.resp.valid && stall
|
2012-10-10 06:35:03 +02:00
|
|
|
when (s1_valid && rdy && !stall) {
|
2012-11-05 01:39:25 +01:00
|
|
|
s2_addr := s1_addr
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
|
|
|
|
2014-08-12 03:36:23 +02:00
|
|
|
val s2_tag = s2_addr(tagBits+untagBits-1,untagBits)
|
|
|
|
val s2_idx = s2_addr(untagBits-1,blockOffBits)
|
|
|
|
val s2_offset = s2_addr(blockOffBits-1,0)
|
2012-10-10 06:35:03 +02:00
|
|
|
val s2_hit = s2_valid && s2_any_tag_hit
|
|
|
|
val s2_miss = s2_valid && !s2_any_tag_hit
|
|
|
|
rdy := state === s_ready && !s2_miss
|
|
|
|
|
2015-02-02 05:04:13 +01:00
|
|
|
val ser = Module(new FlowThroughSerializer(
|
|
|
|
io.mem.grant.bits,
|
|
|
|
refillCyclesPerBeat))
|
2014-12-07 12:09:54 +01:00
|
|
|
ser.io.in <> io.mem.grant
|
|
|
|
val (refill_cnt, refill_wrap) = Counter(ser.io.out.fire(), refillCycles) //TODO Zero width wire
|
|
|
|
val refill_done = state === s_refill && refill_wrap
|
|
|
|
val refill_valid = ser.io.out.valid
|
|
|
|
val refill_bits = ser.io.out.bits
|
|
|
|
ser.io.out.ready := Bool(true)
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2014-08-12 03:36:23 +02:00
|
|
|
val repl_way = if (isDM) UInt(0) else LFSR16(s2_miss)(log2Up(nWays)-1,0)
|
|
|
|
val entagbits = code.width(tagBits)
|
2014-08-08 21:23:02 +02:00
|
|
|
val tag_array = Mem(Bits(width = entagbits*nWays), nSets, seqRead = true)
|
2013-08-12 19:39:11 +02:00
|
|
|
val tag_raddr = Reg(UInt())
|
2012-10-10 06:35:03 +02:00
|
|
|
when (refill_done) {
|
2014-08-12 03:36:23 +02:00
|
|
|
val wmask = FillInterleaved(entagbits, if (isDM) Bits(1) else UIntToOH(repl_way))
|
|
|
|
val tag = code.encode(s2_tag).toUInt
|
2014-08-08 21:23:02 +02:00
|
|
|
tag_array.write(s2_idx, Fill(nWays, tag), wmask)
|
2012-11-05 01:39:25 +01:00
|
|
|
}
|
2013-01-24 04:27:53 +01:00
|
|
|
// /*.else*/when (s0_valid) { // uncomment ".else" to infer 6T SRAM
|
|
|
|
.elsewhen (s0_valid) {
|
2014-08-12 03:36:23 +02:00
|
|
|
tag_raddr := s0_pgoff(untagBits-1,blockOffBits)
|
2012-07-12 23:50:12 +02:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:23:02 +02:00
|
|
|
val vb_array = Reg(init=Bits(0, nSets*nWays))
|
2012-10-10 06:35:03 +02:00
|
|
|
when (refill_done && !invalidated) {
|
|
|
|
vb_array := vb_array.bitSet(Cat(repl_way, s2_idx), Bool(true))
|
|
|
|
}
|
2012-11-16 10:55:45 +01:00
|
|
|
when (io.invalidate) {
|
2012-07-12 23:50:12 +02:00
|
|
|
vb_array := Bits(0)
|
2012-10-10 06:35:03 +02:00
|
|
|
invalidated := Bool(true)
|
2012-07-12 23:50:12 +02:00
|
|
|
}
|
2014-08-08 21:23:02 +02:00
|
|
|
val s2_disparity = Vec.fill(nWays){Bool()}
|
|
|
|
for (i <- 0 until nWays)
|
2013-08-12 19:39:11 +02:00
|
|
|
when (s2_valid && s2_disparity(i)) { vb_array := vb_array.bitSet(Cat(UInt(i), s2_idx), Bool(false)) }
|
2012-10-10 06:35:03 +02:00
|
|
|
|
2014-08-08 21:23:02 +02:00
|
|
|
val s1_tag_match = Vec.fill(nWays){Bool()}
|
|
|
|
val s2_tag_hit = Vec.fill(nWays){Bool()}
|
|
|
|
val s2_dout = Vec.fill(nWays){Reg(Bits())}
|
2012-11-25 07:00:43 +01:00
|
|
|
|
2014-08-08 21:23:02 +02:00
|
|
|
for (i <- 0 until nWays) {
|
2015-01-05 01:40:16 +01:00
|
|
|
val s1_vb = !io.invalidate && vb_array(Cat(UInt(i), s1_pgoff(untagBits-1,blockOffBits))).toBool
|
2013-08-12 19:39:11 +02:00
|
|
|
val s2_vb = Reg(Bool())
|
|
|
|
val s2_tag_disparity = Reg(Bool())
|
|
|
|
val s2_tag_match = Reg(Bool())
|
2014-08-08 21:23:02 +02:00
|
|
|
val tag_out = tag_array(tag_raddr)(entagbits*(i+1)-1, entagbits*i)
|
2012-10-10 06:35:03 +02:00
|
|
|
when (s1_valid && rdy && !stall) {
|
|
|
|
s2_vb := s1_vb
|
2014-08-12 03:36:23 +02:00
|
|
|
s2_tag_disparity := code.decode(tag_out).error
|
2012-11-05 01:39:25 +01:00
|
|
|
s2_tag_match := s1_tag_match(i)
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
2014-08-12 03:36:23 +02:00
|
|
|
s1_tag_match(i) := tag_out(tagBits-1,0) === s1_tag
|
2012-11-05 01:39:25 +01:00
|
|
|
s2_tag_hit(i) := s2_vb && s2_tag_match
|
2014-08-12 03:36:23 +02:00
|
|
|
s2_disparity(i) := s2_vb && (s2_tag_disparity || code.decode(s2_dout(i)).error)
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
|
|
|
s2_any_tag_hit := s2_tag_hit.reduceLeft(_||_) && !s2_disparity.reduceLeft(_||_)
|
|
|
|
|
2014-08-08 21:23:02 +02:00
|
|
|
for (i <- 0 until nWays) {
|
2014-08-12 03:36:23 +02:00
|
|
|
val data_array = Mem(Bits(width = code.width(rowBits)), nSets*refillCycles, seqRead = true)
|
2013-08-12 19:39:11 +02:00
|
|
|
val s1_raddr = Reg(UInt())
|
2014-04-08 03:22:46 +02:00
|
|
|
when (refill_valid && repl_way === UInt(i)) {
|
2014-08-12 03:36:23 +02:00
|
|
|
val e_d = code.encode(refill_bits.payload.data)
|
2015-02-02 05:04:13 +01:00
|
|
|
if(refillCycles > 1) data_array(Cat(s2_idx, refill_bits.payload.addr_beat)) := e_d
|
2014-12-07 12:09:54 +01:00
|
|
|
else data_array(s2_idx) := e_d
|
2012-11-05 01:39:25 +01:00
|
|
|
}
|
2013-01-24 04:27:53 +01:00
|
|
|
// /*.else*/when (s0_valid) { // uncomment ".else" to infer 6T SRAM
|
|
|
|
.elsewhen (s0_valid) {
|
2014-08-12 03:36:23 +02:00
|
|
|
s1_raddr := s0_pgoff(untagBits-1,blockOffBits-(if(refillCycles > 1) refill_cnt.getWidth else 0))
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
2012-11-05 01:39:25 +01:00
|
|
|
// if s1_tag_match is critical, replace with partial tag check
|
2014-08-12 03:36:23 +02:00
|
|
|
when (s1_valid && rdy && !stall && (Bool(isDM) || s1_tag_match(i))) { s2_dout(i) := data_array(s1_raddr) }
|
2012-01-25 01:51:30 +01:00
|
|
|
}
|
2014-09-01 22:28:58 +02:00
|
|
|
val s2_dout_word = s2_dout.map(x => (x >> (s2_offset(log2Up(rowBytes)-1,log2Up(coreInstBytes)) << log2Up(coreInstBits)))(coreInstBits-1,0))
|
2012-10-10 06:35:03 +02:00
|
|
|
io.resp.bits.data := Mux1H(s2_tag_hit, s2_dout_word)
|
|
|
|
io.resp.bits.datablock := Mux1H(s2_tag_hit, s2_dout)
|
2011-12-04 04:41:15 +01:00
|
|
|
|
2014-04-27 00:18:21 +02:00
|
|
|
val ack_q = Module(new Queue(new LogicalNetworkIO(new Finish), 1))
|
2015-02-02 05:04:13 +01:00
|
|
|
ack_q.io.enq.valid := refill_done && refill_bits.payload.requiresAck()
|
|
|
|
ack_q.io.enq.bits.payload := refill_bits.payload.makeFinish()
|
2014-04-08 03:22:46 +02:00
|
|
|
ack_q.io.enq.bits.header.dst := refill_bits.header.src
|
2012-03-07 00:47:19 +01:00
|
|
|
|
2011-11-07 09:58:25 +01:00
|
|
|
// output signals
|
2012-10-10 06:35:03 +02:00
|
|
|
io.resp.valid := s2_hit
|
2014-03-29 18:59:07 +01:00
|
|
|
io.mem.acquire.valid := (state === s_request) && ack_q.io.enq.ready
|
2015-03-01 02:00:05 +01:00
|
|
|
io.mem.acquire.bits.payload := GetBlock(addr_block = s2_addr >> UInt(blockOffBits))
|
2014-04-27 00:18:21 +02:00
|
|
|
io.mem.finish <> ack_q.io.deq
|
2011-10-26 08:02:47 +02:00
|
|
|
|
|
|
|
// control state machine
|
|
|
|
switch (state) {
|
|
|
|
is (s_ready) {
|
2012-10-10 06:35:03 +02:00
|
|
|
when (s2_miss) { state := s_request }
|
2012-03-06 09:31:44 +01:00
|
|
|
invalidated := Bool(false)
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
2012-10-10 06:35:03 +02:00
|
|
|
is (s_request) {
|
2014-03-29 18:59:07 +01:00
|
|
|
when (io.mem.acquire.ready && ack_q.io.enq.ready) { state := s_refill_wait }
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
is (s_refill_wait) {
|
2013-01-22 02:18:23 +01:00
|
|
|
when (io.mem.grant.valid) { state := s_refill }
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
|
|
|
is (s_refill) {
|
2012-10-10 06:35:03 +02:00
|
|
|
when (refill_done) { state := s_ready }
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|
2012-10-10 06:35:03 +02:00
|
|
|
}
|
2011-10-26 08:02:47 +02:00
|
|
|
}
|