xref: /XiangShan/src/main/scala/utils/DataDontCareNode.scala (revision 8891a219bbc84f568e1d134854d8d5ed86d6d560)
1c6d43980SLemover/***************************************************************************************
2c6d43980SLemover* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3f320e0f0SYinan Xu* Copyright (c) 2020-2021 Peng Cheng Laboratory
4c6d43980SLemover*
5c6d43980SLemover* XiangShan is licensed under Mulan PSL v2.
6c6d43980SLemover* You can use this software according to the terms and conditions of the Mulan PSL v2.
7c6d43980SLemover* You may obtain a copy of Mulan PSL v2 at:
8c6d43980SLemover*          http://license.coscl.org.cn/MulanPSL2
9c6d43980SLemover*
10c6d43980SLemover* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11c6d43980SLemover* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12c6d43980SLemover* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13c6d43980SLemover*
14c6d43980SLemover* See the Mulan PSL v2 for more details.
15c6d43980SLemover***************************************************************************************/
16c6d43980SLemover
17279a83c2SAllenpackage utils
18279a83c2SAllen
19279a83c2SAllenimport chisel3._
20*8891a219SYinan Xuimport org.chipsalliance.cde.config.Parameters
21279a83c2SAllenimport chisel3.util.DecoupledIO
22279a83c2SAllenimport freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
23279a83c2SAllenimport freechips.rocketchip.tilelink.{TLBundle, TLClientNode, TLIdentityNode, TLMasterParameters, TLMasterPortParameters}
24279a83c2SAllen
25279a83c2SAllenclass DataDontCareNode(a: Boolean = false, b: Boolean = false, c: Boolean = false, d: Boolean = false)(implicit p: Parameters) extends LazyModule  {
26279a83c2SAllen
27279a83c2SAllen  val node = TLIdentityNode()
28279a83c2SAllen
29279a83c2SAllen  val n = TLClientNode(Seq(TLMasterPortParameters.v1(
30279a83c2SAllen    Seq(
31279a83c2SAllen      TLMasterParameters.v1("DataDontCareNode")
32279a83c2SAllen    )
33279a83c2SAllen  )))
34279a83c2SAllen
355c5bd416Sljw  lazy val module = new LazyModuleImp(this) with HasTLDump{
36279a83c2SAllen    val (out, _) = node.out(0)
37279a83c2SAllen    val (in, _) = node.in(0)
38279a83c2SAllen
39279a83c2SAllen    if (a) {
40279a83c2SAllen      out.a.bits.data := DontCare
41279a83c2SAllen    }
42279a83c2SAllen    if (b) {
43279a83c2SAllen      in.b.bits.data := DontCare
44279a83c2SAllen    }
45279a83c2SAllen    if (c) {
46279a83c2SAllen      out.c.bits.data := DontCare
47279a83c2SAllen    }
48279a83c2SAllen    if (d) {
49279a83c2SAllen      in.d.bits.data := DontCare
50279a83c2SAllen    }
51279a83c2SAllen  }
52279a83c2SAllen}
53279a83c2SAllen
54279a83c2SAllenobject DataDontCareNode {
55279a83c2SAllen  def apply(a: Boolean = false, b: Boolean = false, c: Boolean = false, d: Boolean = false)(implicit p: Parameters): TLIdentityNode = {
56279a83c2SAllen    val dataDontCareNode = LazyModule(new DataDontCareNode(a, b, c, d))
57279a83c2SAllen    dataDontCareNode.node
58279a83c2SAllen  }
59279a83c2SAllen}
60