Commit 9de4d443 by Zachary Snow

simplify handles shadowing via vars and genvars

parent 72ab6396
...@@ -42,6 +42,8 @@ traverseDeclM decl = do ...@@ -42,6 +42,8 @@ traverseDeclM decl = do
where t = IntegerVector TLogic sg rs where t = IntegerVector TLogic sg rs
Param Localparam t x e -> Param Localparam t x e ->
insertExpr x $ Cast (Left t) e insertExpr x $ Cast (Left t) e
Variable _ _ x _ _ -> insertElem x Nil
Net _ _ _ _ x _ _ -> insertElem x Nil
_ -> return () _ -> return ()
return decl' return decl'
...@@ -66,6 +68,8 @@ isSimpleExpr (Cast Left{} e) = isSimpleExpr e ...@@ -66,6 +68,8 @@ isSimpleExpr (Cast Left{} e) = isSimpleExpr e
isSimpleExpr _ = False isSimpleExpr _ = False
traverseModuleItemM :: ModuleItem -> Scoper Expr ModuleItem traverseModuleItemM :: ModuleItem -> Scoper Expr ModuleItem
traverseModuleItemM (Genvar x) =
insertElem x Nil >> return (Genvar x)
traverseModuleItemM (Instance m p x rs l) = do traverseModuleItemM (Instance m p x rs l) = do
p' <- mapM paramBindingMapper p p' <- mapM paramBindingMapper p
traverseExprsM traverseExprM $ Instance m p' x rs l traverseExprsM traverseExprM $ Instance m p' x rs l
...@@ -147,8 +151,8 @@ substitute scopes expr = ...@@ -147,8 +151,8 @@ substitute scopes expr =
substitute' :: Expr -> Expr substitute' :: Expr -> Expr
substitute' (Ident x) = substitute' (Ident x) =
case lookupElem scopes x of case lookupElem scopes x of
Nothing -> Ident x Just (_, _, e) | e /= Nil -> e
Just (_, _, e) -> e _ -> Ident x
substitute' other = substitute' other =
traverseSinglyNestedExprs substitute' other traverseSinglyNestedExprs substitute' other
......
module top;
localparam i = 1234;
function automatic integer f;
input integer i;
f = i + 1;
endfunction
initial $display(i, f(0), f(i + 1));
endmodule
module top;
localparam i = 1234;
if (1) begin
genvar i;
for (i = 0; i < 10; i = i + 1)
initial $display(i > 5 ? i + 100 : i - 100);
end
endmodule
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment