Skip to content

Commit

Permalink
Implement Lookupable for Unit
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoenig committed Nov 7, 2024
1 parent abf74af commit 9d0c9d5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)), ())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 9d0c9d5

Please sign in to comment.