diff options
| author | Adam Izraelevitz | 2016-11-14 10:52:21 -0800 |
|---|---|---|
| committer | GitHub | 2016-11-14 10:52:21 -0800 |
| commit | cf1372d5b721c2384f88632e76841e6dc6772c6c (patch) | |
| tree | 6232b14043cea1d930f8ac9291dba64e0fc039a7 /src/test | |
| parent | c19a53a562883ebb7d9c6131c4ef308bcfbd720a (diff) | |
| parent | fdde6f839d7f6811e12127dbe9f3f1ae429ee12c (diff) | |
Bugfix inferwidth (#372)
* Bugfix: removed recursive removal in infer widths
This will certainly lead to more uninferred width errors, but now widths
that were previously incorrectly inferred are now correctly uninferred.
An example is:
reg r : UInt, clock with: (reset => (reset, UInt<2>(3)))
node x = add(r, r)
r <= x
Here, r's width follows the following formula, which cannot be solved:
rWidth >= max(max(rWidth, rWidth) + 1, 2)
* Added optimizations to for better width inference
Also added exceptions for uninferred widths when checking DoPrim width
legality to not trigger compiler error
* Added additional optimizations
Required for passing all chisel3 tests
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/WidthSpec.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/WidthSpec.scala b/src/test/scala/firrtlTests/WidthSpec.scala index f2938016..9b0ee139 100644 --- a/src/test/scala/firrtlTests/WidthSpec.scala +++ b/src/test/scala/firrtlTests/WidthSpec.scala @@ -78,4 +78,27 @@ class WidthSpec extends FirrtlFlatSpec { executeTest(input, Nil, passes) } } + "Circular reg depending on reg + 1" should "error" in { + val passes = Seq( + ToWorkingIR, + CheckHighForm, + ResolveKinds, + InferTypes, + CheckTypes, + InferWidths, + CheckWidths) + val input = + """circuit Unit : + | module Unit : + | input clock: Clock + | input reset: UInt<1> + | reg r : UInt, clock with : + | reset => (reset, UInt(3)) + | node T_7 = add(r, r) + | r <= T_7 + |""".stripMargin + intercept[CheckWidths.UninferredWidth] { + executeTest(input, Nil, passes) + } + } } |
