Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions regression/verilog/continuous_assign_implicit_net1/main.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// An undeclared identifier used as a member of a concatenation on the LHS
// of a continuous assignment is implicitly declared as a scalar net of the
// default net type (IEEE 1800-2017 6.10). Here `cout` is never declared;
// it is the discarded carry-out of the subtraction.
// Regression for LogikBench arithmetic/sub.
module main #(parameter DW = 16)
(
input [DW-1:0] a,
input [DW-1:0] b,
output [DW-1:0] out
);

assign {cout, out[DW-1:0]} = a[DW-1:0] - b[DW-1:0];

endmodule
8 changes: 8 additions & 0 deletions regression/verilog/continuous_assign_implicit_net1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.v
--module main --bound 0
^Type-checking Verilog::main$
^EXIT=10$
^SIGNAL=0$
--
^.*unknown identifier cout.*$
16 changes: 16 additions & 0 deletions src/verilog/verilog_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,22 @@ void verilog_typecheckt::convert_continuous_assign(
lhs = convert_verilog_identifier(
to_verilog_identifier_expr(lhs), unsignedbv_typet{1});
}
else if(lhs.id() == ID_concatenation)
{
// The implicit net rule also applies to undeclared identifiers that
// appear as members of a concatenation on the LHS, e.g.
// assign {carry, sum} = a + b; // carry is undeclared
// Declare each such member as a scalar net of the default net type,
// then convert the concatenation as usual.
for(auto &op : lhs.operands())
{
if(op.id() == ID_verilog_identifier)
op = convert_verilog_identifier(
to_verilog_identifier_expr(op), unsignedbv_typet{1});
}

convert_expr(lhs);
}
Comment on lines +823 to +838

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we detect that there could be a lhs/rhs bit-width mismatch? It would be great to have a test covering this case.

else
convert_expr(lhs);

Expand Down
Loading