Skip to content

Commit

Permalink
Fix .toString for dynamic indexing (#4260)
Browse files Browse the repository at this point in the history
(cherry picked from commit 95b7fcc)
  • Loading branch information
jackkoenig authored and mergify[bot] committed Jul 10, 2024
1 parent 2bc4859 commit 16a8938
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/internal/firrtl/IR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private[chisel3] object ir {

def earlyLocalName(id: HasId, includeRoot: Boolean): String = id.getOptionRef match {
case Some(Index(Node(imm), Node(value))) =>
s"${earlyLocalName(imm, includeRoot)}[${earlyLocalName(imm, includeRoot)}]"
s"${earlyLocalName(imm, includeRoot)}[${earlyLocalName(value, includeRoot)}]"
case Some(Index(Node(imm), arg)) => s"${earlyLocalName(imm, includeRoot)}[${arg.localName}]"
case Some(Slot(Node(imm), name)) => s"${earlyLocalName(imm, includeRoot)}.$name"
case Some(OpaqueSlot(Node(imm))) => s"${earlyLocalName(imm, includeRoot)}"
Expand Down
10 changes: 10 additions & 0 deletions src/test/scala/chiselTests/DataPrint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ class DataPrintSpec extends ChiselFlatSpec with Matchers {
(2.U + 2.U).toString should be("BoundDataModule.?: OpResult[UInt<2>]")
Wire(Vec(3, UInt(2.W))).toString should be("BoundDataModule.?: Wire[UInt<2>[3]]")

val idx = IO(Input(UInt(3.W)))
val jdx = IO(Input(new Bundle {
val value = UInt(3.W)
}))
val port = IO(Input(new Bundle {
val vec = Vec(8, UInt(8.W))
}))
port.vec(idx).toString should be("BoundDataModule.port.vec[idx]: IO[UInt<8>]")
port.vec(jdx.value).toString should be("BoundDataModule.port.vec[jdx.value]: IO[UInt<8>]")

class InnerModule extends Module {
val io = IO(Output(new Bundle {
val a = UInt(4.W)
Expand Down

0 comments on commit 16a8938

Please sign in to comment.