summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core
diff options
context:
space:
mode:
authorAndrew Waterman2016-10-05 15:18:25 -0700
committerAndrew Waterman2016-10-05 15:49:59 -0700
commitb2373ebda5e63fa850de21585307013f8419320a (patch)
tree9d155b3f7bbc02421b1b50d52cbbf8c23f7eafab /chiselFrontend/src/main/scala/chisel3/core
parentc7ce06493300cf7ffa89ef472cd6a7086443c16f (diff)
Make asInput/asOutput/flip deprecation warnings dynamic
Code that imports Chisel._ shouldn't see them. Not sure if requireIOWrap is the right condition... or if cyan is a good choice of color for deprecation warnings.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala5
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala21
2 files changed, 20 insertions, 6 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala b/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala
index 0e66a241..85aa8cdc 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/CompileOptions.scala
@@ -17,6 +17,9 @@ trait CompileOptions {
val dontTryConnectionsSwapped: Boolean
// If connection directionality is not explicit, do not use heuristics to attempt to determine it.
val dontAssumeDirectionality: Boolean
+ // Issue a deprecation warning if Data.{flip, asInput,asOutput} is used
+ // instead of Flipped, Input, or Output.
+ val deprecateOldDirectionMethods: Boolean
}
object CompileOptions {
@@ -34,6 +37,7 @@ object ExplicitCompileOptions {
val requireIOWrap = false
val dontTryConnectionsSwapped = false
val dontAssumeDirectionality = false
+ val deprecateOldDirectionMethods = false
}
// Collection of "strict" connection compile options, preferred for new code.
@@ -44,5 +48,6 @@ object ExplicitCompileOptions {
val requireIOWrap = true
val dontTryConnectionsSwapped = true
val dontAssumeDirectionality = true
+ val deprecateOldDirectionMethods = true
}
}
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index 3f21a34c..922b33a9 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -104,12 +104,21 @@ object Data {
}
implicit class AddDirectionToData[T<:Data](val target: T) extends AnyVal {
- @deprecated("Input(Data) should be used over Data.asInput", "gchisel")
- def asInput: T = Input(target)
- @deprecated("Output(Data) should be used over Data.asOutput", "gchisel")
- def asOutput: T = Output(target)
- @deprecated("Flipped(Data) should be used over Data.flip", "gchisel")
- def flip(): T = Flipped(target)
+ def asInput(implicit opts: CompileOptions): T = {
+ if (opts.deprecateOldDirectionMethods)
+ Builder.deprecated("Input(Data) should be used over Data.asInput")
+ Input(target)
+ }
+ def asOutput(implicit opts: CompileOptions): T = {
+ if (opts.deprecateOldDirectionMethods)
+ Builder.deprecated("Output(Data) should be used over Data.asOutput")
+ Output(target)
+ }
+ def flip()(implicit opts: CompileOptions): T = {
+ if (opts.deprecateOldDirectionMethods)
+ Builder.deprecated("Flipped(Data) should be used over Data.flip")
+ Flipped(target)
+ }
}
}