@@ -56,8 +56,17 @@ void verilog_typecheckt::typecheck_port_connection(
56
56
}
57
57
else
58
58
{
59
- convert_expr (op);
60
-
59
+ // IEEE 1800 2017 6.10 allows implicit declarations of nets when
60
+ // used in a port connection.
61
+ if (op.id () == ID_symbol)
62
+ {
63
+ op = convert_symbol (to_symbol_expr (op), port.type ());
64
+ }
65
+ else
66
+ {
67
+ convert_expr (op);
68
+ }
69
+
61
70
if (symbol.is_output )
62
71
check_lhs (op, A_CONTINUOUS);
63
72
else
@@ -229,7 +238,17 @@ void verilog_typecheckt::typecheck_builtin_port_connections(
229
238
230
239
for (auto &connection : inst.connections ())
231
240
{
232
- convert_expr (connection);
241
+ // IEEE 1800 2017 6.10 allows implicit declarations of nets when
242
+ // used in a port connection.
243
+ if (connection.id () == ID_symbol)
244
+ {
245
+ connection = convert_symbol (to_symbol_expr (connection), type);
246
+ }
247
+ else
248
+ {
249
+ convert_expr (connection);
250
+ }
251
+
233
252
propagate_type (connection, type);
234
253
}
235
254
}
@@ -821,8 +840,16 @@ void verilog_typecheckt::convert_continuous_assign(
821
840
exprt &lhs = to_binary_expr (*it).lhs ();
822
841
exprt &rhs = to_binary_expr (*it).rhs ();
823
842
824
- convert_expr (lhs);
843
+ // IEEE 1800 2017 6.10 allows implicit declarations of nets when
844
+ // used as the LHS of a continuous assignment. The type is derived
845
+ // from the RHS, and hence, we convert that first.
825
846
convert_expr (rhs);
847
+
848
+ if (lhs.id () == ID_symbol)
849
+ lhs = convert_symbol (to_symbol_expr (lhs), rhs.type ());
850
+ else
851
+ convert_expr (lhs);
852
+
826
853
propagate_type (rhs, lhs.type ());
827
854
828
855
check_lhs (lhs, A_CONTINUOUS);
@@ -1761,7 +1788,8 @@ Function: verilog_typecheckt::implicit_wire
1761
1788
1762
1789
bool verilog_typecheckt::implicit_wire (
1763
1790
const irep_idt &identifier,
1764
- const symbolt *&symbol_ptr)
1791
+ const symbolt *&symbol_ptr,
1792
+ const typet &net_type)
1765
1793
{
1766
1794
std::string full_identifier=
1767
1795
id2string (module_identifier)+" ." +id2string (identifier);
@@ -1773,7 +1801,7 @@ bool verilog_typecheckt::implicit_wire(
1773
1801
symbol.value .make_nil ();
1774
1802
symbol.base_name =identifier;
1775
1803
symbol.name =full_identifier;
1776
- symbol.type = bool_typet (); // TODO: other types?
1804
+ symbol.type = net_type;
1777
1805
symbol.pretty_name =strip_verilog_prefix (full_identifier);
1778
1806
1779
1807
symbolt *new_symbol;
@@ -1836,6 +1864,7 @@ bool verilog_typecheck(
1836
1864
const verilog_parse_treet &parse_tree,
1837
1865
symbol_table_baset &symbol_table,
1838
1866
const std::string &module,
1867
+ bool warn_implicit_nets,
1839
1868
message_handlert &message_handler)
1840
1869
{
1841
1870
verilog_parse_treet::module_mapt::const_iterator it=
@@ -1851,7 +1880,11 @@ bool verilog_typecheck(
1851
1880
}
1852
1881
1853
1882
return verilog_typecheck (
1854
- symbol_table, *it->second , parse_tree.standard , message_handler);
1883
+ symbol_table,
1884
+ *it->second ,
1885
+ parse_tree.standard ,
1886
+ warn_implicit_nets,
1887
+ message_handler);
1855
1888
}
1856
1889
1857
1890
/* ******************************************************************\
@@ -1870,6 +1903,7 @@ bool verilog_typecheck(
1870
1903
symbol_table_baset &symbol_table,
1871
1904
const verilog_module_sourcet &verilog_module_source,
1872
1905
verilog_standardt standard,
1906
+ bool warn_implicit_nets,
1873
1907
message_handlert &message_handler)
1874
1908
{
1875
1909
// create symbol
@@ -1898,6 +1932,7 @@ bool verilog_typecheck(
1898
1932
}
1899
1933
1900
1934
verilog_typecheckt verilog_typecheck (
1901
- standard, *new_symbol, symbol_table, message_handler);
1935
+ standard, warn_implicit_nets, *new_symbol, symbol_table, message_handler);
1936
+
1902
1937
return verilog_typecheck.typecheck_main ();
1903
1938
}
0 commit comments