xref: /XiangShan/src/main/scala/utils/Trigger.scala (revision 7295133529ec07672490a4dcfc4832daadb8bb4b)
1*72951335SLi Qianruo/***************************************************************************************
2*72951335SLi Qianruo * Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3*72951335SLi Qianruo * Copyright (c) 2020-2021 Peng Cheng Laboratory
4*72951335SLi Qianruo *
5*72951335SLi Qianruo * XiangShan is licensed under Mulan PSL v2.
6*72951335SLi Qianruo * You can use this software according to the terms and conditions of the Mu lan PSL v2.
7*72951335SLi Qianruo * You may obtain a copy of Mulan PSL v2 at:
8*72951335SLi Qianruo *          http://license.coscl.org.cn/MulanPSL2
9*72951335SLi Qianruo *
10*72951335SLi Qianruo * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11*72951335SLi Qianruo * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12*72951335SLi Qianruo * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13*72951335SLi Qianruo *
14*72951335SLi Qianruo * See the Mulan PSL v2 for more details.
15*72951335SLi Qianruo ***************************************************************************************/
16*72951335SLi Qianruo
17*72951335SLi Qianruopackage utils
18*72951335SLi Qianruo
19*72951335SLi Qianruoimport chisel3._
20*72951335SLi Qianruoimport chisel3.util._
21*72951335SLi Qianruo
22*72951335SLi Qianruoobject TriggerCmp {
23*72951335SLi Qianruo  def apply(actual: UInt, tdata: UInt, matchType: UInt, enable: Bool) = {
24*72951335SLi Qianruo    val equal = actual === tdata
25*72951335SLi Qianruo    val greater = actual >= tdata
26*72951335SLi Qianruo    val less = actual <= tdata
27*72951335SLi Qianruo    val res = MuxLookup(matchType, false.B,
28*72951335SLi Qianruo      Array(0.U -> equal,
29*72951335SLi Qianruo          2.U -> greater,
30*72951335SLi Qianruo          3.U -> less))
31*72951335SLi Qianruo    res && enable
32*72951335SLi Qianruo  }
33*72951335SLi Qianruo}
34*72951335SLi Qianruo
35*72951335SLi Qianruoobject ChainCheck {
36*72951335SLi Qianruo  def TimingCheck(prevTiming: Bool, thisTiming: Bool, chain: Bool) = !((prevTiming ^ thisTiming) && chain)
37*72951335SLi Qianruo  def HitCheck(prevHit: Bool, chain: Bool) = prevHit || !chain
38*72951335SLi Qianruo}
39