Skip to content

Commit 9f63e62

Browse files
committed
Verilog: typed parameters are assignment-like contexts
IEEE 1800-2017 10.8 states that parameter assignments with a type are assignment-like contexts. Hence, use assignment_conversion(...).
1 parent 2d186f0 commit 9f63e62

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

regression/verilog/modules/localparam3.v

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ module main;
33
localparam [7:0] foo = 1;
44
parameter [7:0] bar = 2;
55

6+
// Parameters with type are "assignment contexts"
7+
localparam [7:0] baz = 1'b1 + 1'b1;
8+
69
always assert property1: $bits(foo) == 8;
710
always assert property2: $bits(bar) == 8;
11+
always assert property3: baz == 2;
812

913
endmodule

src/verilog/verilog_elaborate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,11 @@ void verilog_typecheckt::elaborate_symbol_rec(irep_idt identifier)
10261026
{
10271027
convert_expr(symbol.value);
10281028

1029+
// Convert to the given type. These are assignment contexts.
1030+
assignment_conversion(symbol.value, symbol.type);
1031+
10291032
if(!is_let)
10301033
symbol.value = elaborate_constant_expression_check(symbol.value);
1031-
1032-
// Cast to the given type.
1033-
propagate_type(symbol.value, symbol.type);
10341034
}
10351035
}
10361036
}

0 commit comments

Comments
 (0)