summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorRichard Lin2017-04-26 17:52:29 -0700
committerGitHub2017-04-26 17:52:29 -0700
commit36718cf6040990f2be9ab143adb1d3c519e9d983 (patch)
tree34ae121faf999bb962f5257c26de651bd08ecf04 /src/main
parent7449fdc9043708e426aeb8b12b30226db9e47a80 (diff)
Deprecate fromBits and clock/reset constructors (#583)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/chisel3/compatibility.scala35
-rw-r--r--src/main/scala/chisel3/package.scala10
-rw-r--r--src/main/scala/chisel3/util/Decoupled.scala17
3 files changed, 51 insertions, 11 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index 778d2c13..d64b3bb5 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -37,6 +37,26 @@ package object Chisel { // scalastyle:ignore package.object.name
val Clock = chisel3.core.Clock
type Clock = chisel3.core.Clock
+ // Implicit conversion to allow fromBits because it's being deprecated in chisel3
+ implicit class fromBitsable[T <: Data](val data: T) {
+ import chisel3.core.CompileOptions
+ import chisel3.internal.sourceinfo.SourceInfo
+
+ /** Creates an new instance of this type, unpacking the input Bits into
+ * structured data.
+ *
+ * This performs the inverse operation of toBits.
+ *
+ * @note does NOT assign to the object this is called on, instead creates
+ * and returns a NEW object (useful in a clone-and-assign scenario)
+ * @note does NOT check bit widths, may drop bits during assignment
+ * @note what fromBits assigs to must have known widths
+ */
+ def fromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
+ that.asTypeOf(data)
+ }
+ }
+
type Aggregate = chisel3.core.Aggregate
val Vec = chisel3.core.Vec
type Vec[T <: Data] = chisel3.core.Vec[T]
@@ -155,7 +175,7 @@ package object Chisel { // scalastyle:ignore package.object.name
import chisel3.core.Param
abstract class BlackBox(params: Map[String, Param] = Map.empty[String, Param]) extends chisel3.core.BlackBox(params) {
// This class auto-wraps the BlackBox with IO(...), allowing legacy code (where IO(...) wasn't
- // required) to build.
+ // required) to build.
override def _autoWrapPorts() = {
if (!_ioPortBound()) {
IO(io)
@@ -176,10 +196,13 @@ package object Chisel { // scalastyle:ignore package.object.name
// This class auto-wraps the Module IO with IO(...), allowing legacy code (where IO(...) wasn't
// required) to build.
// Also provides the clock / reset constructors, which were used before withClock happened.
-
- def this(_clock: Clock)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), None)(moduleCompileOptions)
- def this(_reset: Bool)(implicit moduleCompileOptions: CompileOptions) = this(None, Option(_reset))(moduleCompileOptions)
- def this(_clock: Clock, _reset: Bool)(implicit moduleCompileOptions: CompileOptions) = this(Option(_clock), Option(_reset))(moduleCompileOptions)
+
+ def this(_clock: Clock)(implicit moduleCompileOptions: CompileOptions) =
+ this(Option(_clock), None)(moduleCompileOptions)
+ def this(_reset: Bool)(implicit moduleCompileOptions: CompileOptions) =
+ this(None, Option(_reset))(moduleCompileOptions)
+ def this(_clock: Clock, _reset: Bool)(implicit moduleCompileOptions: CompileOptions) =
+ this(Option(_clock), Option(_reset))(moduleCompileOptions)
override def _autoWrapPorts() = {
if (!_ioPortBound()) {
@@ -203,7 +226,7 @@ package object Chisel { // scalastyle:ignore package.object.name
// parameterized scope.
def apply[T <: Data](t: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T =
chisel3.core.Reg(t)
-
+
/** Creates a register with optional next and initialization values.
*
* @param t: data type for the register
diff --git a/src/main/scala/chisel3/package.scala b/src/main/scala/chisel3/package.scala
index 0ab4876d..ac4e5441 100644
--- a/src/main/scala/chisel3/package.scala
+++ b/src/main/scala/chisel3/package.scala
@@ -25,6 +25,16 @@ package object chisel3 { // scalastyle:ignore package.object.name
val Clock = chisel3.core.Clock
type Clock = chisel3.core.Clock
+ implicit class fromBitsable[T <: Data](val data: T) {
+ import chisel3.core.CompileOptions
+ import chisel3.internal.sourceinfo.SourceInfo
+
+ @deprecated("fromBits is deprecated, use asTypeOf instead", "chisel3")
+ def fromBits(that: Bits)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {
+ that.asTypeOf(data)
+ }
+ }
+
type Aggregate = chisel3.core.Aggregate
val Vec = chisel3.core.Vec
type Vec[T <: Data] = chisel3.core.Vec[T]
diff --git a/src/main/scala/chisel3/util/Decoupled.scala b/src/main/scala/chisel3/util/Decoupled.scala
index 22532a4d..53fa8b29 100644
--- a/src/main/scala/chisel3/util/Decoupled.scala
+++ b/src/main/scala/chisel3/util/Decoupled.scala
@@ -168,11 +168,18 @@ class QueueIO[T <: Data](gen: T, entries: Int) extends Bundle
class Queue[T <: Data](gen: T,
val entries: Int,
pipe: Boolean = false,
- flow: Boolean = false,
- override_reset: Option[Bool] = None)
-extends Module(override_reset=override_reset) {
- def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, _reset: Bool) =
- this(gen, entries, pipe, flow, Some(_reset))
+ flow: Boolean = false)
+ extends Module() {
+ @deprecated("Module constructor with override _reset deprecated, use withReset", "chisel3")
+ def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, override_reset: Option[Bool]) = {
+ this(gen, entries, pipe, flow)
+ this.override_reset = override_reset
+ }
+ @deprecated("Module constructor with override _reset deprecated, use withReset", "chisel3")
+ def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, _reset: Bool) = {
+ this(gen, entries, pipe, flow)
+ this.override_reset = Some(_reset)
+ }
val io = IO(new QueueIO(gen, entries))