diff options
| author | Richard Lin | 2018-03-23 13:17:40 -0700 |
|---|---|---|
| committer | GitHub | 2018-03-23 13:17:40 -0700 |
| commit | a86e38889302662db14b932e4e0d862290c01308 (patch) | |
| tree | 9358bb719c7331b5e9a8bd4ec85b423a8f976b59 /src/test/scala/chiselTests | |
| parent | f3a39aff35879f1959786b1178ec2ffe96164a35 (diff) | |
Fallback null insertion for autoclonetype (#801)
If autoclonetype is unable to determine an outer class, this attempts to insert a null (and give a deprecation warning), preserving old behavior (in some cases) where the new behavior doesn't work.
This doesn't provide full compatibility with old autoclonetype: this does not attempt null insertion in the general first argument (if it's not an outer class reference). Reasoning is that inserting a null for an explicit argument is probably not the right thing to do, and will likely cause a difficult-to-debug NullPointerException (whereas that would be unlikely for an outer class, which is not always referenced in Bundle subclass code).
Diffstat (limited to 'src/test/scala/chiselTests')
| -rw-r--r-- | src/test/scala/chiselTests/AutoClonetypeSpec.scala | 11 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/AutoNestedCloneSpec.scala | 10 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/test/scala/chiselTests/AutoClonetypeSpec.scala b/src/test/scala/chiselTests/AutoClonetypeSpec.scala index 6924f8b8..520fbdc4 100644 --- a/src/test/scala/chiselTests/AutoClonetypeSpec.scala +++ b/src/test/scala/chiselTests/AutoClonetypeSpec.scala @@ -161,4 +161,15 @@ class AutoClonetypeSpec extends ChiselFlatSpec { } } } + "3.0 null compatibility" should "not need clonetype" in { + elaborate { new Module { + class InnerClassThing { + def createBundle = new Bundle { + val a = Output(UInt(8.W)) + } + } + val io = IO((new InnerClassThing).createBundle) + val a = WireInit(io) + } } + } } diff --git a/src/test/scala/chiselTests/AutoNestedCloneSpec.scala b/src/test/scala/chiselTests/AutoNestedCloneSpec.scala index 236de101..09cd687f 100644 --- a/src/test/scala/chiselTests/AutoNestedCloneSpec.scala +++ b/src/test/scala/chiselTests/AutoNestedCloneSpec.scala @@ -102,9 +102,9 @@ class AutoNestedCloneSpec extends ChiselFlatSpec with Matchers { } } - behavior of "anonymous doubly-nested inner bundle fails with clear error" - ( the[ChiselException] thrownBy { - elaborate { + // Test ignored because the compatibility null-inserting autoclonetype doesn't trip this + ignore should "fail on anonymous doubly-nested inner bundle with clear error" in { + intercept[ChiselException] { elaborate { class Outer(val w: Int) extends Module { class Middle(val w: Int) { def getIO = new Bundle { @@ -115,6 +115,6 @@ class AutoNestedCloneSpec extends ChiselFlatSpec with Matchers { val myWire = Wire((new Middle(w)).getIO) } new Outer(2) - } - }).getMessage should include("Unable to determine instance") + }}.getMessage should include("Unable to determine instance") + } } |
