Skip to content

Commit

Permalink
Propagate user compile options for Chisel.Module (#1387) (#1388)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 6263fcc)

Co-authored-by: Jack Koenig <[email protected]>
  • Loading branch information
mergify[bot] and jackkoenig authored Mar 25, 2020
1 parent 7a9ae29 commit 7a343dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/chisel3/compatibility.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions src/test/scala/chiselTests/CompatibilitySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._

Expand Down Expand Up @@ -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)
}

}

0 comments on commit 7a343dc

Please sign in to comment.