Commit 82d06b39 by Zachary Snow

elaboration avoid introducing illegal selects

parent 80154feb
......@@ -34,13 +34,24 @@ convertDescription =
traverseDeclM :: Decl -> State Info Decl
traverseDeclM decl = do
case decl of
Param Localparam _ x e -> modify $ Map.insert x e
Param Localparam _ x e ->
when (isSimpleExpr e) $ modify $ Map.insert x e
_ -> return ()
let mi = MIPackageItem $ Decl decl
mi' <- traverseModuleItemM mi
let MIPackageItem (Decl decl') = mi'
return decl'
isSimpleExpr :: Expr -> Bool
isSimpleExpr Ident{} = True
isSimpleExpr PSIdent{} = True
isSimpleExpr Number{} = True
isSimpleExpr String{} = True
isSimpleExpr (Dot e _ ) = isSimpleExpr e
isSimpleExpr (Bit e _ ) = isSimpleExpr e
isSimpleExpr (Range e _ _) = isSimpleExpr e
isSimpleExpr _ = False
traverseModuleItemM :: ModuleItem -> State Info ModuleItem
traverseModuleItemM (Instance m p x rs l) = do
p' <- mapM paramBindingMapper p
......
package PKG;
typedef struct packed {
int F;
} S;
function automatic S f();
return '0;
endfunction
endpackage
module top;
localparam PKG::S L0 = PKG::f();
localparam int L1 = L0.F;
localparam int L2 = $clog2(L1);
initial $display("%b %b %b", L0, L1, L2);
endmodule
module top;
localparam L0 = 0;
localparam L1 = L0;
localparam L2 = $clog2(L1);
initial $display("%b %b %b", L0, L1, L2);
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