check for conflicts with unused declarations

This commit is contained in:
Zachary Snow 2022-07-18 21:05:21 -04:00
parent a9f00cce2a
commit e00582de8f
3 changed files with 18 additions and 2 deletions

View File

@ -123,8 +123,21 @@ convertPackages files =
-- injected package items
collectIdentConflicts :: Idents -> AST -> Writer Idents ()
collectIdentConflicts prefixes =
mapM_ $ collectModuleItemsM $ collectify traverseIdentsM $
collectIdent prefixes
mapM_ $ collectModuleItemsM collectModuleItem
where
collectModuleItem =
evalScoperT . scoper >=>
collectify traverseIdentsM ident
scoper = scopeModuleItem collectDecl return return return
collectDecl decl = do
case decl of
Variable _ _ x _ _ -> lift $ ident x
Net _ _ _ _ x _ _ -> lift $ ident x
Param _ _ x _ -> lift $ ident x
ParamType _ x _ -> lift $ ident x
CommentDecl{} -> return ()
return decl
ident = collectIdent prefixes
-- write down identifiers that have a package name as a prefix
collectIdent :: Idents -> Identifier -> Writer Idents ()

View File

@ -1,9 +1,11 @@
package P;
typedef logic T;
typedef logic [1:0] U;
endpackage
module top;
P::T P_T;
assign P_T = 0;
initial $display("%b", P_T);
P::U P_U = 0;
endmodule

View File

@ -2,4 +2,5 @@ module top;
wire P_T;
assign P_T = 0;
initial $display("%b", P_T);
reg [1:0] P_U = 0;
endmodule