diff --git a/src/Convert/Typedef.hs b/src/Convert/Typedef.hs index da5aacf..d38205e 100644 --- a/src/Convert/Typedef.hs +++ b/src/Convert/Typedef.hs @@ -76,7 +76,10 @@ traverseDeclM decl = do insertElem x UnknownType >> return decl' ParamType Localparam x t -> do traverseTypeM t >>= scopeType >>= insertElem x - return $ CommentDecl $ "removed localparam type " ++ x + return $ case t of + Enum{} -> ParamType Localparam tmpX t + _ -> CommentDecl $ "removed localparam type " ++ x + where tmpX = "_sv2v_keep_enum_for_params" ParamType{} -> return decl' CommentDecl{} -> return decl' diff --git a/test/basic/enum_typedef_keep.sv b/test/basic/enum_typedef_keep.sv new file mode 100644 index 0000000..3fd0b1d --- /dev/null +++ b/test/basic/enum_typedef_keep.sv @@ -0,0 +1,9 @@ +module top; + localparam int W = 4; + typedef logic [W - 1:0] T; + typedef enum T { + A = 4'b1010, + B = 4'b0101 + } E; + initial $display("%d %d %b %b", $bits(A), $bits(B), A, B); +endmodule diff --git a/test/basic/enum_typedef_keep.v b/test/basic/enum_typedef_keep.v new file mode 100644 index 0000000..89c839a --- /dev/null +++ b/test/basic/enum_typedef_keep.v @@ -0,0 +1,6 @@ +module top; + localparam W = 4; + localparam A = 4'b1010; + localparam B = 4'b0101; + initial $display("%d %d %b %b", W, W, A, B); +endmodule