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

expose typeEquivalent #1402

Merged
merged 6 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions core/src/main/scala/chisel3/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ package experimental {
requireIsHardware(target, "node requested directionality on")
target.direction
}
def checkTypeEquivalence(x: Data, y: Data): Boolean = x.typeEquivalent(y)
sequencer marked this conversation as resolved.
Show resolved Hide resolved

// Returns the top-level module ports
// TODO: maybe move to something like Driver or DriverUtils, since this is mainly for interacting
Expand Down
12 changes: 12 additions & 0 deletions src/test/scala/chiselTests/RecordSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ trait RecordSpecUtils {
assert(wire("0").asUInt === 123.U)
stop()
}

class RecordTypeTester extends BasicTester {
val wire0 = Wire(new CustomBundle("0"-> UInt(32.W)))
val wire1 = Reg(new CustomBundle("0"-> UInt(32.W)))
val wire2 = Wire(new CustomBundle("1"-> UInt(32.W)))
require(DataMirror.checkTypeEquivalence(wire0, wire1))
require(!DataMirror.checkTypeEquivalence(wire1, wire2))
}
}

class RecordSpec extends ChiselFlatSpec with RecordSpecUtils {
Expand Down Expand Up @@ -146,4 +154,8 @@ class RecordSpec extends ChiselFlatSpec with RecordSpecUtils {
io := wire
})
}

"CustomBundle" should "check the types" in {
elaborate { new RecordTypeTester }
}
}