Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate user compile options for Chisel.Module (bp #1387) #1388

Merged
merged 1 commit into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}

}