Skip to content

Commit 918ef6d

Browse files
authored
Merge pull request #1513 from diffblue/implicit_declaration1-fix
Bugfix: type of implicit nets
2 parents d539aa9 + 504b372 commit 918ef6d

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Verilog: fix for four-valued | and &
44
* Verilog: fix for typed parameter ports
5+
* Verilog: fix for the type of implicit nets for continous assignments
56
* SystemVerilog: fix for type parameters
67
* SystemVerilog: type parameter ports
78
* SMV: word constants
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
implicit_declaration1.sv
33

44
^EXIT=0$
55
^SIGNAL=0$
66
--
77
^warning: ignoring
88
--
9-
This gives the wrong answer.

regression/verilog/nets/implicit4.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module main;
55
// implicit nets are allowed on the LHS of a continuous assignment
66
assign O = A & B;
77

8-
always assert final (O == (A & B));
9-
always assert final ($bits(O) == 4);
8+
always assert final (O == (A & B & 1'b1));
9+
always assert final ($bits(O) == 1);
1010

1111
endmodule

src/verilog/verilog_typecheck.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -857,16 +857,18 @@ void verilog_typecheckt::convert_continuous_assign(
857857
exprt &rhs = to_binary_expr(*it).rhs();
858858

859859
// IEEE 1800 2017 6.10 allows implicit declarations of nets when
860-
// used as the LHS of a continuous assignment. The type is derived
861-
// from the RHS, and hence, we convert that first.
862-
convert_expr(rhs);
863-
860+
// used as the LHS of a continuous assignment. The type is _not_
861+
// derived from the RHS, but instead a "scalar net of default net type".
864862
if(lhs.id() == ID_verilog_identifier)
865-
lhs =
866-
convert_verilog_identifier(to_verilog_identifier_expr(lhs), rhs.type());
863+
{
864+
lhs = convert_verilog_identifier(
865+
to_verilog_identifier_expr(lhs), unsignedbv_typet{1});
866+
}
867867
else
868868
convert_expr(lhs);
869869

870+
convert_expr(rhs);
871+
870872
assignment_conversion(rhs, lhs.type());
871873

872874
check_lhs(lhs, A_CONTINUOUS);

0 commit comments

Comments
 (0)