xref: /XiangShan/src/main/scala/xiangshan/frontend/icache/ICacheBundle.scala (revision 6c106319588f5988a282dc2e7c687a9d44e9c209)
1/***************************************************************************************
2* Copyright (c) 2024 Beijing Institute of Open Source Chip (BOSC)
3* Copyright (c) 2020-2024 Institute of Computing Technology, Chinese Academy of Sciences
4* Copyright (c) 2020-2021 Peng Cheng Laboratory
5*
6* XiangShan is licensed under Mulan PSL v2.
7* You can use this software according to the terms and conditions of the Mulan PSL v2.
8* You may obtain a copy of Mulan PSL v2 at:
9*          http://license.coscl.org.cn/MulanPSL2
10*
11* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
12* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
13* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
14*
15* See the Mulan PSL v2 for more details.
16***************************************************************************************/
17
18package xiangshan.frontend.icache
19
20import chisel3._
21import chisel3.util._
22import org.chipsalliance.cde.config.Parameters
23
24class ICacheReadBundle(implicit p: Parameters) extends ICacheBundle {
25  val vSetIdx:      Vec[UInt]      = Vec(2, UInt(idxBits.W))
26  val waymask:      Vec[Vec[Bool]] = Vec(2, Vec(nWays, Bool()))
27  val blkOffset:    UInt           = UInt(log2Ceil(blockBytes).W)
28  val isDoubleLine: Bool           = Bool()
29}
30
31class ICacheMetaWriteBundle(implicit p: Parameters) extends ICacheBundle {
32  val virIdx:  UInt = UInt(idxBits.W)
33  val phyTag:  UInt = UInt(tagBits.W)
34  val waymask: UInt = UInt(nWays.W)
35  val bankIdx: Bool = Bool()
36  val poison:  Bool = Bool()
37
38  def generate(tag: UInt, idx: UInt, waymask: UInt, bankIdx: Bool, poison: Bool): Unit = {
39    this.virIdx  := idx
40    this.phyTag  := tag
41    this.waymask := waymask
42    this.bankIdx := bankIdx
43    this.poison  := poison
44  }
45}
46
47class ICacheMetaFlushBundle(implicit p: Parameters) extends ICacheBundle {
48  val virIdx:  UInt = UInt(idxBits.W)
49  val waymask: UInt = UInt(nWays.W)
50}
51
52class ICacheDataWriteBundle(implicit p: Parameters) extends ICacheBundle {
53  val virIdx:  UInt = UInt(idxBits.W)
54  val data:    UInt = UInt(blockBits.W)
55  val waymask: UInt = UInt(nWays.W)
56  val bankIdx: Bool = Bool()
57  val poison:  Bool = Bool()
58
59  def generate(data: UInt, idx: UInt, waymask: UInt, bankIdx: Bool, poison: Bool): Unit = {
60    this.virIdx  := idx
61    this.data    := data
62    this.waymask := waymask
63    this.bankIdx := bankIdx
64    this.poison  := poison
65  }
66}
67
68class ICacheMetaRespBundle(implicit p: Parameters) extends ICacheBundle {
69  val metas:      Vec[Vec[ICacheMetadata]] = Vec(PortNumber, Vec(nWays, new ICacheMetadata))
70  val codes:      Vec[Vec[UInt]]           = Vec(PortNumber, Vec(nWays, UInt(ICacheMetaCodeBits.W)))
71  val entryValid: Vec[Vec[Bool]]           = Vec(PortNumber, Vec(nWays, Bool()))
72
73  // for compatibility
74  def tags: Vec[Vec[UInt]] = VecInit(metas.map(port => VecInit(port.map(way => way.tag))))
75}
76
77class ICacheDataRespBundle(implicit p: Parameters) extends ICacheBundle {
78  val datas: Vec[UInt] = Vec(ICacheDataBanks, UInt(ICacheDataBits.W))
79  val codes: Vec[UInt] = Vec(ICacheDataBanks, UInt(ICacheDataCodeBits.W))
80}
81
82class ReplacerTouch(implicit p: Parameters) extends ICacheBundle {
83  val vSetIdx: UInt = UInt(idxBits.W)
84  val way:     UInt = UInt(wayBits.W)
85}
86
87class ReplacerVictim(implicit p: Parameters) extends ICacheBundle {
88  val vSetIdx: Valid[UInt] = ValidIO(UInt(idxBits.W))
89  val way:     UInt        = Input(UInt(wayBits.W))
90}
91