don't inline module-level constants into static prefixes

This commit is contained in:
Zachary Snow 2022-10-22 18:02:54 -07:00
parent c00f508e81
commit 4533e4fffb
5 changed files with 51 additions and 0 deletions

View File

@ -1,3 +1,11 @@
## Unreleased
### Bug Fixes
* Fixed module-level localparams being needlessly inlined when forming longest
static prefixes, which could cause deep recursion and run out of memory on
some designs
## v0.0.10
### Breaking Changes

View File

@ -130,6 +130,7 @@ asConst scopes expr =
asConstRaw :: Scopes Kind -> Expr -> Writer Any Expr
asConstRaw scopes expr =
case lookupElem scopes expr of
Just (accesses@[_, _], _, Const{}) -> return $ accessesToExpr accesses
Just (_, _, Const Nil) -> recurse
Just (_, _, Const expr') -> asConstRaw scopes expr'
Just{} -> tell (Any True) >> return Nil

8
test/core/always_spin.sv Normal file
View File

@ -0,0 +1,8 @@
module top;
`include "always_spin.vh"
logic [Z - 1:0] foo;
logic flag;
logic bar;
always_comb
bar = foo[Z - 1] & flag;
endmodule

8
test/core/always_spin.v Normal file
View File

@ -0,0 +1,8 @@
module top;
`include "always_spin.vh"
wire [Z - 1:0] foo;
wire flag;
reg bar;
always @*
bar = foo[Z - 1] & flag;
endmodule

26
test/core/always_spin.vh Normal file
View File

@ -0,0 +1,26 @@
parameter A = 1;
localparam B = A + A;
localparam C = B + B;
localparam D = C + C;
localparam E = D + D;
localparam F = E + E;
localparam G = F + F;
localparam H = G + G;
localparam I = H + H;
localparam J = I + I;
localparam K = J + J;
localparam L = K + K;
localparam M = L + L;
localparam N = M + M;
localparam O = N + N;
localparam P = O + O;
localparam Q = P + P;
localparam R = Q + Q;
localparam S = R + R;
localparam T = S + S;
localparam U = T + T;
localparam V = U + U;
localparam W = V + V;
localparam X = W + W;
localparam Y = X + X;
localparam Z = $clog2(Y + Y);