summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAdam Izraelevitz2020-11-02 12:18:46 -0800
committerGitHub2020-11-02 12:18:46 -0800
commitd21fe713aa79b660db3350addd274507dd2edfd4 (patch)
treed732791e7e39548622b8f7794b788cb21a9235cc /src/test
parent0979133b2e67c82f916c2739bbda5df1c692a1d3 (diff)
Bugfix - adding external modules was broken (#1649)
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/chiselTests/aop/InjectionSpec.scala32
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
+ )
+ }
}