-
Notifications
You must be signed in to change notification settings - Fork 603
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
Fix Nested Instantiate #4018
Fix Nested Instantiate #4018
Conversation
1a5f6f9
to
30ee35d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug is because in each definition elaboration, previous elaborated definition and cache doesn't exist, so Definition
/Instantiate
inside other Definition
never worked before.
This doesn't affect Module
since it can be resolved by firtool dedup, but for Class
, multiple Instantiate
lead to different type: e.g. FooOM
, FooOM_1
, FooOM_2
.
@@ -475,4 +491,12 @@ class InstantiateSpec extends ChiselFunSpec with Utils { | |||
) | |||
) | |||
} | |||
|
|||
it("Nested Instantiate should work") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reproduce via:
mill chiselut[2.13.12].testOnly chiselTests.experimental.hierarchy.InstantiateSpec
Here is log:
List("Bar", "Bar_1", "Bar_2", "Bar_3", "Baz", "Baz_1", "Baz_2", "Baz_3", "Foo", "Foo_1", "Top") did not equal List("Bar", "Bar_1", "Baz", "Foo", "Foo_1", "Top")
ScalaTestFailureLocation: chiselTests.experimental.hierarchy.InstantiateSpec at (InstantiateSpec.scala:500)
Expected :List("Bar", "Bar_1", "Baz", "Foo", "Foo_1", "Top")
Actual :List("Bar", "Bar_1", "Bar_2", "Bar_3", "Baz", "Baz_1", "Baz_2", "Baz_3", "Foo", "Foo_1", "Top")
Thanks for the PR. I had been playing around with Instantiate and noticed this behavior, but I never got around to sending a PR or filing an issue. I took a quick look and I think this makes sense, I had something similar when I was trying to fix this on my end once. |
fc9f326
to
5faf39a
Compare
5faf39a
to
6f73e23
Compare
* minimal reproduce Nested Instantiate bug * expose cache and elaborated defination to inner defination * fix up (cherry picked from commit 02b01e8) # Conflicts: # core/src/main/scala/chisel3/experimental/hierarchy/core/Definition.scala # core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala # core/src/main/scala/chisel3/internal/Builder.scala # src/main/scala/chisel3/aop/injecting/InjectingAspect.scala # src/main/scala/chisel3/stage/phases/Elaborate.scala # src/test/scala/chiselTests/experimental/hierarchy/InstantiateSpec.scala
* minimal reproduce Nested Instantiate bug * expose cache and elaborated defination to inner defination * fix up (cherry picked from commit 02b01e8) # Conflicts: # core/src/main/scala/chisel3/experimental/hierarchy/core/Definition.scala # core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala # core/src/main/scala/chisel3/internal/Builder.scala # src/main/scala/chisel3/aop/injecting/InjectingAspect.scala # src/main/scala/chisel3/stage/phases/Elaborate.scala
* minimal reproduce Nested Instantiate bug * expose cache and elaborated defination to inner defination * fix up (cherry picked from commit 02b01e8)
* Fix Nested Instantiate (#4018) * minimal reproduce Nested Instantiate bug * expose cache and elaborated defination to inner defination * fix up (cherry picked from commit 02b01e8) # Conflicts: # core/src/main/scala/chisel3/experimental/hierarchy/core/Definition.scala # core/src/main/scala/chisel3/experimental/hierarchy/core/Instance.scala # core/src/main/scala/chisel3/internal/Builder.scala # src/main/scala/chisel3/aop/injecting/InjectingAspect.scala # src/main/scala/chisel3/stage/phases/Elaborate.scala * Resolve backport conflicts --------- Co-authored-by: Jiuyang Liu <liu@jiuyang.me> Co-authored-by: Jack Koenig <koenig@sifive.com>
When Instantiate a instantiable module, if it has other instantiable modules inside it, inner module will miss cache.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Fix Nested Instantiate
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.