Commit 2b84bdb7 by Zachary Snow

support for type param without parameter keyword

parent 3807ab67
......@@ -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 }
......
......@@ -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
......@@ -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
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