don't process global items when looking up identifiers in packages

This commit is contained in:
Zachary Snow 2021-07-19 12:33:11 -04:00
parent 56c597e35e
commit 8a554113c8
3 changed files with 29 additions and 3 deletions

View File

@ -264,9 +264,11 @@ processItems topName packageName moduleItems = do
details <- lookupElemM x
case details of
Nothing ->
if null topName
then return x
else resolveGlobalIdent x
-- only missing identifiers within parts should be looked up
-- in the global scope
if null packageName && not (null topName)
then resolveGlobalIdent x
else return x
Just ([_, _], _, Declared) ->
if null packageName
then return x

View File

@ -0,0 +1,17 @@
package P;
typedef struct packed {
integer U;
} T;
function automatic integer F;
input integer inp;
return $clog2(inp);
endfunction
localparam X = F(100);
localparam T Y = '{ U: X + 1 };
localparam Z = Y.U + 1;
endpackage
import P::*;
localparam V = Y + 1;
module top;
initial $display("%0d %0d", V, X);
endmodule

View File

@ -0,0 +1,7 @@
module top;
localparam X = $clog2(100);
localparam Y = X + 1;
localparam Z = Y + 1;
localparam V = Y + 1;
initial $display("%0d %0d", V, X);
endmodule