-
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
Check field referential equality in autoclonetype #1047
Changes from all commits
8e763f2
53a3b36
450a708
f80d719
f814b91
521153d
b2e0da5
cac7b4c
a03839f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,4 +172,29 @@ class AutoClonetypeSpec extends ChiselFlatSpec { | |
val a = WireDefault(io) | ||
} } | ||
} | ||
|
||
"Aliased fields" should "be caught" in { | ||
a [ChiselException] should be thrownBy { | ||
elaborate { new Module { | ||
val bundleFieldType = UInt(8.W) | ||
val io = IO(Output(new Bundle { | ||
val a = bundleFieldType | ||
})) | ||
io.a := 0.U | ||
} } | ||
} | ||
} | ||
|
||
"Aliased fields from inadequate autoclonetype" should "be caught" in { | ||
a [ChiselException] should be thrownBy { | ||
class BadBundle(val typeTuple: (Data, Int)) extends Bundle { | ||
val a = typeTuple._1 | ||
} | ||
|
||
elaborate { new Module { | ||
val io = IO(Output(new BadBundle(UInt(8.W), 1))) | ||
io.a := 0.U | ||
} } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the following also subject to issues related to aliased fields? new Module {
val io = IO(Output(new Bundle {
val a = UInt(8.W)
}))
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't, because it creates a new UInt on the constructor invocation, and auto-clone-type constructs a new Bundle each time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the following would also have aliasing issues? class AliasedBundle(foo: UInt) extends Bundle {
val a = foo
val b = foo
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but I don't think that's in the domain of auto-cloneType to check, and under current code it will probably cause a rebinding error anyways. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I don't understand is why autoclonetype can't check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a automatically generated clone type issue (as in, issue between the original bundle and cloned bundle), it's your Bundle definition is wrong (problem is solely within one Bundle object). And I think it's also caught by the rebinding checks. If you want I'll add a test case for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good |
||
} | ||
} | ||
} |
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.
Why not run this on creation of
elements
? That will always happen on or before cloningThere 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.
@jackkoenig does #1050 address this concern?