Skip to content

Verilog: continuous assignments to variables #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
CORE
continuous_assignment_to_variable.v

^EXIT=2$
--bound 0
^\[main\.property\.p1\] always main\.some_reg == main\.i: PROVED up to bound 0$
^EXIT=0$
^SIGNAL=0$
^file continuous_assignment_to_variable\.v line 6: continuous assignment to a variable$
^Identifier main\.some_reg is declared as bool on line 3\.$
--
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module main(input i);

reg some_reg;

// should error
assign some_reg = i;

// should pass
always assert p1: some_reg == i;

endmodule
8 changes: 3 additions & 5 deletions src/verilog/verilog_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ void verilog_typecheckt::check_lhs(
vassignt vassign)
{
if(lhs.id()==ID_index)
{
check_lhs(to_index_expr(lhs).array(), vassign);
}
else if(lhs.id()==ID_extractbit)
{
if(lhs.operands().size()!=2)
Expand Down Expand Up @@ -701,11 +703,7 @@ void verilog_typecheckt::check_lhs(
case A_CONTINUOUS:
if(symbol.is_state_var)
{
throw errort().with_location(lhs.source_location())
<< "continuous assignment to a variable\n"
<< "Identifier " << symbol.display_name() << " is declared as "
<< to_string(symbol.type) << " on line " << symbol.location.get_line()
<< '.';
// Continuous assignments can drive variables.
}
else if(symbol.is_input && !symbol.is_output)
{
Expand Down