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 utils 18 19import chisel3._ 20import org.chipsalliance.cde.config.Parameters 21import chisel3.util.DecoupledIO 22import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp} 23import freechips.rocketchip.tilelink.{TLBundle, TLClientNode, TLIdentityNode, TLMasterParameters, TLMasterPortParameters} 24import utility.XSDebug 25 26class DebugIdentityNode()(implicit p: Parameters) extends LazyModule { 27 28 val node = TLIdentityNode() 29 30 val n = TLClientNode(Seq(TLMasterPortParameters.v1( 31 Seq( 32 TLMasterParameters.v1("debug node") 33 ) 34 ))) 35 36 lazy val module = new LazyModuleImp(this) with HasTLDump { 37 val (out, _) = node.out(0) 38 val (in, _) = node.in(0) 39 40 def debug(t: TLBundle, valid: Boolean = false): Unit ={ 41 def fire[T <: Data](x: DecoupledIO[T]) = if(valid) x.valid else x.fire 42 val channels = Seq(t.a, t.b, t.c, t.d, t.e) 43 channels.foreach { c => 44 XSDebug(fire(c), " isFire:%d ", c.fire) 45 c.bits.dump(fire(c)) 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