summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/Aggregate.scala
diff options
context:
space:
mode:
authormergify[bot]2022-11-10 20:03:45 +0000
committerGitHub2022-11-10 20:03:45 +0000
commitbe4463a7756351dcab09ba3f576f5e3687fb0ebf (patch)
tree2260180caf5121412fe43aee004f4e9aec5aa0ee /core/src/main/scala/chisel3/Aggregate.scala
parentbfa9f7465e6069b1e624126f9e14245b69e7c0a9 (diff)
Unify Chisel2 and chisel3 directionality (backport #2634) (#2837)
* Unify Chisel2 and chisel3 directionality (#2634) Co-authored-by: Jack Koenig <koenig@sifive.com> (cherry picked from commit 1aea4ef96466cbe08150d20c85c88b81e4e4f80f) # Conflicts: # core/src/main/scala/chisel3/Aggregate.scala # core/src/main/scala/chisel3/Module.scala # src/test/scala/chiselTests/Direction.scala * fix up backport * fix up backport * clean up diff * make test order like it was on master Co-authored-by: Adam Izraelevitz <adam.izraelevitz@sifive.com> Co-authored-by: Megan Wachs <megan@sifive.com>
Diffstat (limited to 'core/src/main/scala/chisel3/Aggregate.scala')
-rw-r--r--core/src/main/scala/chisel3/Aggregate.scala42
1 files changed, 17 insertions, 25 deletions
diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala
index f22f5e63..b6836ea7 100644
--- a/core/src/main/scala/chisel3/Aggregate.scala
+++ b/core/src/main/scala/chisel3/Aggregate.scala
@@ -936,37 +936,29 @@ abstract class Record(private[chisel3] implicit val compileOptions: CompileOptio
}
private[chisel3] override def bind(target: Binding, parentDirection: SpecifiedDirection): Unit = {
- try {
- _parent.foreach(_.addId(this))
- binding = target
+ _parent.foreach(_.addId(this))
+ binding = target
- val resolvedDirection = SpecifiedDirection.fromParent(parentDirection, specifiedDirection)
+ val resolvedDirection = SpecifiedDirection.fromParent(parentDirection, specifiedDirection)
- checkForAndReportDuplicates()
+ checkForAndReportDuplicates()
- for ((child, sameChild) <- this.elementsIterator.zip(this.elementsIterator)) {
- if (child != sameChild) {
- throwException(
- s"${this.className} does not return the same objects when calling .elements multiple times. Did you make it a def by mistake?"
- )
- }
- child.bind(ChildBinding(this), resolvedDirection)
+ for ((child, sameChild) <- this.elementsIterator.zip(this.elementsIterator)) {
+ if (child != sameChild) {
+ throwException(
+ s"${this.className} does not return the same objects when calling .elements multiple times. Did you make it a def by mistake?"
+ )
}
+ child.bind(ChildBinding(this), resolvedDirection)
+ }
- // Check that children obey the directionality rules.
- val childDirections = elementsIterator.map(_.direction).toSet - ActualDirection.Empty
- direction = ActualDirection.fromChildren(childDirections, resolvedDirection) match {
- case Some(dir) => dir
- case None =>
- val childWithDirections = getElements.zip(getElements.map(_.direction))
- throw MixedDirectionAggregateException(
- s"Aggregate '$this' can't have elements that are both directioned and undirectioned: $childWithDirections"
- )
- }
- } catch { // nasty compatibility mode shim, where anything flies
- case e: MixedDirectionAggregateException if !compileOptions.dontAssumeDirectionality =>
+ // Check that children obey the directionality rules.
+ val childDirections = elementsIterator.map(_.direction).toSet - ActualDirection.Empty
+ direction = ActualDirection.fromChildren(childDirections, resolvedDirection) match {
+ case Some(dir) => dir
+ case None =>
val resolvedDirection = SpecifiedDirection.fromParent(parentDirection, specifiedDirection)
- direction = resolvedDirection match {
+ resolvedDirection match {
case SpecifiedDirection.Unspecified => ActualDirection.Bidirectional(ActualDirection.Default)
case SpecifiedDirection.Flip => ActualDirection.Bidirectional(ActualDirection.Flipped)
case _ => ActualDirection.Bidirectional(ActualDirection.Default)