allow type declarations in tasks and functions (#321)

Co-authored-by: Zachary Snow <zach@zachjs.com>
This commit is contained in:
Akihiko Odaki 2025-11-22 13:17:56 +09:00 committed by GitHub
parent c1ce7d067b
commit f41cc5bcea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 0 deletions

View File

@ -1226,6 +1226,7 @@ DeclsAndStmts :: { ([Decl], [Stmt]) }
DeclOrStmt :: { ([Decl], [Stmt]) }
: DeclTokens(";") { parseDTsAsDeclOrStmt $1 }
| ParameterDecl(";") { ($1, []) }
| Typedef { ([$1], []) }
ParameterDecl(delim) :: { [Decl] }
: ParameterDeclKW DeclAsgns delim { makeParamDecls $1 (Implicit Unspecified []) $2 }

17
test/core/tf_typedef.sv Normal file
View File

@ -0,0 +1,17 @@
module top;
task t;
typedef byte u;
$display("t %b", u'('1));
endtask
function integer f;
input reg signed i;
typedef shortint v;
$display("i %b", v'(i));
return $bits(v);
endfunction
initial begin
t();
$display("f %b", f(0));
$display("f %b", f(1));
end
endmodule

19
test/core/tf_typedef.v Normal file
View File

@ -0,0 +1,19 @@
module top;
task t;
$display("t %b", 8'hFF);
endtask
function integer f;
input reg signed i;
reg [15:0] j;
begin
j = i;
$display("i %b", j);
f = 16;
end
endfunction
initial begin
t;
$display("f %b", f(0));
$display("f %b", f(1));
end
endmodule