From 4ddbff9b9793e0d9d7110eddb4868e5e3f724be5 Mon Sep 17 00:00:00 2001 From: Zachary Snow Date: Tue, 13 Apr 2021 15:08:38 -0400 Subject: [PATCH] keep enum localparam types for later resolution --- src/Convert/Typedef.hs | 5 ++++- test/basic/enum_typedef_keep.sv | 9 +++++++++ test/basic/enum_typedef_keep.v | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/basic/enum_typedef_keep.sv create mode 100644 test/basic/enum_typedef_keep.v 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