diff options
| author | azidar | 2016-08-04 15:15:00 -0700 |
|---|---|---|
| committer | azidar | 2016-08-04 15:16:37 -0700 |
| commit | 6aea3924fb48cbb4c1be217630c60be39b243ff1 (patch) | |
| tree | c9fc072f10598953f54405a3336e3079e394bfbb /src/main | |
| parent | 9b310a04c9c355c8a6f11da2e2f704fbce8f89bb (diff) | |
Addd check: bits, tail, head arg width
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/passes/Checks.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/passes/Checks.scala b/src/main/scala/firrtl/passes/Checks.scala index 7350a8c1..8c94d737 100644 --- a/src/main/scala/firrtl/passes/Checks.scala +++ b/src/main/scala/firrtl/passes/Checks.scala @@ -690,6 +690,9 @@ object CheckWidths extends Pass { s"$info : [module $mname] Width too small for constant " + serialize(b) + ".") class NegWidthException(info:Info) extends PassException(s"${info}: [module ${mname}] Width cannot be negative or zero.") + class BitsWidthException(info: Info, hi: BigInt, width: BigInt) extends PassException(s"${info}: [module ${mname}] High bit $hi in bits operator is larger than input width $width.") + class HeadWidthException(info: Info, n: BigInt, width: BigInt) extends PassException(s"${info}: [module ${mname}] Parameter $n in head operator is larger than input width $width.") + class TailWidthException(info: Info, n: BigInt, width: BigInt) extends PassException(s"${info}: [module ${mname}] Parameter $n in tail operator is larger than input width $width.") def run (c:Circuit): Circuit = { val errors = new Errors() def check_width_m (m:DefModule) : Unit = { @@ -720,6 +723,12 @@ object CheckWidths extends Pass { } check_width_w(info)(e.width) } + case DoPrim(Bits, Seq(a), Seq(hi, lo), _) if(long_BANG(a.tpe) <= hi) => + errors.append(new BitsWidthException(info, hi, long_BANG(a.tpe))) + case DoPrim(Head, Seq(a), Seq(n), _) if(long_BANG(a.tpe) < n) => + errors.append(new HeadWidthException(info, n, long_BANG(a.tpe))) + case DoPrim(Tail, Seq(a), Seq(n), _) if(long_BANG(a.tpe) <= n) => + errors.append(new TailWidthException(info, n, long_BANG(a.tpe))) case (e:DoPrim) => false case (e) => false } |
