From 27474b362bc80d6867925e83381f32df4a1ac012 Mon Sep 17 00:00:00 2001 From: Daniel Kroening Date: Sat, 16 Nov 2024 11:37:59 +0000 Subject: [PATCH] Verilog: typechecking for remaining unary expressions --- src/verilog/verilog_typecheck_expr.cpp | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/verilog/verilog_typecheck_expr.cpp b/src/verilog/verilog_typecheck_expr.cpp index df419cec..6e2454e0 100644 --- a/src/verilog/verilog_typecheck_expr.cpp +++ b/src/verilog/verilog_typecheck_expr.cpp @@ -2606,16 +2606,37 @@ exprt verilog_typecheck_exprt::convert_unary_expr(unary_exprt expr) expr.type() = expr.op().operands()[0].type(); return std::move(expr); } - else + else if(expr.id() == ID_bitnot) { convert_expr(expr.op()); expr.type() = expr.op().type(); - // check boolean operators - - if(expr.type().id()==ID_bool && expr.id()==ID_bitnot) + // Boolean? + if(expr.type().id() == ID_bool) expr.id(ID_not); } + else if(expr.id() == ID_posedge || expr.id() == ID_negedge) + { + convert_expr(expr.op()); + expr.type() = bool_typet{}; + } + else if(expr.id() == ID_verilog_smv_eventually) + { + convert_expr(expr.op()); + make_boolean(expr.op()); + expr.type() = bool_typet{}; + } + else if( + expr.id() == ID_postincrement || expr.id() == ID_preincrement || + expr.id() == ID_postdecrement || expr.id() == ID_predecrement) + { + convert_expr(expr.op()); + expr.type() = expr.op().type(); + } + else + { + throw errort() << "no conversion for unary expression " << expr.id(); + } return std::move(expr); }