diff options
| author | Richard Lin | 2018-05-09 23:38:44 -0700 |
|---|---|---|
| committer | Richard Lin | 2018-07-04 18:39:28 -0500 |
| commit | 95f1e17d8402b2fb8120b8f60d5b110f0b009a60 (patch) | |
| tree | ae7bab41ab4a9ab420547addeeba8ac3f7b0366c /chiselFrontend/src/main/scala/chisel3/core/Bits.scala | |
| parent | 7834f0ada9f8bcfc28c1d6124f63acdcaa2d4755 (diff) | |
refactoring of lit and ref implementations
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Bits.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Bits.scala | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala index 8368a812..b0edd687 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala @@ -75,13 +75,10 @@ sealed abstract class Bits(width: Width) def cloneType: this.type = cloneTypeWidth(width) - protected def litArgOption: Option[LitArg] = bindingOpt match { - case Some(_) => topBinding match { - case ElementLitBinding(litArg) => Some(litArg) - case BundleLitBinding(litMap) => litMap.get(this) match { - case Some(litArg) => Some(litArg) - case _ => None - } + protected def litArgOption: Option[LitArg] = topBindingOpt match { + case Some(ElementLitBinding(litArg)) => Some(litArg) + case Some(BundleLitBinding(litMap)) => litMap.get(this) match { + case Some(litArg) => Some(litArg) case _ => None } case _ => None @@ -97,6 +94,12 @@ sealed abstract class Bits(width: Width) case _ => None } + // provide bits-specific literal handling functionality here + override private[chisel3] def ref: Arg = topBindingOpt match { + case Some(binding: LitBinding) => binding.asInstanceOf[ElementLitBinding].litArg + case _ => super.ref + } + final def tail(n: Int): UInt = macro SourceInfoTransform.nArg final def head(n: Int): UInt = macro SourceInfoTransform.nArg |
