summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2020-03-24 16:28:30 -0700
committerGitHub2020-03-24 23:28:30 +0000
commit6263fcc56b630b7181eb30680cadcdbb2bdf91dc (patch)
treebfa49d80b93aaabf14510eed86808209b773183f /src
parent3f6b1ce708063097042ecee5d004c66182c25470 (diff)
Propagate user compile options for Chisel.Module (#1387)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/compatibility.scala2
-rw-r--r--src/test/scala/chiselTests/CompatibilitySpec.scala17
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index 02dfa329..9584fad6 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -300,7 +300,7 @@ package object Chisel { // scalastyle:ignore package.object.name number.of.t
import chisel3.CompileOptions
abstract class CompatibilityModule(implicit moduleCompileOptions: CompileOptions)
- extends chisel3.internal.LegacyModule {
+ extends chisel3.internal.LegacyModule()(moduleCompileOptions) {
// 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.
diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala
index d2b39c49..b055890b 100644
--- a/src/test/scala/chiselTests/CompatibilitySpec.scala
+++ b/src/test/scala/chiselTests/CompatibilitySpec.scala
@@ -7,6 +7,16 @@ import chisel3.testers.BasicTester
import org.scalacheck.Gen
import org.scalatest.prop.GeneratorDrivenPropertyChecks
+// Need separate import to override compile options from Chisel._
+object CompatibilityCustomCompileOptions {
+ import Chisel.{defaultCompileOptions => _, _}
+ implicit val customCompileOptions =
+ chisel3.ExplicitCompileOptions.NotStrict.copy(inferModuleReset = true)
+ class Foo extends Module {
+ val io = new Bundle {}
+ }
+}
+
class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks {
import Chisel._
@@ -581,4 +591,11 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks
elaborate(new Foo)
}
+ it should "properly propagate custom compileOptions in Chisel.Module" in {
+ import CompatibilityCustomCompileOptions._
+ var result: Foo = null
+ elaborate({result = new Foo; result})
+ result.compileOptions should be theSameInstanceAs (customCompileOptions)
+ }
+
}