Skip to content

Commit 27cb88c

Browse files
authored
Merge pull request #427 from diffblue/continuous_assignment_to_variable
Verilog: continuous assignments to variables
2 parents 8102fba + 9e0161f commit 27cb88c

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
CORE
22
continuous_assignment_to_variable.v
3-
4-
^EXIT=2$
3+
--bound 0
4+
^\[main\.property\.p1\] always main\.some_reg == main\.i: PROVED up to bound 0$
5+
^EXIT=0$
56
^SIGNAL=0$
6-
^file continuous_assignment_to_variable\.v line 6: continuous assignment to a variable$
7-
^Identifier main\.some_reg is declared as bool on line 3\.$
87
--

regression/verilog/synthesis/continuous_assignment_to_variable.v

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ module main(input i);
22

33
reg some_reg;
44

5-
// should error
65
assign some_reg = i;
76

7+
// should pass
8+
always assert p1: some_reg == i;
9+
810
endmodule

src/verilog/verilog_typecheck.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,9 @@ void verilog_typecheckt::check_lhs(
666666
vassignt vassign)
667667
{
668668
if(lhs.id()==ID_index)
669+
{
669670
check_lhs(to_index_expr(lhs).array(), vassign);
671+
}
670672
else if(lhs.id()==ID_extractbit)
671673
{
672674
if(lhs.operands().size()!=2)
@@ -701,11 +703,7 @@ void verilog_typecheckt::check_lhs(
701703
case A_CONTINUOUS:
702704
if(symbol.is_state_var)
703705
{
704-
throw errort().with_location(lhs.source_location())
705-
<< "continuous assignment to a variable\n"
706-
<< "Identifier " << symbol.display_name() << " is declared as "
707-
<< to_string(symbol.type) << " on line " << symbol.location.get_line()
708-
<< '.';
706+
// Continuous assignments can drive variables.
709707
}
710708
else if(symbol.is_input && !symbol.is_output)
711709
{

0 commit comments

Comments
 (0)