Skip to content
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

Verilog: error on real operand for edge control #937

Merged
merged 1 commit into from
Jan 17, 2025
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
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
Loading