xref: /XiangShan/src/main/scala/utils/DataDontCareNode.scala (revision 8891a219bbc84f568e1d134854d8d5ed86d6d560)
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}
24
25class DataDontCareNode(a: Boolean = false, b: Boolean = false, c: Boolean = false, d: Boolean = false)(implicit p: Parameters) extends LazyModule  {
26
27  val node = TLIdentityNode()
28
29  val n = TLClientNode(Seq(TLMasterPortParameters.v1(
30    Seq(
31      TLMasterParameters.v1("DataDontCareNode")
32    )
33  )))
34
35  lazy val module = new LazyModuleImp(this) with HasTLDump{
36    val (out, _) = node.out(0)
37    val (in, _) = node.in(0)
38
39    if (a) {
40      out.a.bits.data := DontCare
41    }
42    if (b) {
43      in.b.bits.data := DontCare
44    }
45    if (c) {
46      out.c.bits.data := DontCare
47    }
48    if (d) {
49      in.d.bits.data := DontCare
50    }
51  }
52}
53
54object DataDontCareNode {
55  def apply(a: Boolean = false, b: Boolean = false, c: Boolean = false, d: Boolean = false)(implicit p: Parameters): TLIdentityNode = {
56    val dataDontCareNode = LazyModule(new DataDontCareNode(a, b, c, d))
57    dataDontCareNode.node
58  }
59}
60