From 556ce6398e2f23d1f796d4626b4010f00726f4cd Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Thu, 10 Feb 2022 01:50:28 +0000 Subject: Make Tuple2 Lookupable (#2372) (#2406) (cherry picked from commit 024847d75079a125e5946e9dcf2ed9c14d2db730) Co-authored-by: Megan Wachs --- .../chiselTests/experimental/hierarchy/InstanceSpec.scala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala') diff --git a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala index 45d1f85f..9683d648 100644 --- a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala +++ b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala @@ -298,7 +298,18 @@ class InstanceSpec extends ChiselFunSpec with Utils { annos should contain(MarkAnnotation("~Top|Top/i:HasEither>x".rt, "xright")) annos should contain(MarkAnnotation("~Top|Top/i:HasEither>y".rt, "yleft")) } - it("3.12: should properly support val modifiers") { + it("3.12: should work on tuple2") { + class Top() extends Module { + val i = Instance(Definition(new HasTuple2())) + mark(i.xy._1, "x") + mark(i.xy._2, "y") + } + val (_, annos) = getFirrtlAndAnnos(new Top) + annos should contain(MarkAnnotation("~Top|Top/i:HasTuple2>x".rt, "x")) + annos should contain(MarkAnnotation("~Top|Top/i:HasTuple2>y".rt, "y")) + } + + it("3.13: should properly support val modifiers") { class SupClass extends Module { val value = 10 val overriddenVal = 10 -- cgit v1.2.3 From be4feccad0d4fe487a0bea57cb44702c08831429 Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Fri, 11 Feb 2022 21:46:50 +0000 Subject: Hierarchy API: make Mems lookupable (#2404) (#2410) (cherry picked from commit 2a985ac376698a2e6300fbee13001d82d3e13989) Co-authored-by: Deborah Soung --- .../chiselTests/experimental/hierarchy/InstanceSpec.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala') diff --git a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala index 9683d648..407a7237 100644 --- a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala +++ b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala @@ -331,6 +331,17 @@ class InstanceSpec extends ChiselFunSpec with Utils { @public override final lazy val y: Int = 4 } } + it("3.13: should work with Mems/SyncReadMems") { + class Top() extends Module { + val i = Instance(Definition(new HasMems())) + mark(i.mem, "Mem") + mark(i.syncReadMem, "SyncReadMem") + } + val (_, annos) = getFirrtlAndAnnos(new Top) + annos.foreach { x => println(x.serialize) } + annos should contain(MarkAnnotation("~Top|Top/i:HasMems>mem".rt, "Mem")) + annos should contain(MarkAnnotation("~Top|Top/i:HasMems>syncReadMem".rt, "SyncReadMem")) + } } describe("4: toInstance") { it("4.0: should work on modules") { -- cgit v1.2.3 From 4ee545d7706a2d2ba59902fb86a4393287327a9a Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Wed, 9 Mar 2022 20:40:25 +0000 Subject: Support BlackBoxes in D/I (#2438) (#2442) Also delete an errant println in InstanceSpec (cherry picked from commit 3462c54c018a52a377f1c89121b6ed99c5b0ae1d) Co-authored-by: Jack Koenig --- .../experimental/hierarchy/InstanceSpec.scala | 69 +++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala') diff --git a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala index 407a7237..8d8f7ea5 100644 --- a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala +++ b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala @@ -43,6 +43,29 @@ class InstanceSpec extends ChiselFunSpec with Utils { val (chirrtl, _) = getFirrtlAndAnnos(new Top) chirrtl.serialize should include("inst i0 of AddOne") } + it("0.3: BlackBoxes should be supported") { + class Top extends Module { + val in = IO(Input(UInt(32.W))) + val out = IO(Output(UInt(32.W))) + val io = IO(new Bundle { + val in = Input(UInt(32.W)) + val out = Output(UInt(32.W)) + }) + val definition = Definition(new AddOneBlackBox) + val i0 = Instance(definition) + val i1 = Instance(definition) + i0.io.in := in + out := i0.io.out + io <> i1.io + } + val chirrtl = getFirrtlAndAnnos(new Top)._1.serialize + chirrtl should include("inst i0 of AddOneBlackBox") + chirrtl should include("inst i1 of AddOneBlackBox") + chirrtl should include("i0.in <= in") + chirrtl should include("out <= i0.out") + chirrtl should include("i1.in <= io.in") + chirrtl should include("io.out <= i1.out") + } } describe("1: Annotations on instances in same chisel compilation") { it("1.0: should work on a single instance, annotating the instance") { @@ -338,7 +361,6 @@ class InstanceSpec extends ChiselFunSpec with Utils { mark(i.syncReadMem, "SyncReadMem") } val (_, annos) = getFirrtlAndAnnos(new Top) - annos.foreach { x => println(x.serialize) } annos should contain(MarkAnnotation("~Top|Top/i:HasMems>mem".rt, "Mem")) annos should contain(MarkAnnotation("~Top|Top/i:HasMems>syncReadMem".rt, "SyncReadMem")) } @@ -717,6 +739,51 @@ class InstanceSpec extends ChiselFunSpec with Utils { annos should contain(e) } } + + it("7.4: should work on Views of BlackBoxes") { + @instantiable + class MyBlackBox extends BlackBox { + @public val io = IO(new Bundle { + val in = Input(UInt(8.W)) + val out = Output(UInt(8.W)) + }) + @public val innerView = io.viewAs + @public val foo = io.in.viewAs[UInt] + @public val bar = io.out.viewAs[UInt] + } + class Top extends RawModule { + val foo = IO(Input(UInt(8.W))) + val bar = IO(Output(UInt(8.W))) + val i = Instance(Definition(new MyBlackBox)) + val outerView = i.io.viewAs + i.foo := foo + bar := i.bar + mark(i.foo, "i.foo") + mark(i.bar, "i.bar") + mark(i.innerView.in, "i.innerView.in") + mark(outerView.out, "outerView.out") + } + val inst = "~Top|Top/i:MyBlackBox" + val expectedAnnos = List( + s"$inst>in".rt -> "i.foo", + s"$inst>out".rt -> "i.bar", + s"$inst>in".rt -> "i.innerView.in", + s"$inst>out".rt -> "outerView.out" + ) + val expectedLines = List( + "i.in <= foo", + "bar <= i.out" + ) + val (chirrtl, annos) = getFirrtlAndAnnos(new Top) + val text = chirrtl.serialize + for (line <- expectedLines) { + text should include(line) + } + for (e <- expectedAnnos.map(MarkAnnotation.tupled)) { + annos should contain(e) + } + } + } describe("8: @instantiable and @public should compose with CloneModuleAsRecord") { -- cgit v1.2.3