diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala b/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala index df3f702100..29216c0413 100644 --- a/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala +++ b/core/src/main/scala/chisel3/experimental/hierarchy/core/Lookupable.scala @@ -552,4 +552,5 @@ object Lookupable { implicit val lookupString: SimpleLookupable[String] = new SimpleLookupable[String]() implicit val lookupBoolean: SimpleLookupable[Boolean] = new SimpleLookupable[Boolean]() implicit val lookupBigInt: SimpleLookupable[BigInt] = new SimpleLookupable[BigInt]() + implicit val lookupUnit: SimpleLookupable[Unit] = new SimpleLookupable[Unit]() } diff --git a/src/test/scala/chiselTests/experimental/hierarchy/Examples.scala b/src/test/scala/chiselTests/experimental/hierarchy/Examples.scala index 2843797eae..18db2e9e83 100644 --- a/src/test/scala/chiselTests/experimental/hierarchy/Examples.scala +++ b/src/test/scala/chiselTests/experimental/hierarchy/Examples.scala @@ -369,4 +369,11 @@ object Examples { out := copy.out } + + @instantiable + class HasPublicUnit extends Module { + @public val x: Unit = () + // Should also work in type-parameterized lookupable things + @public val y: (Data, Unit) = (Wire(UInt(3.W)), ()) + } } diff --git a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala index 0bf63a7dc2..9bc6e0ef36 100644 --- a/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala +++ b/src/test/scala/chiselTests/experimental/hierarchy/InstanceSpec.scala @@ -474,6 +474,18 @@ class InstanceSpec extends ChiselFunSpec with Utils { MarkAnnotation("~Top|Top/i:HasHasTarget>sram_sram".rt, "x") ) } + it("(3.s): should work on Unit") { + class Top extends Module { + val i = Instance(Definition(new HasPublicUnit)) + i.x should be(()) + mark(i.y._1, "y_1") + i.y._2 should be(()) + } + val (_, annos) = getFirrtlAndAnnos(new Top) + annos.collect { case c: MarkAnnotation => c } should contain( + MarkAnnotation("~Top|Top/i:HasPublicUnit>y_1".rt, "y_1") + ) + } } describe("(4) toInstance") { it("(4.a): should work on modules") {