-
Notifications
You must be signed in to change notification settings - Fork 614
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 ActualDirection calculation from SpecifiedDirection #4205
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,17 +160,17 @@ class DirectionSpec extends ChiselPropSpec with Matchers with Utils { | |
} | ||
|
||
property("Directions should be preserved through cloning and binding of Bundles") { | ||
ChiselStage.emitCHIRRTL(new Module { | ||
class MyBundle extends Bundle { | ||
val foo = Input(UInt(8.W)) | ||
val bar = Output(UInt(8.W)) | ||
} | ||
class MyOuterBundle extends Bundle { | ||
val fizz = new MyBundle | ||
val buzz = Flipped(new MyBundle) | ||
} | ||
class MyBundle extends Bundle { | ||
val foo = Input(UInt(8.W)) | ||
val bar = Output(UInt(8.W)) | ||
} | ||
class MyOuterBundle extends Bundle { | ||
val fizz = new MyBundle | ||
val buzz = Flipped(new MyBundle) | ||
} | ||
class Top(hwop: MyOuterBundle => MyOuterBundle) extends Module { | ||
val a = new MyOuterBundle | ||
val b = IO(a) | ||
val b = hwop(a) | ||
val specifiedDirs = Seq( | ||
a.fizz.foo -> SpecifiedDirection.Input, | ||
a.fizz.bar -> SpecifiedDirection.Output, | ||
|
@@ -193,11 +193,15 @@ class DirectionSpec extends ChiselPropSpec with Matchers with Utils { | |
for ((data, dir) <- actualDirs) { | ||
DataMirror.directionOf(data) shouldBe (dir) | ||
} | ||
}.asInstanceOf[Module]) // The cast works around weird reflection behavior (bug?) | ||
} | ||
val ops: Seq[MyOuterBundle => MyOuterBundle] = Seq(IO(_), Wire(_)) | ||
for (op <- ops) { | ||
ChiselStage.emitCHIRRTL(new Top(op)) | ||
} | ||
} | ||
|
||
property("Directions should be preserved through cloning and binding of Vecs") { | ||
ChiselStage.emitCHIRRTL(new Module { | ||
class Top(hwop: Vec[Vec[UInt]] => Vec[Vec[UInt]]) extends Module { | ||
val a = Vec(1, Input(UInt(8.W))) | ||
val b = Vec(1, a) | ||
val c = Vec(1, Flipped(a)) | ||
|
@@ -226,7 +230,11 @@ class DirectionSpec extends ChiselPropSpec with Matchers with Utils { | |
for ((data, dir) <- actualDirs) { | ||
DataMirror.directionOf(data) shouldBe (dir) | ||
} | ||
}.asInstanceOf[Module]) // The cast works around weird reflection behavior (bug?) | ||
} | ||
val ops: Seq[Vec[Vec[UInt]] => Vec[Vec[UInt]]] = Seq(IO(_), Wire(_)) | ||
for (op <- ops) { | ||
ChiselStage.emitCHIRRTL(new Top(op)) | ||
} | ||
} | ||
|
||
property("Using Vec and Flipped together should calculate directions properly") { | ||
|
@@ -493,6 +501,45 @@ class DirectionSpec extends ChiselPropSpec with Matchers with Utils { | |
assert(emitted.contains("connect io.monitor.valid, io.driver.valid")) | ||
assert(emitted.contains("connect io.monitor.ready, io.driver.ready")) | ||
} | ||
|
||
property("Output mixed with unspecified directions should report Output") { | ||
class MyBundle extends Bundle { | ||
val foo = UInt(8.W) | ||
val bar = Output(UInt(8.W)) | ||
} | ||
class MyModule extends RawModule { | ||
val w = Wire(new MyBundle) | ||
assert(DataMirror.specifiedDirectionOf(w) == SpecifiedDirection.Unspecified) | ||
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. i agree with the tests tho |
||
assert(DataMirror.specifiedDirectionOf(w.foo) == SpecifiedDirection.Unspecified) | ||
assert(DataMirror.specifiedDirectionOf(w.bar) == SpecifiedDirection.Output) | ||
assert(DataMirror.directionOf(w) == Direction.Output) | ||
assert(DataMirror.directionOf(w.foo) == Direction.Output) | ||
assert(DataMirror.directionOf(w.bar) == Direction.Output) | ||
|
||
} | ||
val chirrtl = ChiselStage.emitCHIRRTL(new MyModule) | ||
assert(chirrtl.contains("wire w : { foo : UInt<8>, bar : UInt<8>}")) | ||
} | ||
|
||
property("Input mixed with Flipped directions should report Input") { | ||
class MyBundle extends Bundle { | ||
val foo = Flipped(UInt(8.W)) | ||
val bar = Input(UInt(8.W)) | ||
} | ||
class MyModule extends RawModule { | ||
val w = Wire(new MyBundle) | ||
assert(DataMirror.specifiedDirectionOf(w) == SpecifiedDirection.Unspecified) | ||
assert(DataMirror.specifiedDirectionOf(w.foo) == SpecifiedDirection.Flip) | ||
assert(DataMirror.specifiedDirectionOf(w.bar) == SpecifiedDirection.Input) | ||
assert(DataMirror.directionOf(w) == Direction.Input) | ||
assert(DataMirror.directionOf(w.foo) == Direction.Input) | ||
assert(DataMirror.directionOf(w.bar) == Direction.Input) | ||
|
||
} | ||
val chirrtl = ChiselStage.emitCHIRRTL(new MyModule) | ||
assert(chirrtl.contains("wire w : { flip foo : UInt<8>, flip bar : UInt<8>}")) | ||
} | ||
|
||
jackkoenig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
property("Bugfix: marking Vec fields with mixed directionality as Output/Input clears inner directions") { | ||
class Decoupled extends Bundle { | ||
val bits = UInt(3.W) | ||
|
@@ -559,4 +606,5 @@ class DirectionSpec extends ChiselPropSpec with Matchers with Utils { | |
val emitted: String = ChiselStage.emitCHIRRTL(new MyModule) | ||
assert(emitted.contains("Probe<const UInt<1>>")) | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please add a test to cover this.
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 is an internal error that isn't supposed to be reachable.