Skip to content

Commit

Permalink
Verilog: error on real operand for edge control
Browse files Browse the repository at this point in the history
1800-2017 6.12.1 prohibits real operands given to edge control operators.
This adds an error message for this case.
  • Loading branch information
kroening committed Jan 17, 2025
1 parent f6c38d9 commit aa53cdd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions regression/verilog/synthesis/posedge_real.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
posedge_real.v
--module main
^file posedge_real.v line \d+: edge event controls do not take real operands$
^EXIT=2$
^SIGNAL=0$
--
^warning: ignoring
--
7 changes: 7 additions & 0 deletions regression/verilog/synthesis/posedge_real.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module main;

real data;

always @(posedge data);

endmodule
11 changes: 11 additions & 0 deletions src/verilog/verilog_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,17 @@ exprt verilog_typecheck_exprt::convert_unary_expr(unary_exprt expr)
else if(expr.id() == ID_posedge || expr.id() == ID_negedge)
{
convert_expr(expr.op());

// 1800-2017 6.12.1
// Edge event controls must not be given real operands.
if(
expr.op().type().id() == ID_verilog_shortreal ||
expr.op().type().id() == ID_verilog_real)
{
throw errort().with_location(expr.source_location())
<< "edge event controls do not take real operands";
}

expr.type() = bool_typet{};
}
else if(expr.id() == ID_verilog_smv_eventually)
Expand Down

0 comments on commit aa53cdd

Please sign in to comment.