From e0c805171ddb9707b0f9fe93e5d85ef9cdcab044 Mon Sep 17 00:00:00 2001 From: Justin Deters Date: Tue, 11 Aug 2020 18:28:12 -0500 Subject: 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--- src/test/scala/chiselTests/aop/InjectionSpec.scala | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/test/scala') 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) + } } -- cgit v1.2.3