diff options
| author | Jack Koenig | 2021-03-15 16:55:06 -0700 |
|---|---|---|
| committer | GitHub | 2021-03-15 16:55:06 -0700 |
| commit | 96436ae018b3631decb8384ce404ada0daa5d645 (patch) | |
| tree | 4d27eeddbfb96fee1843015aaecb91d7334ab45b | |
| parent | b3592a4973a50098f71e0e64bf3f0f53a82a82e9 (diff) | |
allowReflectiveAutoCloneType must work outside of Builder context (#1811)
| -rw-r--r-- | core/src/main/scala/chisel3/internal/Builder.scala | 8 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/AutoClonetypeSpec.scala | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala index b1016a2e..084bdc88 100644 --- a/core/src/main/scala/chisel3/internal/Builder.scala +++ b/core/src/main/scala/chisel3/internal/Builder.scala @@ -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 } diff --git a/src/test/scala/chiselTests/AutoClonetypeSpec.scala b/src/test/scala/chiselTests/AutoClonetypeSpec.scala index a6e5562a..e0e6b2f0 100644 --- a/src/test/scala/chiselTests/AutoClonetypeSpec.scala +++ b/src/test/scala/chiselTests/AutoClonetypeSpec.scala @@ -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") |
