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

allowReflectiveAutoCloneType must work outside of Builder context #1811

Merged
merged 1 commit into from
Mar 15, 2021
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
8 changes: 6 additions & 2 deletions core/src/main/scala/chisel3/internal/Builder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,12 @@ private[chisel3] object Builder extends LazyLogging {
dynamicContext.currentReset = newReset
}

// This should only be used for testing
def allowReflectiveAutoCloneType: Boolean = dynamicContext.allowReflectiveAutoCloneType
// This should only be used for testing, must be true outside of Builder context
def allowReflectiveAutoCloneType: Boolean = {
dynamicContextVar.value
.map(_.allowReflectiveAutoCloneType)
.getOrElse(true)
}
def allowReflectiveAutoCloneType_=(value: Boolean): Unit = {
dynamicContext.allowReflectiveAutoCloneType = value
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/chiselTests/AutoClonetypeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class AutoClonetypeSpec extends ChiselFlatSpec with Utils {
} }
}

"Autoclonetype" should "work outside of a builder context" in {
new BundleWithIntArg(8).cloneType
}

def checkSubBundleInvalid() = {
elaborate { new Module {
val io = IO(new Bundle{}).suggestName("io")
Expand Down