forked from OpenXiangShan/HuanCun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01a0941
commit 1d6448f
Showing
7 changed files
with
67 additions
and
15 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 |
---|---|---|
|
@@ -41,3 +41,6 @@ jobs: | |
|
||
- name: Compile | ||
run: make compile | ||
|
||
- name: Unit test | ||
run: make 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
out/ | ||
.idea/ | ||
.idea_modules/ | ||
test_run_dir/ | ||
|
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package HuanCun | ||
|
||
import org.scalatest._ | ||
import chiseltest._ | ||
import chisel3._ | ||
import chiseltest.experimental.TestOptionBuilder.ChiselScalatestOptionBuilder | ||
import freechips.rocketchip.diplomacy.{AddressSet, LazyModule, LazyModuleImp, LazyModuleImpLike} | ||
import freechips.rocketchip.tilelink.{TLCacheCork, TLFuzzer, TLIdentityNode, TLRAM} | ||
|
||
class BasicTester extends L2Tester { | ||
|
||
class TestTop extends LazyModule { | ||
val cache = LazyModule(new HuanCun()) | ||
val fuzzer = LazyModule(new TLFuzzer( | ||
nOperations = 2 * cache.cacheParams.mshrs, inFlight = cache.cacheParams.mshrs | ||
)) | ||
val ram = LazyModule(new TLRAM(AddressSet(0, 0xffff))) | ||
|
||
ram.node := TLCacheCork() := cache.node := fuzzer.node | ||
lazy val module = new LazyModuleImp(this){ | ||
val pass = IO(Output(Bool())) | ||
pass := fuzzer.module.io.finished | ||
} | ||
} | ||
|
||
it should "read and write TLRAM correctly" in { | ||
|
||
val top = LazyModule(new TestTop) | ||
|
||
test(top.module).withAnnotations(testAnnos) { dut => | ||
while(!dut.pass.peek().litToBoolean){ | ||
dut.clock.step(1) | ||
} | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package HuanCun | ||
|
||
import chipsalliance.rocketchip.config.Config | ||
import chiseltest._ | ||
import chiseltest.internal.VerilatorBackendAnnotation | ||
import firrtl.AnnotationSeq | ||
import org.scalatest.flatspec._ | ||
import org.scalatest.matchers.should._ | ||
|
||
abstract class L2Tester extends AnyFlatSpec with ChiselScalatestTester with Matchers { | ||
behavior of "L2" | ||
implicit val defaultConfig = new Config((_, _, _) => { | ||
case CacheParamsKey => CacheParameters() | ||
}) | ||
var testAnnos: AnnotationSeq = Seq() | ||
} | ||
|
||
trait WithVerilatorBackend { this: L2Tester => | ||
testAnnos = testAnnos :+ VerilatorBackendAnnotation | ||
} |