mirror of https://github.com/zachjs/sv2v.git
elaboration avoid introducing illegal selects
This commit is contained in:
parent
80154feb5e
commit
82d06b3915
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
module top;
|
||||
localparam L0 = 0;
|
||||
localparam L1 = L0;
|
||||
localparam L2 = $clog2(L1);
|
||||
initial $display("%b %b %b", L0, L1, L2);
|
||||
endmodule
|
||||
Loading…
Reference in New Issue