Skip to content

Commit

Permalink
Make isView safe outside of Builder context (#4228) (#4230)
Browse files Browse the repository at this point in the history
(cherry picked from commit 219a237)

Co-authored-by: Jack Koenig <koenig@sifive.com>
  • Loading branch information
mergify[bot] and jackkoenig committed Jun 28, 2024
1 parent 9f667d8 commit 7687a30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ package object dataview {
}

// Safe for all Data
private[chisel3] def isView(d: Data): Boolean = d._parent.contains(ViewParent)
private[chisel3] def isView(d: Data): Boolean = d._parent.exists(_ == ViewParent)

/** Turn any [[Element]] that could be a View into a concrete Element
*
Expand Down
5 changes: 5 additions & 0 deletions src/test/scala/chiselTests/UIntOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ class UIntLitZeroWidthTester extends BasicTester {

class UIntOpsSpec extends ChiselPropSpec with Matchers with Utils {

// This is intentionally a val outside of any ScalaTest constructs to check that it is legal
// to create a literal outside of a Chisel context and *before* any Chisel contexts have been created
// in this thread.
val five = 5.U

property("Bools can be created from 1 bit UInts") {
ChiselStage.emitCHIRRTL(new GoodBoolConversion)
}
Expand Down

0 comments on commit 7687a30

Please sign in to comment.