From b74034446223db6731c7e4f2eb362b3349efc8be Mon Sep 17 00:00:00 2001 From: ducky Date: Wed, 2 May 2018 11:45:22 -0700 Subject: Infrastructure for bundle literals --- chiselFrontend/src/main/scala/chisel3/core/Data.scala | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala') 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. -- cgit v1.2.3