xref: /XiangShan/src/main/scala/utils/DebugIdentityNode.scala (revision c6d439803a044ea209139672b25e35fe8d7f4aa0)
1/***************************************************************************************
2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3*
4* XiangShan is licensed under Mulan PSL v2.
5* You can use this software according to the terms and conditions of the Mulan PSL v2.
6* You may obtain a copy of Mulan PSL v2 at:
7*          http://license.coscl.org.cn/MulanPSL2
8*
9* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
10* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
11* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
12*
13* See the Mulan PSL v2 for more details.
14***************************************************************************************/
15
16package utils
17
18import chisel3._
19import chipsalliance.rocketchip.config.Parameters
20import chisel3.util.DecoupledIO
21import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
22import freechips.rocketchip.tilelink.{TLBundle, TLClientNode, TLIdentityNode, TLMasterParameters, TLMasterPortParameters}
23
24class DebugIdentityNode()(implicit p: Parameters) extends LazyModule  {
25
26  val node = TLIdentityNode()
27
28  val n = TLClientNode(Seq(TLMasterPortParameters.v1(
29    Seq(
30      TLMasterParameters.v1("debug node")
31    )
32  )))
33
34  lazy val module = new LazyModuleImp(this) with HasTLDump{
35    val (out, _) = node.out(0)
36    val (in, _) = node.in(0)
37
38    def debug(t: TLBundle, valid: Boolean = false): Unit ={
39      def fire[T <: Data](x: DecoupledIO[T]) = if(valid) x.valid else x.fire()
40      val channels = Seq(t.a, t.b, t.c, t.d, t.e)
41      channels.foreach(c =>
42        when(fire(c)){
43          XSDebug(" isFire:%d ",c.fire())
44          c.bits.dump
45        }
46      )
47    }
48    debug(in, false)
49  }
50}
51
52object DebugIdentityNode {
53  def apply()(implicit p: Parameters): TLIdentityNode = {
54    val identityNode = LazyModule(new DebugIdentityNode())
55    identityNode.node
56  }
57}
58