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.
feat: add ArbitraryRegFile in RVConfig
- Loading branch information
Showing
7 changed files
with
76 additions
and
30 deletions.
There are no files selected for viewing
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 genSink(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 was deleted.
Oops, something went wrong.
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.genSink | ||
ArbitraryRegFile.init | ||
|
||
if (hasBug) | ||
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] { | ||
// fail because the rf(1) is Arbitrary, could be not 0.U | ||
// this will print a "Assertion failed at ArbitraryGeneraterSpec.scala:17 assert(io.rf(1) === 0.U)" | ||
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