-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #735 from diffblue/power1-fix
Verilog: four-valued power
- Loading branch information
Showing
8 changed files
with
162 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
KNOWNBUG | ||
CORE broken-smt-backend | ||
power1.sv | ||
--bound 0 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
Lowering for power on three-valued logic is missing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ Author: Daniel Kroening, [email protected] | |
#define CPROVER_VERILOG_AVAL_BVAL_H | ||
|
||
#include <util/bitvector_types.h> | ||
#include <util/mathematical_expr.h> | ||
|
||
#include "verilog_expr.h" | ||
|
||
|
@@ -47,5 +48,7 @@ exprt aval_bval(const not_exprt &); | |
exprt aval_bval(const verilog_wildcard_equality_exprt &); | ||
/// lowering for !=? | ||
exprt aval_bval(const verilog_wildcard_inequality_exprt &); | ||
/// lowering for ** | ||
exprt aval_bval(const power_exprt &); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected] | |
#include <util/bitvector_expr.h> | ||
#include <util/ebmc_util.h> | ||
#include <util/expr_util.h> | ||
#include <util/mathematical_expr.h> | ||
#include <util/mathematical_types.h> | ||
#include <util/namespace.h> | ||
#include <util/prefix.h> | ||
|
@@ -123,14 +124,11 @@ void verilog_typecheck_exprt::propagate_type( | |
expr.has_operands()) | ||
{ | ||
// arithmetic | ||
|
||
if(expr.id()==ID_plus || | ||
expr.id()==ID_minus || | ||
expr.id()==ID_mult || | ||
expr.id()==ID_div || | ||
expr.id()==ID_power || | ||
expr.id()==ID_unary_minus || | ||
expr.id()==ID_unary_plus) | ||
|
||
if( | ||
expr.id() == ID_plus || expr.id() == ID_minus || expr.id() == ID_mult || | ||
expr.id() == ID_div || expr.id() == ID_unary_minus || | ||
expr.id() == ID_unary_plus) | ||
{ | ||
if(type.id()!=ID_bool) | ||
{ | ||
|
@@ -2611,6 +2609,44 @@ Function: verilog_typecheck_exprt::convert_shl_expr | |
\*******************************************************************/ | ||
|
||
exprt verilog_typecheck_exprt::convert_power_expr(power_exprt expr) | ||
{ | ||
convert_expr(expr.op0()); | ||
convert_expr(expr.op1()); | ||
|
||
no_bool_ops(expr); | ||
|
||
// Is one of the operands four-valued? | ||
if(is_four_valued(expr.op0().type())) | ||
{ | ||
// We make the other operand also four-valued, if needed | ||
expr.op1() = typecast_exprt{expr.op1(), four_valued(expr.op1().type())}; | ||
} | ||
else if(is_four_valued(expr.op1().type())) | ||
{ | ||
// We make the other operand also four-valued, if needed | ||
expr.op0() = typecast_exprt{expr.op0(), four_valued(expr.op0().type())}; | ||
} | ||
|
||
// 1800-2017 Table 11-21 | ||
// The width of a power is the width of the left operand | ||
expr.type() = expr.op0().type(); | ||
|
||
return std::move(expr); | ||
} | ||
|
||
/*******************************************************************\ | ||
Function: verilog_typecheck_exprt::convert_shl_expr | ||
Inputs: | ||
Outputs: | ||
Purpose: | ||
\*******************************************************************/ | ||
|
||
exprt verilog_typecheck_exprt::convert_shl_expr(shl_exprt expr) | ||
{ | ||
convert_expr(expr.op0()); | ||
|
@@ -2760,6 +2796,8 @@ exprt verilog_typecheck_exprt::convert_binary_expr(binary_exprt expr) | |
|
||
return std::move(expr); | ||
} | ||
else if(expr.id() == ID_power) | ||
return convert_power_expr(to_power_expr(expr)); | ||
else if(expr.id()==ID_shl) | ||
return convert_shl_expr(to_shl_expr(expr)); | ||
else if(expr.id()==ID_shr) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected] | |
#include <stack> | ||
|
||
class function_call_exprt; | ||
class power_exprt; | ||
|
||
class verilog_typecheck_exprt:public verilog_typecheck_baset | ||
{ | ||
|
@@ -168,6 +169,7 @@ class verilog_typecheck_exprt:public verilog_typecheck_baset | |
convert_system_function(const irep_idt &identifier, function_call_exprt); | ||
[[nodiscard]] exprt convert_bit_select_expr(binary_exprt); | ||
[[nodiscard]] exprt convert_replication_expr(replication_exprt); | ||
[[nodiscard]] exprt convert_power_expr(power_exprt); | ||
[[nodiscard]] exprt convert_shl_expr(shl_exprt); | ||
void implicit_typecast(exprt &, const typet &type); | ||
void tc_binary_expr(exprt &); | ||
|