summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Bits.scala9
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala12
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala2
-rw-r--r--src/main/scala/chisel3/compatibility.scala1
-rw-r--r--src/main/scala/chisel3/compatibility/FileSystemUtilities.scala12
-rw-r--r--src/main/scala/chisel3/util/OneHot.scala2
6 files changed, 14 insertions, 24 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
index 9ef46402..7a3962a0 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Bits.scala
@@ -245,15 +245,6 @@ sealed abstract class Bits(width: Width, override val litArg: Option[LitArg])
def do_asSInt(implicit sourceInfo: SourceInfo): SInt
- /** Reinterpret cast to an 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
-
/** Reinterpret cast to Bits. */
final def asBits(): Bits = macro SourceInfoTransform.noArg
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index 73470383..8c874070 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -184,6 +184,18 @@ abstract class Data extends HasId {
*/
@deprecated("Use asBits, which makes the reinterpret cast more explicit and actually returns Bits", "chisel3")
def toBits(): UInt = SeqUtils.do_asUInt(this.flatten)(DeprecatedSourceInfo)
+
+ /** Reinterpret cast to 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
+ * @note Aggregates are recursively packed with the first element appearing
+ * in the least-significant bits of the result.
+ */
+ final def asUInt(): UInt = macro SourceInfoTransform.noArg
+
+ def do_asUInt(implicit sourceInfo: SourceInfo): UInt =
+ SeqUtils.do_asUInt(this.flatten)(sourceInfo)
}
object Wire {
diff --git a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala
index 0872ec41..63bcc87f 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala
@@ -47,7 +47,7 @@ private[chisel3] object SeqUtils {
if (in.tail.isEmpty) {
in.head._2
} else {
- val masked = for ((s, i) <- in) yield Mux(s, i.toBits, Bits(0))
+ val masked = for ((s, i) <- in) yield Mux(s, i.asUInt, UInt(0))
val width = in.map(_._2.width).reduce(_ max _)
in.head._2.cloneTypeWidth(width).fromBits(masked.reduceLeft(_|_))
}
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index d4ad7b9f..5624b79c 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -100,7 +100,6 @@ package object Chisel {
type BackendCompilationUtilities = chisel3.BackendCompilationUtilities
val Driver = chisel3.Driver
- type FileSystemUtilities = chisel3.compatibility.FileSystemUtilities
val ImplicitConversions = chisel3.util.ImplicitConversions
val chiselMain = chisel3.compatibility.chiselMain
val throwException = chisel3.compatibility.throwException
diff --git a/src/main/scala/chisel3/compatibility/FileSystemUtilities.scala b/src/main/scala/chisel3/compatibility/FileSystemUtilities.scala
deleted file mode 100644
index cd47c731..00000000
--- a/src/main/scala/chisel3/compatibility/FileSystemUtilities.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-// See LICENSE for license details.
-
-package chisel3.compatibility
-
-import chisel3._
-
-@deprecated("FileSystemUtilities doesn't exist in chisel3", "3.0.0")
-trait FileSystemUtilities {
- def createOutputFile(name: String): java.io.FileWriter = {
- new java.io.FileWriter(Driver.targetDir + "/" + name)
- }
-}
diff --git a/src/main/scala/chisel3/util/OneHot.scala b/src/main/scala/chisel3/util/OneHot.scala
index abede61e..7e04a8d7 100644
--- a/src/main/scala/chisel3/util/OneHot.scala
+++ b/src/main/scala/chisel3/util/OneHot.scala
@@ -11,7 +11,7 @@ import chisel3._
* This is the inverse of [[Chisel.UIntToOH UIntToOH]]*/
object OHToUInt {
def apply(in: Seq[Bool]): UInt = apply(Cat(in.reverse), in.size)
- def apply(in: Vec[Bool]): UInt = apply(in.toBits, in.size)
+ def apply(in: Vec[Bool]): UInt = apply(in.asUInt, in.size)
def apply(in: Bits): UInt = apply(in, in.getWidth)
def apply(in: Bits, width: Int): UInt = {