xref: /XiangShan/src/main/scala/utils/Trigger.scala (revision bb2f3f51dd67f6e16e0cc1ffe43368c9fc7e4aef)
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 Mu lan 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 chisel3.util._
21import xiangshan.MatchTriggerIO
22import org.chipsalliance.cde.config.Parameters
23import utility.XSDebug
24
25object ChainCheck {
26  def TimingCheck(prevTiming: Bool, thisTiming: Bool, chain: Bool) = !((prevTiming ^ thisTiming) && chain)
27  def HitCheck(prevHit: Bool, chain: Bool) = prevHit || !chain
28}
29
30object PrintTriggerInfo {
31  def apply(enable: Bool, trigger: MatchTriggerIO)(implicit p: Parameters) = {
32    XSDebug(enable, p"Debug Mode: Match Type is ${trigger.matchType}; select is ${trigger.select};" +
33      p"timing is ${trigger.timing}; action is ${trigger.action}; chain is ${trigger.chain};" +
34      p"tdata2 is ${Hexadecimal(trigger.tdata2)}")
35  }
36}