-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PrepareForEmission] Add max expression size before creating a wire. (#…
…2795) If an expression has more than the maximum number of terms, and we are able to drop a wire or hoist it and drop a wire, we do so. The intent is to remove the burden of spilling expressions larger than the maximum token limit of some simulators by guessing what's "too large" and doing it before ExportVerilog. Better algorithms and heuristics for deciding to drop a wire can be added to shouldSpillWire. The current implementation of prepareHWModule makes the phase ordering of this a little interesting: we need to know it is "too large" before we break the expression up into a binary tree. We also need to move this addition, the splitting, and other canonicalizations to later in prepareHWModule. If the spill happens while we are working on a non-procedural region, we we can just proceed to splitting, but inside a procedural region we actually move on down the block before returning up.
- Loading branch information
1 parent
7bcfbc6
commit 286c483
Showing
4 changed files
with
117 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// RUN: circt-opt -lowering-options=maximumNumberOfTermsPerExpression=4 --export-verilog %s | FileCheck %s | ||
|
||
// CHECK-LABEL: module large_use_in_procedural | ||
hw.module @large_use_in_procedural(%clock: i1, %a: i1) { | ||
// CHECK: wire [[GEN:.+]]; | ||
// CHECK: reg [[REG:.+]]; | ||
|
||
// CHECK: assign [[GEN]] = a + a + a + a + a; | ||
// CHECK: always | ||
sv.always { | ||
sv.ifdef.procedural "FOO" { | ||
// This expression should be hoisted and spilled. | ||
%1 = comb.add %a, %a, %a, %a, %a : i1 | ||
// CHECK: if ([[GEN]]) | ||
sv.if %1 { | ||
sv.exit | ||
} | ||
%2 = comb.add %a, %a, %a, %a : i1 | ||
// CHECK: if (a + a + a + a) | ||
sv.if %2 { | ||
sv.exit | ||
} | ||
} | ||
} | ||
|
||
%reg = sv.reg : !hw.inout<i1> | ||
sv.alwaysff(posedge %clock) { | ||
// CHECK: [[REG]] <= a; | ||
sv.passign %reg, %a : i1 | ||
%0 = sv.read_inout %reg : !hw.inout<i1> | ||
// This expression cannot be hoisted, even though it's over the limit. | ||
%1 = comb.add %0, %0, %0, %0, %0 : i1 | ||
// CHECK: if ([[REG]] + [[REG]] + [[REG]] + [[REG]] + [[REG]]) | ||
sv.if %1 { | ||
sv.exit | ||
} | ||
} | ||
} |