xref: /XiangShan/src/main/scala/utils/DebugMem.scala (revision e3da8bad334fc71ba0d72f0607e2e93245ddaece)
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 utils
19
20import chisel3._
21
22object DebugMem {
23  def apply[T <: Data](size: Int, data: T): DebugMem[T] = {
24    new DebugMem(size, data)
25  }
26}
27
28class DebugMem[T <: Data](size: Int, data: T) extends IndexedSeq[T] {
29  private val debugReg: Vec[T] = Reg(Vec(size, data))
30
31  def apply(addr: Int): T = debugReg(addr)
32
33  def apply(addr: UInt): T = debugReg(addr)
34
35  def length: Int = debugReg.length
36}
37