diff --git a/src/Language/SystemVerilog/Parser/Parse.y b/src/Language/SystemVerilog/Parser/Parse.y index 4081da6..cb8306e 100644 --- a/src/Language/SystemVerilog/Parser/Parse.y +++ b/src/Language/SystemVerilog/Parser/Parse.y @@ -538,8 +538,8 @@ ParamsFollow :: { [Decl] } | ParamAsgn "," ParamsFollow { $1 : $3 } | ParamsDecl { $1 } ParamsDecl :: { [Decl] } - : ParameterDecl(")") { $1 } - | ParameterDecl(",") ParamsDecl { $1 ++ $2 } + : ModuleParameterDecl(")") { $1 } + | ModuleParameterDecl(",") ParamsDecl { $1 ++ $2 } ParamAsgn :: { Decl } : Identifier "=" Expr { Param Parameter (Implicit Unspecified []) $1 $3 } @@ -966,6 +966,9 @@ DeclOrStmt :: { ([Decl], [Stmt]) } : DeclOrStmtTokens(";") { parseDTsAsDeclOrAsgn $1 } | ParameterDecl(";") { ($1, []) } +ModuleParameterDecl(delim) :: { [Decl] } + : ParameterDecl(delim) { $1 } + | "type" TypeAsgns delim { map (uncurry $ ParamType Parameter) $2 } ParameterDecl(delim) :: { [Decl] } : ParameterDeclKW DeclAsgns delim { makeParamDecls $1 (Implicit Unspecified []) $2 } | ParameterDeclKW ParamType DeclAsgns delim { makeParamDecls $1 ($2 ) $3 } diff --git a/test/basic/paramtype.sv b/test/basic/paramtype.sv index d80db55..ed3e003 100644 --- a/test/basic/paramtype.sv +++ b/test/basic/paramtype.sv @@ -67,6 +67,17 @@ module o_nodef #( end endmodule +module p #( + type T = logic, U = logic +); + T x = 0; + U y = 1; + initial begin + $display("p %b %b %d", x, x+1, $bits(T)); + $display("p %b %b %d", y, y+1, $bits(U)); + end +endmodule + module top; endmodule // Top level modules appear to be generally instantiated in lexicographic order, @@ -98,3 +109,6 @@ module f_1; o_nodef #(1, logic [1:0], logic [2:0], 0) x(); endmodule module f_2; o_nodef #(.T(logic [1:0]), .U(logic), .b(1), .a(0)) x(); endmodule module f_3; o_nodef #(0, logic [1:0], logic [2:0], 1) x(); endmodule module f_4; o_nodef #(.T(logic [1:0]), .U(logic), .b(0), .a(1)) x(); endmodule + +module p_1; p #(logic [1:0], logic [2:0]) x(); endmodule +module p_2; p x(); endmodule diff --git a/test/basic/paramtype.v b/test/basic/paramtype.v index 6e87462..e686801 100644 --- a/test/basic/paramtype.v +++ b/test/basic/paramtype.v @@ -36,5 +36,9 @@ module top; $display("n_nodef b= 1 001 00000000000000000000000000000010 3"); $display("n_nodef a= 1 01 00000000000000000000000000000010 2"); $display("n_nodef b= 0 0 00000000000000000000000000000001 1"); + $display("p 00 00000000000000000000000000000001 2"); + $display("p 001 00000000000000000000000000000010 3"); + $display("p 0 00000000000000000000000000000001 1"); + $display("p 1 00000000000000000000000000000010 1"); end endmodule