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 device.standalone 18 19import chisel3._ 20import freechips.rocketchip.diplomacy._ 21import org.chipsalliance.cde.config.Parameters 22import freechips.rocketchip.devices.tilelink._ 23import freechips.rocketchip.interrupts._ 24import device.XSDebugModuleParams 25import system.SoCParamsKey 26import xiangshan.XSCoreParamsKey 27import xiangshan.XSTileKey 28import device.DebugModule 29 30class StandAloneDebugModule ( 31 useTL: Boolean = false, 32 baseAddress: BigInt, 33 addrWidth: Int, 34 dataWidth: Int = 64, 35 hartNum: Int 36)(implicit p: Parameters) extends StandAloneDevice( 37 useTL, baseAddress, addrWidth, dataWidth, hartNum 38) with HasMasterInterface { 39 40 def addressSet: AddressSet = AddressSet(XSDebugModuleParams.apply(p(XSTileKey).head.XLEN).baseAddress, 0xfff) 41 42 val debugModule = LazyModule(new DebugModule(hartNum)(p)) 43 debugModule.debug.node := xbar 44 debugModule.debug.dmInner.dmInner.sb2tlOpt.foreach(masternode := _.node) 45 46 // interrupts 47 val debugModuleIntNode = IntSinkNode(IntSinkPortSimple(hartNum, 1)) 48 debugModuleIntNode :*= debugModule.debug.dmOuter.dmOuter.intnode 49 val int = InModuleBody(debugModuleIntNode.makeIOs()) 50 51 class StandAloneDebugModuleImp(val outer: StandAloneDebugModule)(implicit p: Parameters) extends StandAloneDeviceImp(outer) { 52 val io = IO(new outer.debugModule.DebugModuleIO) 53 io <> outer.debugModule.module.io 54 } 55 56 override lazy val module = new StandAloneDebugModuleImp(this) 57 58} 59