diff options
| author | ducky | 2018-05-02 11:45:22 -0700 |
|---|---|---|
| committer | Richard Lin | 2018-07-04 18:39:28 -0500 |
| commit | b74034446223db6731c7e4f2eb362b3349efc8be (patch) | |
| tree | 317b55c2c2a11217dc452addb427e57bdac3a2c5 /chiselFrontend/src/main/scala/chisel3/core/Data.scala | |
| parent | 3d8064a9f2fd49bffb402b91131087c19ca7d6fc (diff) | |
Infrastructure for bundle literals
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Data.scala | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index e85bee42..36aec383 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -364,8 +364,25 @@ abstract class Data extends HasId with NamedComponent { final def := (that: Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit = this.connect(that)(sourceInfo, connectionCompileOptions) final def <> (that: Data)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Unit = this.bulkConnect(that)(sourceInfo, connectionCompileOptions) - def litArg(): Option[LitArg] = None + + @chiselRuntimeDeprecated + @deprecated("Literal accessors on Data are deprecated, a replacement is pending", "chisel3.2") + def litArg(): 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 // DontCares in a bundle literal are treated as non-literal + } + case _ => None + } + case _ => None + } + @chiselRuntimeDeprecated + @deprecated("Literal accessors on Data are deprecated, a replacement is pending", "chisel3.2") def litValue(): BigInt = litArg.get.num + @chiselRuntimeDeprecated + @deprecated("Literal accessors on Data are deprecated, a replacement is pending", "chisel3.2") def isLit(): Boolean = litArg.isDefined /** Returns the width, in bits, if currently known. |
