diff options
| author | Justin Deters | 2020-08-11 18:28:12 -0500 |
|---|---|---|
| committer | GitHub | 2020-08-11 23:28:12 +0000 |
| commit | e0c805171ddb9707b0f9fe93e5d85ef9cdcab044 (patch) | |
| tree | 8b331390b99204b72c7abfab67351845b685f06c /src/test | |
| parent | 3668532fabc4ba4eaf70cf0ad1a55522aa33cdb3 (diff) | |
Bug fix for manipulating submodules in aspects (#1538)
* Fixed the aspect as parent bug in Data and MonoConnect
* refactored and cleaned up finding an aspect parent
* Added aspect fix to the BiConnect class
* added unit test for manipulating submodules via aspects
* Refactored to move determination of proper parent to Builder and made logic simpler in MonoConnect, Data, and BiConnect
* Removed unused function and provided Scaladoc for retrieveParent
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/aop/InjectionSpec.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/aop/InjectionSpec.scala b/src/test/scala/chiselTests/aop/InjectionSpec.scala index 7e09bd54..3f41d598 100644 --- a/src/test/scala/chiselTests/aop/InjectionSpec.scala +++ b/src/test/scala/chiselTests/aop/InjectionSpec.scala @@ -7,6 +7,23 @@ import chiselTests.ChiselFlatSpec import chisel3._ import chisel3.aop.injecting.InjectingAspect +class SubmoduleManipulationTester extends BasicTester { + val moduleSubmoduleA = Module(new SubmoduleA) +} + +class SubmoduleA extends Module { + val io = IO(new Bundle { + val out = Output(Bool()) + }) + io.out := false.B +} + +class SubmoduleB extends Module { + val io = IO(new Bundle { + val in = Input(Bool()) + }) +} + class AspectTester(results: Seq[Int]) extends BasicTester { val values = VecInit(results.map(_.U)) val counter = RegInit(0.U(results.length.W)) @@ -40,6 +57,16 @@ class InjectionSpec extends ChiselFlatSpec { } ) + val manipulateSubmoduleAspect = InjectingAspect( + {dut: SubmoduleManipulationTester => Seq(dut)}, + {dut: SubmoduleManipulationTester => + val moduleSubmoduleB = Module(new SubmoduleB) + moduleSubmoduleB.io.in := dut.moduleSubmoduleA.io.out + //if we're here then we've elaborated correctly + stop() + } + ) + "Test" should "pass if inserted the correct values" in { assertTesterPasses{ new AspectTester(Seq(0, 1, 2)) } } @@ -57,4 +84,8 @@ class InjectionSpec extends ChiselFlatSpec { "Test" should "fail if pass wrong values, then correct aspect, then wrong aspect" in { assertTesterFails({ new AspectTester(Seq(9, 9, 9))} , Nil, Seq(correctValueAspect, wrongValueAspect)) } + + "Test" should "pass if the submodules in SubmoduleManipulationTester can be manipulated by manipulateSubmoduleAspect" in { + assertTesterPasses({ new SubmoduleManipulationTester} , Nil, Seq(manipulateSubmoduleAspect) ++ TesterDriver.verilatorOnly) + } } |
