Skip to content

Commit 9dc7fb8

Browse files
committed
Verilog: add type parameters to scope
Type parameters are now added to the scope, and hence usable as types.
1 parent 029f48a commit 9dc7fb8

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
type_parameters2.sv
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module main;
2+
3+
parameter type T1 = bit [31:0];
4+
5+
T1 some_data;
6+
7+
initial assert ($bits(some_data) == 32);
8+
9+
endmodule

src/verilog/parser.y

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,11 @@ type_assignment: param_identifier '=' data_type
20312031
auto base_name = stack_expr($1).id();
20322032
stack_expr($$).set(ID_identifier, base_name);
20332033
stack_expr($$).set(ID_base_name, base_name);
2034-
addswap($$, ID_type, $3); }
2034+
addswap($$, ID_type, $3);
2035+
2036+
// add to the scope as a type name
2037+
PARSER.scopes.add_name(base_name, "", verilog_scopet::TYPEDEF);
2038+
}
20352039
;
20362040

20372041
data_type_or_implicit:

0 commit comments

Comments
 (0)