Skip to content

Commit b8f68f1

Browse files
committed
Improve desiredName for nested objects/classes
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
1 parent 896cad0 commit b8f68f1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

chiselFrontend/src/main/scala/chisel3/Module.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ package experimental {
221221
/** Desired name of this module. Override this to give this module a custom, perhaps parametric,
222222
* name.
223223
*/
224-
def desiredName: String = this.getClass.getName.split('.').last
224+
def desiredName: String = this.getClass.getName.split("\\.|\\$").last
225225

226226
/** Legalized name of this module. */
227227
final lazy val name = try {

src/test/scala/chiselTests/DataPrint.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ class DataPrintSpec extends ChiselFlatSpec with Matchers {
3333
}
3434

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

4545
class InnerModule extends MultiIOModule {
4646
val io = IO(Output(new Bundle {
4747
val a = UInt(4.W)
4848
}))
4949
}
5050
val inner = Module(new InnerModule)
51-
inner.clock.toString should be ("Clock(IO clock in DataPrintSpec$BoundDataModule$InnerModule)")
52-
inner.io.a.toString should be ("UInt<4>(IO io_a in DataPrintSpec$BoundDataModule$InnerModule)")
51+
inner.clock.toString should be ("Clock(IO clock in InnerModule)")
52+
inner.io.a.toString should be ("UInt<4>(IO io_a in InnerModule)")
5353
}
5454

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

0 commit comments

Comments
 (0)