summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/Chisel/Data.scala
diff options
context:
space:
mode:
authorchick2016-06-06 15:32:33 -0700
committerchick2016-06-06 15:32:33 -0700
commit43124af2f3eab9a3491dd2c83c1922b1b7e07c2a (patch)
tree2f49304edeb9de95eaaec47599b812c042195ecb /chiselFrontend/src/main/scala/Chisel/Data.scala
parente98f9656591925464c42db70641d3cfa501f108a (diff)
moved macro def for toUInt() int to Data and made do_asUInt (the macro target) there as an abstract method.
This left clock without a do_asUInt, that has been implemented as an exception at this time
Diffstat (limited to 'chiselFrontend/src/main/scala/Chisel/Data.scala')
-rw-r--r--chiselFrontend/src/main/scala/Chisel/Data.scala15
1 files changed, 14 insertions, 1 deletions
diff --git a/chiselFrontend/src/main/scala/Chisel/Data.scala b/chiselFrontend/src/main/scala/Chisel/Data.scala
index adb4ff7b..b953df71 100644
--- a/chiselFrontend/src/main/scala/Chisel/Data.scala
+++ b/chiselFrontend/src/main/scala/Chisel/Data.scala
@@ -120,7 +120,15 @@ abstract class Data(dirArg: Direction) extends HasId {
@deprecated("Best alternative, .toUInt() or if Bits really needed, .toUInt().toBits()", "chisel3")
def toBits(): UInt = SeqUtils.do_asUInt(this.flatten)(DeprecatedSourceInfo)
-// def asBits(): Bits
+ /** Reinterpret cast to a UInt.
+ *
+ * @note value not guaranteed to be preserved: for example, a SInt of width
+ * 3 and value -1 (0b111) would become an UInt with value 7
+ */
+ final def asUInt(): UInt = macro SourceInfoTransform.noArg
+
+ def do_asUInt(implicit sourceInfo: SourceInfo): UInt
+
}
object Wire {
@@ -160,4 +168,9 @@ sealed class Clock(dirArg: Direction) extends Element(dirArg, Width(1)) {
case _: Clock => this connect that
case _ => this badConnect that
}
+
+ def do_asUInt(implicit sourceInfo: SourceInfo): UInt = {
+ throwException("clock cannot be interpreted as UInt")
+ }
+
}