Skip to content

Commit

Permalink
Improve desiredName for nested objects/classes
Browse files Browse the repository at this point in the history
Signed-off-by: Schuyler Eldridge <[email protected]>
  • Loading branch information
seldridge committed Oct 7, 2019
1 parent 896cad0 commit b8f68f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion chiselFrontend/src/main/scala/chisel3/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ package experimental {
/** Desired name of this module. Override this to give this module a custom, perhaps parametric,
* name.
*/
def desiredName: String = this.getClass.getName.split('.').last
def desiredName: String = this.getClass.getName.split("\\.|\\$").last

/** Legalized name of this module. */
final lazy val name = try {
Expand Down
16 changes: 8 additions & 8 deletions src/test/scala/chiselTests/DataPrint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ class DataPrintSpec extends ChiselFlatSpec with Matchers {
}

class BoundDataModule extends MultiIOModule { // not in the test to avoid anon naming suffixes
Wire(UInt()).toString should be("UInt(Wire in DataPrintSpec$BoundDataModule)")
Reg(SInt()).toString should be("SInt(Reg in DataPrintSpec$BoundDataModule)")
Wire(UInt()).toString should be("UInt(Wire in BoundDataModule)")
Reg(SInt()).toString should be("SInt(Reg in BoundDataModule)")
val io = IO(Output(Bool())) // needs a name so elaboration doesn't fail
io.toString should be("Bool(IO in unelaborated DataPrintSpec$BoundDataModule)")
io.toString should be("Bool(IO in unelaborated BoundDataModule)")
val m = Mem(4, UInt(2.W))
m(2).toString should be("UInt<2>(MemPort in DataPrintSpec$BoundDataModule)")
(2.U + 2.U).toString should be("UInt<2>(OpResult in DataPrintSpec$BoundDataModule)")
Wire(Vec(3, UInt(2.W))).toString should be ("UInt<2>[3](Wire in DataPrintSpec$BoundDataModule)")
m(2).toString should be("UInt<2>(MemPort in BoundDataModule)")
(2.U + 2.U).toString should be("UInt<2>(OpResult in BoundDataModule)")
Wire(Vec(3, UInt(2.W))).toString should be ("UInt<2>[3](Wire in BoundDataModule)")

class InnerModule extends MultiIOModule {
val io = IO(Output(new Bundle {
val a = UInt(4.W)
}))
}
val inner = Module(new InnerModule)
inner.clock.toString should be ("Clock(IO clock in DataPrintSpec$BoundDataModule$InnerModule)")
inner.io.a.toString should be ("UInt<4>(IO io_a in DataPrintSpec$BoundDataModule$InnerModule)")
inner.clock.toString should be ("Clock(IO clock in InnerModule)")
inner.io.a.toString should be ("UInt<4>(IO io_a in InnerModule)")
}

"Bound data types" should "have a meaningful string representation" in {
Expand Down

0 comments on commit b8f68f1

Please sign in to comment.