diff options
Diffstat (limited to 'core/src/main/scala/chisel3/Data.scala')
| -rw-r--r-- | core/src/main/scala/chisel3/Data.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/Data.scala b/core/src/main/scala/chisel3/Data.scala index bb45b4d8..5d398aa6 100644 --- a/core/src/main/scala/chisel3/Data.scala +++ b/core/src/main/scala/chisel3/Data.scala @@ -9,6 +9,8 @@ import chisel3.internal._ import chisel3.internal.firrtl._ import chisel3.internal.sourceinfo.{DeprecatedSourceInfo, SourceInfo, SourceInfoTransform, UnlocatableSourceInfo} +import scala.util.Try + /** User-specified directions. */ sealed abstract class SpecifiedDirection @@ -374,7 +376,7 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc { // Provides a unhelpful fallback for literals, which should have custom rendering per // Data-subtype. // TODO Is this okay for sample_element? It *shouldn't* be visible to users - protected def bindingToString: String = topBindingOpt match { + protected def bindingToString: String = Try(topBindingOpt match { case None => "" case Some(OpBinding(enclosure, _)) => s"(OpResult in ${enclosure.desiredName})" case Some(MemoryPortBinding(enclosure, _)) => s"(MemPort in ${enclosure.desiredName})" @@ -389,7 +391,7 @@ abstract class Data extends HasId with NamedComponent with SourceInfoDoc { case Some(DontCareBinding()) => s"(DontCare)" case Some(ElementLitBinding(litArg)) => s"(unhandled literal)" case Some(BundleLitBinding(litMap)) => s"(unhandled bundle literal)" - } + }).getOrElse("") // Return ALL elements at root of this type. // Contasts with flatten, which returns just Bits |
