File tree 2 files changed +6
-1
lines changed
core/src/main/scala/chisel3
src/test/scala/chiselTests
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ sealed case class UnknownWidth() extends Width {
30
30
}
31
31
32
32
sealed case class KnownWidth (value : Int ) extends Width {
33
- require(value >= 0 )
33
+ require(value >= 0 , s " Widths must be non-negative, got $value " )
34
34
def known : Boolean = true
35
35
def get : Int = value
36
36
def op (that : Width , f : (W , W ) => W ): Width = that match {
Original file line number Diff line number Diff line change @@ -485,4 +485,9 @@ class UIntOpsSpec extends ChiselPropSpec with Matchers with Utils {
485
485
chirrtl should include(" connect y, a" )
486
486
chirrtl should include(" connect z, b" )
487
487
}
488
+
489
+ property(" UInts with negative widths should have a decent error message" ) {
490
+ val e = the[IllegalArgumentException ] thrownBy (UInt (- 8 .W ))
491
+ e.getMessage should include(" Widths must be non-negative, got -8" )
492
+ }
488
493
}
You can’t perform that action at this time.
0 commit comments