xref: /XiangShan/src/main/scala/xiangshan/frontend/icache/ICacheBundle.scala (revision b1ded4e8375ab58ac87a32698bfab53120d706f6)
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.frontend.icache
18
19import chipsalliance.rocketchip.config.Parameters
20import chisel3._
21import chisel3.util._
22import freechips.rocketchip.tilelink.{ClientMetadata, TLPermissions}
23import xiangshan._
24import utils._
25import utility._
26
27class ICacheReadBundle(implicit p: Parameters) extends ICacheBundle
28{
29  val isDoubleLine  = Bool()
30  val vSetIdx       = Vec(2,UInt(log2Ceil(nSets).W))
31
32  def port_0_read_0 =  !vSetIdx(0)(0)
33  def port_0_read_1 =   vSetIdx(0)(0)
34  def port_1_read_0 =  !vSetIdx(1)(0) && isDoubleLine
35  def port_1_read_1 =   vSetIdx(1)(0) && isDoubleLine
36
37  def read_bank_0 = port_0_read_0 || port_1_read_0
38  def read_bank_1 =  port_0_read_1 || port_1_read_1
39}
40
41
42class ICacheMetaRespBundle(implicit p: Parameters) extends ICacheBundle
43{
44  val metaData   = Vec(2, Vec(nWays, new ICacheMetadata))
45  val errors     = Vec(2, Vec(nWays ,Bool() ))
46  val entryValid = Vec(2, Vec(nWays, Bool()))
47
48  def tags = VecInit(metaData.map(port => VecInit(port.map( way=> way.tag ))))
49}
50
51class ICacheMetaWriteBundle(implicit p: Parameters) extends ICacheBundle
52{
53  val virIdx  = UInt(idxBits.W)
54  val phyTag  = UInt(tagBits.W)
55  val waymask = UInt(nWays.W)
56  val bankIdx = Bool()
57
58  def generate(tag:UInt, idx:UInt, waymask:UInt, bankIdx: Bool){
59    this.virIdx  := idx
60    this.phyTag  := tag
61    this.waymask := waymask
62    this.bankIdx   := bankIdx
63  }
64
65}
66
67class ICacheDataWriteBundle(implicit p: Parameters) extends ICacheBundle
68{
69  val virIdx  = UInt(idxBits.W)
70  val data    = UInt(blockBits.W)
71  val waymask = UInt(nWays.W)
72  val bankIdx = Bool()
73  val paddr   = UInt(PAddrBits.W)
74
75  def generate(data:UInt, idx:UInt, waymask:UInt, bankIdx: Bool, paddr: UInt){
76    this.virIdx  := idx
77    this.data    := data
78    this.waymask := waymask
79    this.bankIdx := bankIdx
80    this.paddr   := paddr
81  }
82
83}
84
85class ICacheDataRespBundle(implicit p: Parameters) extends ICacheBundle
86{
87  val datas = Vec(2, Vec(nWays,  UInt(blockBits.W)))
88  val codes = Vec(2, Vec(nWays , UInt(dataCodeEntryBits.W)))
89}
90
91class ICacheMetaReadBundle(implicit p: Parameters) extends ICacheBundle
92{
93    val req     = Flipped(DecoupledIO(new ICacheReadBundle))
94    val resp = Output(new ICacheMetaRespBundle)
95}
96
97class IPFBufferFilterRead(implicit p: Parameters) extends  IPrefetchBundle{
98  /** input */
99  val req = Flipped(new Bundle {
100    val vSetIdx = Output(UInt(log2Ceil(nSets).W))
101    val paddr = Output(UInt(PAddrBits.W))
102  })
103  /** output */
104  val resp = new Bundle {
105    val ipf_hit = Output(Bool())
106  }
107}
108
109class IPFBufferRead(implicit p: Parameters) extends IPrefetchBundle {
110  val req = Vec(PortNumber, Flipped(DecoupledIO(new Bundle {
111    val vaddr = UInt(VAddrBits.W)
112    val paddr = UInt(PAddrBits.W)
113  })))
114  val resp = Vec(PortNumber, ValidIO(new Bundle {
115    val ipf_hit = Bool()
116    val cacheline = UInt(blockBits.W)
117  }))
118}
119
120class PIQMetaWrite(implicit p: Parameters) extends  IPrefetchBundle{
121  val tag = UInt(tagBits.W)
122  val index = UInt(idxBits.W)
123  val paddr = UInt(PAddrBits.W)
124}
125
126class IPFBufferWrite(implicit p: Parameters) extends  IPrefetchBundle{
127  val buffIdx = UInt(log2Ceil(nPrefetchEntries).W)
128  val meta = new PIQMetaWrite
129  val data =  UInt(blockBits.W)
130}
131
132class IPFBufferMove(implicit p: Parameters) extends  IPrefetchBundle{
133  val vsetIdx = Output(UInt(idxBits.W))
134  val waymask = Input(UInt(nWays.W))
135}