diff options
| author | Andrew Waterman | 2015-07-30 17:42:37 -0700 |
|---|---|---|
| committer | Andrew Waterman | 2015-07-30 17:42:37 -0700 |
| commit | a841af651905b32a756164ea5adbb1480a19259b (patch) | |
| tree | e8b2ccf2a5def64fb5bc02b6cc3d90a09eddc46e /src | |
| parent | a3cd76901958ee88da2b56d67ce0dee263d3301c (diff) | |
Check for negative UInt literals
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/Chisel/Core.scala | 5 |
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 { |
