Skip to content

Commit

Permalink
Fix chisel3 <> for Bundles that contain compatibility Bundles (Take 2) (
Browse files Browse the repository at this point in the history
#2031)

PR #2023 fixed a composition issue for chisel3 biconnects delegating to
FIRRTL partial connect when compatibility mode Bundles are elements of
chisel3 Bundles. It missed an important case though that caused
previously working code to break.

The bug is fixed by doing the automatic flipping for compatibility mode
Bundles that have "Input" as a direction in addition to those that are
"Flipped".

(cherry picked from commit 5183ef8)

# Conflicts:
#	src/test/scala/chiselTests/CompatibilityInteroperabilitySpec.scala
  • Loading branch information
jackkoenig authored and mergify-bot committed Jul 9, 2021
1 parent ba3b699 commit 63d32bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ private[chisel3] object BiConnect {
if (notStrict) {
// chisel3 <> is commutative but FIRRTL <- is not
val flipped = {
import ActualDirection._
// Everything is flipped when it's the port of a child
val childPort = left_r._parent.get != context_mod
val isFlipped = left_r.direction == ActualDirection.Bidirectional(ActualDirection.Flipped)
val isFlipped = Seq(Bidirectional(Flipped), Input).contains(left_r.direction)
isFlipped ^ childPort
}
val (newLeft, newRight) = if (flipped) pair.swap else pair
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,27 @@ class CompatibiltyInteroperabilitySpec extends ChiselFlatSpec {
compile {
object Compat {
import Chisel._
class Foo extends Bundle {
class BiDir extends Bundle {
val a = Input(UInt(8.W))
val b = Output(UInt(8.W))
}
class Struct extends Bundle {
val a = UInt(8.W)
}
}
import chisel3._
import Compat._
class Bar extends Bundle {
<<<<<<< HEAD
val foo1 = new Foo
val foo2 = Flipped(new Foo)
override def cloneType = (new Bar).asInstanceOf[this.type]
=======
val bidir1 = new BiDir
val bidir2 = Flipped(new BiDir)
val struct1 = Output(new Struct)
val struct2 = Input(new Struct)
>>>>>>> 5183ef88 (Fix chisel3 <> for Bundles that contain compatibility Bundles (Take 2) (#2031))
}
// Check every connection both ways to see that chisel3 <>'s commutativity holds
class Child extends RawModule {
Expand Down

0 comments on commit 63d32bd

Please sign in to comment.