1/*************************************************************************************** 2 * Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3 * Copyright (c) 2020-2021 Peng Cheng Laboratory 4 * 5 * XiangShan is licensed under Mulan PSL v2. 6 * You can use this software according to the terms and conditions of the Mulan PSL v2. 7 * You may obtain a copy of Mulan PSL v2 at: 8 * http://license.coscl.org.cn/MulanPSL2 9 * 10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13 * 14 * See the Mulan PSL v2 for more details. 15 ***************************************************************************************/ 16 17package xiangshan.mem.prefetch 18 19import chisel3._ 20import chisel3.util._ 21import org.chipsalliance.cde.config.Parameters 22import utility.MemReqSource 23import xiangshan._ 24import xiangshan.backend.fu.PMPRespBundle 25import xiangshan.cache.mmu.TlbRequestIO 26import xiangshan.mem.{LdPrefetchTrainBundle, StPrefetchTrainBundle, L1PrefetchReq} 27import xiangshan.backend._ 28import coupledL2.PrefetchCtrlFromCore 29 30class PrefetchCtrl(implicit p: Parameters) extends XSBundle { 31 val l1I_pf_enable = Bool() 32 val l2_pf_enable = Bool() 33 val l1D_pf_enable = Bool() 34 val l1D_pf_train_on_hit = Bool() 35 val l1D_pf_enable_agt = Bool() 36 val l1D_pf_enable_pht = Bool() 37 val l1D_pf_active_threshold = UInt(4.W) 38 val l1D_pf_active_stride = UInt(6.W) 39 val l1D_pf_enable_stride = Bool() 40 val l2_pf_store_only = Bool() 41 val l2_pf_recv_enable = Bool() 42 val l2_pf_pbop_enable = Bool() 43 val l2_pf_vbop_enable = Bool() 44 val l2_pf_tp_enable = Bool() 45 46 def toL2PrefetchCtrl(): PrefetchCtrlFromCore = { 47 val res = Wire(new PrefetchCtrlFromCore) 48 res.l2_pf_master_en := l2_pf_enable 49 res.l2_pf_recv_en := l2_pf_recv_enable 50 res.l2_pbop_en := l2_pf_pbop_enable 51 res.l2_vbop_en := l2_pf_vbop_enable 52 res.l2_tp_en := l2_pf_tp_enable 53 res 54 } 55} 56 57class L2PrefetchReq(implicit p: Parameters) extends XSBundle { 58 val addr = UInt(PAddrBits.W) 59 val source = UInt(MemReqSource.reqSourceBits.W) 60} 61 62class PrefetcherIO()(implicit p: Parameters) extends XSBundle { 63 val ld_in = Flipped(Vec(backendParams.LdExuCnt, ValidIO(new LdPrefetchTrainBundle()))) 64 val st_in = Flipped(Vec(backendParams.StaExuCnt, ValidIO(new StPrefetchTrainBundle()))) 65 val tlb_req = new TlbRequestIO(nRespDups = 2) 66 val pmp_resp = Flipped(new PMPRespBundle()) 67 val l1_req = DecoupledIO(new L1PrefetchReq()) 68 val l2_req = ValidIO(new L2PrefetchReq()) 69 val l3_req = ValidIO(UInt(PAddrBits.W)) // TODO: l3 pf source 70 val enable = Input(Bool()) 71} 72 73class PrefetchReqBundle()(implicit p: Parameters) extends XSBundle { 74 val vaddr = UInt(VAddrBits.W) 75 val paddr = UInt(PAddrBits.W) 76 val pc = UInt(VAddrBits.W) 77 val miss = Bool() 78 val pfHitStream = Bool() 79} 80 81trait PrefetcherParams 82 83abstract class BasePrefecher()(implicit p: Parameters) extends XSModule { 84 val io = IO(new PrefetcherIO()) 85 86 io.l3_req.valid := false.B 87 io.l3_req.bits := DontCare 88}