Skip to content
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

Give default direction to children of Vecs in compatibility code #667

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions chiselFrontend/src/main/scala/chisel3/core/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ abstract class BaseModule extends HasId {
case data: Aggregate => data.userDirection match {
// Recurse into children to ensure explicit direction set somewhere
case UserDirection.Unspecified | UserDirection.Flip => data match {
case data: Record if (!data.compileOptions.dontAssumeDirectionality) =>
data.getElements.foreach(assignCompatDir(_, true))
case _ => data.getElements.foreach(assignCompatDir(_, false))
case record: Record =>
val compatRecord = !record.compileOptions.dontAssumeDirectionality
record.getElements.foreach(assignCompatDir(_, compatRecord))
case vec: Vec[_] =>
vec.getElements.foreach(assignCompatDir(_, insideCompat))
}
case UserDirection.Input | UserDirection.Output => // forced assign, nothing to do
}
Expand Down
11 changes: 11 additions & 0 deletions src/test/scala/chiselTests/CompatibilitySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,15 @@ class CompatibiltySpec extends ChiselFlatSpec with GeneratorDrivenPropertyChecks
}
elaborate { new DirectionLessConnectionModule() }
}

"Vec ports" should "give default directions to children so they can be used in chisel3.util" in {
import Chisel._
elaborate(new Module {
val io = new Bundle {
val in = Vec(1, UInt(width = 8)).flip
val out = UInt(width = 8)
}
io.out := RegEnable(io.in(0), true.B)
})
}
}