diff options
| author | Jack Koenig | 2019-11-29 14:55:01 -0800 |
|---|---|---|
| committer | GitHub | 2019-11-29 14:55:01 -0800 |
| commit | 85fe90d5b7ed4e1101b0b3959a1d362eb93915ac (patch) | |
| tree | e027c898e182936f667ec90252355756b6081196 /src/main/scala/chisel3/compatibility.scala | |
| parent | 2c53527f6c232121a2340e75c0109c1618fc2428 (diff) | |
Compat compile options macro (#1253)
* Use macro to materialize CompileOptions in Chisel._
This switches from using an implicit val that required awkward
suppression (as illustrated in CompileOptionsSpec) to allowing
overriding in the same way as done in "import chisel3._" via the
creation of an implicit val in lexical scope.
* Deprecate Chisel.defaultCompileOptions
Diffstat (limited to 'src/main/scala/chisel3/compatibility.scala')
| -rw-r--r-- | src/main/scala/chisel3/compatibility.scala | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala index 02dfa329..432446cb 100644 --- a/src/main/scala/chisel3/compatibility.scala +++ b/src/main/scala/chisel3/compatibility.scala @@ -9,11 +9,17 @@ package object Chisel { // scalastyle:ignore package.object.name number.of.t import chisel3.internal.firrtl.Width import scala.language.experimental.macros - import scala.annotation.StaticAnnotation - import scala.annotation.compileTimeOnly + import scala.reflect.macros.blackbox.Context + import scala.annotation.{StaticAnnotation, compileTimeOnly} import scala.language.implicitConversions - implicit val defaultCompileOptions = chisel3.ExplicitCompileOptions.NotStrict + + /** Default NotStrict CompileOptions for compatibility code + * + * No longer implicit, materialization macro below provides a low-priority default + */ + @deprecated("Use chisel3.ExplicitCompileOptions.NotStrict", "3.3") + val defaultCompileOptions = chisel3.ExplicitCompileOptions.NotStrict abstract class Direction case object INPUT extends Direction @@ -584,6 +590,16 @@ package object Chisel { // scalastyle:ignore package.object.name number.of.t val Pipe = chisel3.util.Pipe type Pipe[T <: Data] = chisel3.util.Pipe[T] + /** Provides a low priority NotStrict default. Can be overridden by providing a custom implicit + * val in lexical scope (ie. imported) + * Implemented as a macro to provide a low-priority default + */ + implicit def materializeCompileOptions: CompileOptions = macro materializeCompileOptions_impl + + def materializeCompileOptions_impl(c: Context): c.Tree = { + import c.universe._ + q"_root_.chisel3.ExplicitCompileOptions.NotStrict" + } /** Package for experimental features, which may have their API changed, be removed, etc. * |
