summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Waterman2015-07-30 17:42:37 -0700
committerAndrew Waterman2015-07-30 17:42:37 -0700
commita841af651905b32a756164ea5adbb1480a19259b (patch)
treee8b2ccf2a5def64fb5bc02b6cc3d90a09eddc46e /src
parenta3cd76901958ee88da2b56d67ce0dee263d3301c (diff)
Check for negative UInt literals
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Chisel/Core.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main/scala/Chisel/Core.scala b/src/main/scala/Chisel/Core.scala
index 27d07e30..1dc9ddc7 100644
--- a/src/main/scala/Chisel/Core.scala
+++ b/src/main/scala/Chisel/Core.scala
@@ -762,6 +762,11 @@ sealed class UInt(dir: Direction, width: Int, lit: Option[LitArg] = None) extend
def toSInt(): SInt = asSInt()
def toUInt(): UInt = this
def asUInt(): UInt = this
+
+ lit match {
+ case Some(x) => require(x.num >= 0, s"UInt literal ${x.num} is negative")
+ case None =>
+ }
}
trait UIntFactory {