-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(DataStorage): Fix req_valid and Add MCP2 Check Assertions (#254)
* TMP: add HoldChecker to ensure MCP2 Hold condition * misc: an official version of MCP2 hold check * misc: add check right at predecessor regs' output * misc: remove checks that are no longer needed * DataStorage: use LSB instead of orR for req_valid Since task_s3_valid_hold2(1) will change during the two cycles, we just use (0) as req_valid * misc: add check for task_valid_s3_hold2(0) * misc: fix wrong assertion
- Loading branch information
1 parent
2f63bfe
commit 66e6ff7
Showing
10 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** ************************************************************************************* | ||
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences | ||
* Copyright (c) 2020-2021 Peng Cheng Laboratory | ||
* | ||
* XiangShan is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* | ||
* See the Mulan PSL v2 for more details. | ||
* ************************************************************************************* | ||
*/ | ||
|
||
package coupledL2.utils | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
|
||
// enable signals, only used to check mcp2 hold condition of predecessor regs | ||
class MCP2CheckEn extends Bundle { | ||
val en = Bool() | ||
val wen = Bool() | ||
} | ||
|
||
/** | ||
* Assert the signal must hold for certain cycles when enable is high | ||
*/ | ||
object HoldChecker { | ||
/** | ||
* signal holds at en and the next cycle | ||
*/ | ||
def check2(signal: Data, en: Bool, name: String): Unit = { | ||
// at the 2nd cycle, signal changes | ||
assert(!(RegNext(en) && (signal.asUInt =/= RegNext(signal).asUInt)), | ||
s"signal changed at $name, fails to hold for 2 cycles") | ||
} | ||
|
||
/** | ||
* signal holds for N cycles | ||
*/ | ||
def apply(signal: Data, en: Bool, cycles: Int, name: String): Unit = { | ||
val counter = RegInit(0.U(log2Ceil(cycles).W)) | ||
val data = RegEnable(signal, 0.U.asTypeOf(signal), en) | ||
|
||
when(en) { | ||
counter := cycles.U - 1.U | ||
}.otherwise { | ||
counter := Mux(counter === 0.U, 0.U, counter - 1.U) | ||
} | ||
|
||
assert((counter =/= 0.U) && (signal.asUInt =/= data.asUInt), | ||
s"Signal should hold for $cycles cycles, but it fails") | ||
} | ||
} | ||
|