summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/aop
diff options
context:
space:
mode:
authorAdam Izraelevitz2021-09-05 12:11:32 -0700
committerGitHub2021-09-05 12:11:32 -0700
commit9fa8da227569455a77596355aeb114f9c164510a (patch)
tree3be3dd579fcc7ae83297d3c28020e97417a6b984 /src/test/scala/chiselTests/aop
parent7fb2c1ebc23ca07e5de6416a284e1be1b62a48ac (diff)
Add Definition and Instance API (#2045)
This introduces a new experimental API for module instantiation that disentagles elaborating the definition (or implementation) from instantiation of a given module. This solves Chisel's longstanding reliance on "Deduplication" for generating Verilog with multiple instances of the same module. The new API resides in package chisel3.experimental.hierarchy. Please see the hierarchy ScalaDoc, documentation, and tests for examples of use. Co-authored-by: Jack Koenig <koenig@sifive.com> Co-authored-by: Megan Wachs <megan@sifive.com> Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Diffstat (limited to 'src/test/scala/chiselTests/aop')
-rw-r--r--src/test/scala/chiselTests/aop/SelectSpec.scala31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/test/scala/chiselTests/aop/SelectSpec.scala b/src/test/scala/chiselTests/aop/SelectSpec.scala
index 46c62d67..e09e78c8 100644
--- a/src/test/scala/chiselTests/aop/SelectSpec.scala
+++ b/src/test/scala/chiselTests/aop/SelectSpec.scala
@@ -163,7 +163,7 @@ class SelectSpec extends ChiselFlatSpec {
val out = IO(Output(UInt(8.W)))
out := in
}
- class Top extends MultiIOModule {
+ class Top extends Module {
val in = IO(Input(UInt(8.W)))
val out = IO(Output(UInt(8.W)))
val inst0 = Module(new Child)
@@ -182,5 +182,34 @@ class SelectSpec extends ChiselFlatSpec {
Select.instances(top) should equal (Seq(top.inst0))
}
+ "Using Definition/Instance with Injecting Aspects" should "throw an error" in {
+ import chisel3.experimental.CloneModuleAsRecord
+ import chisel3.experimental.hierarchy._
+ @instantiable
+ class Child extends RawModule {
+ @public val in = IO(Input(UInt(8.W)))
+ @public val out = IO(Output(UInt(8.W)))
+ out := in
+ }
+ class Top extends Module {
+ val in = IO(Input(UInt(8.W)))
+ val out = IO(Output(UInt(8.W)))
+ val definition = Definition(new Child)
+ val inst0 = Instance(definition)
+ val inst1 = Instance(definition)
+ inst0.in := in
+ inst1.in := inst0.out
+ out := inst1.out
+ }
+ val top = ChiselGeneratorAnnotation(() => {
+ new Top()
+ }).elaborate
+ .collectFirst { case DesignAnnotation(design: Top) => design }
+ .get
+ intercept[Exception] { Select.collectDeep(top) { case x => x } }
+ intercept[Exception] { Select.getDeep(top)(x => Seq(x)) }
+ intercept[Exception] { Select.instances(top) }
+ }
+
}