Skip to content

Commit

Permalink
Make isView safe outside of Builder context (#4228)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoenig committed Jun 28, 2024
1 parent 2fdaead commit 219a237
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 @@ -273,7 +273,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 @@ -275,6 +275,11 @@ trait ShiftRightWidthBehavior { self: ChiselRunners =>

class UIntOpsSpec extends ChiselPropSpec with Matchers with Utils with ShiftRightWidthBehavior {

// 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 219a237

Please sign in to comment.