diff options
| author | Adam Izraelevitz | 2016-06-08 13:48:04 -0700 |
|---|---|---|
| committer | Adam Izraelevitz | 2016-06-08 13:48:04 -0700 |
| commit | cc4e7e39ebad106ff72f7ac97dcdc99048ee5347 (patch) | |
| tree | 4cc5542878715275ebaf332418471741f29cf48d /src | |
| parent | 73ca9d789b9de55d2d69a86c2efb04c9360b8d11 (diff) | |
| parent | 56f27c481ba7436f74739ab5dd13f340b5d15e89 (diff) | |
Merge pull request #185 from ucb-bar/fix-width-bug
Fix for bug introduced in #174
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/passes/Passes.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala index 4ed152a4..abd758bf 100644 --- a/src/main/scala/firrtl/passes/Passes.scala +++ b/src/main/scala/firrtl/passes/Passes.scala @@ -493,8 +493,8 @@ object InferWidths extends Pass { // This function shouldn't be necessary // Added as protection in case a constraint accidentally uses MinWidth/MaxWidth // without any actual Widths. This should be elevated to an earlier error - def forceNonEmpty(in: Seq[Option[BigInt]]): Seq[Option[BigInt]] = - if(in.isEmpty) Seq(None) + def forceNonEmpty(in: Seq[Option[BigInt]], default: Option[BigInt]): Seq[Option[BigInt]] = + if(in.isEmpty) Seq(default) else in def max(a: BigInt, b: BigInt): BigInt = if (a >= b) a else b @@ -507,8 +507,8 @@ object InferWidths extends Pass { v <- h.get(w.name) if !v.isInstanceOf[VarWidth] result <- solve(v) } yield result - case (w: MaxWidth) => reduceOptions(forceNonEmpty(w.args.map(solve _)), max) - case (w: MinWidth) => reduceOptions(forceNonEmpty(w.args.map(solve _)), min) + case (w: MaxWidth) => reduceOptions(forceNonEmpty(w.args.map(solve _), Some(BigInt(0))), max) + case (w: MinWidth) => reduceOptions(forceNonEmpty(w.args.map(solve _), None), min) case (w: PlusWidth) => map2(solve(w.arg1), solve(w.arg2), {_ + _}) case (w: MinusWidth) => map2(solve(w.arg1), solve(w.arg2), {_ - _}) case (w: ExpWidth) => map2(Some(BigInt(2)), solve(w.arg1), pow_minus_one) |
