generated from chipsalliance/chisel-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exception handle in branch insts and add ArbitraryRegFile (#23)
* fix: fix the exception handle in Branch insts * feat: add GenerateArbitraryRegFile func and update to 1.3-SNAPSHOT * feat: add ArbitraryRegFile in RVConfig * refactor: rename functions * ci: setup BtorMC in Test --------- Co-authored-by: liuyic00 <[email protected]>
- Loading branch information
1 parent
74c204b
commit 0deda76
Showing
9 changed files
with
128 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,7 @@ jobs: | |
java-version: [email protected] | ||
- name: Cache Scala | ||
uses: coursier/cache-action@v5 | ||
- name: Setup BtorMC | ||
uses: SeddonShen/[email protected] | ||
- name: SBT Test | ||
run: sbt test |
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
22 changes: 22 additions & 0 deletions
22
src/main/scala/rvspeccore/checker/ArbitraryGenerater.scala
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,22 @@ | ||
package rvspeccore.checker | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
import chisel3.util.experimental.BoringUtils | ||
|
||
object ArbitraryRegFile { | ||
val uniqueIdArbitraryRegFile = "ArbitraryRegFile" | ||
def gen(implicit XLEN: Int): Vec[UInt] = { | ||
val initval = Wire(Vec(32, UInt(XLEN.W))) | ||
initval := DontCare | ||
BoringUtils.addSink(initval, uniqueIdArbitraryRegFile) | ||
initval | ||
} | ||
def init(implicit XLEN: Int): Vec[UInt] = { | ||
val rf = Wire(Vec(32, UInt(XLEN.W))) | ||
rf.map(_ := DontCare) | ||
rf(0) := 0.U | ||
BoringUtils.addSource(rf, uniqueIdArbitraryRegFile) | ||
rf | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/test/scala/rvspeccore/checker/ArbitraryGeneraterSpec.scala
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,32 @@ | ||
package rvspeccore.checker | ||
|
||
import chisel3._ | ||
import chiseltest._ | ||
import chiseltest.formal._ | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
|
||
class TestArbitraryRegFileModule(hasBug: Boolean) extends Module { | ||
implicit val XLEN: Int = 64 | ||
val io = IO(new Bundle { | ||
val rf = Output(Vec(32, UInt(64.W))) | ||
}) | ||
io.rf := ArbitraryRegFile.gen | ||
ArbitraryRegFile.init | ||
|
||
if (hasBug) { | ||
// this assertion should fail because the rf(1) is arbitrary, could be not 0.U | ||
// will print a "Assertion failed" | ||
assert(io.rf(1) === 0.U) | ||
} else | ||
assert(io.rf(0) === 0.U) | ||
} | ||
|
||
class ArbitraryRegFileSpec extends AnyFlatSpec with Formal with ChiselScalatestTester { | ||
behavior of "ArbitraryRegFile" | ||
it should "be able to create arbitrary regFile init value" in { | ||
verify(new TestArbitraryRegFileModule(false), Seq(BoundedCheck(2), BtormcEngineAnnotation)) | ||
assertThrows[chiseltest.formal.FailedBoundedCheckException] { | ||
verify(new TestArbitraryRegFileModule(true), Seq(BoundedCheck(2), BtormcEngineAnnotation)) | ||
} | ||
} | ||
} |
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