diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/aop/InjectionSpec.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/aop/InjectionSpec.scala b/src/test/scala/chiselTests/aop/InjectionSpec.scala index 60233f48..c9fa2e5e 100644 --- a/src/test/scala/chiselTests/aop/InjectionSpec.scala +++ b/src/test/scala/chiselTests/aop/InjectionSpec.scala @@ -27,6 +27,19 @@ object InjectionHierarchy { }) } + class SubmoduleC extends experimental.ExtModule with util.HasExtModuleInline { + val io = IO(new Bundle { + val in = Input(Bool()) + }) + //scalastyle:off regex + setInline("SubmoduleC.v", s""" + |module SubmoduleC( + | input io_in + |); + |endmodule + """.stripMargin) + } + class AspectTester(results: Seq[Int]) extends BasicTester { val values = VecInit(results.map(_.U)) val counter = RegInit(0.U(results.length.W)) @@ -81,6 +94,17 @@ class InjectionSpec extends ChiselFlatSpec with Utils { } ) + val addingExternalModules = InjectingAspect( + {dut: SubmoduleManipulationTester => Seq(dut)}, + {_: SubmoduleManipulationTester => + // By creating a second SubmoduleA, the module names would conflict unless they were uniquified + val moduleSubmoduleC = Module(new SubmoduleC) + //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)) } } @@ -110,4 +134,12 @@ class InjectionSpec extends ChiselFlatSpec with Utils { Seq(duplicateSubmoduleAspect) ++ TesterDriver.verilatorOnly ) } + + "Adding external modules" should "work" in { + assertTesterPasses( + { new SubmoduleManipulationTester}, + Nil, + Seq(addingExternalModules) ++ TesterDriver.verilatorOnly + ) + } } |
