-
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.
Verilog: aval/bval lowering for casts to Bool
This implements casing four-valued ava/bval encoded cast to Bool. In particular, values containing x or z cast to false, not true.
- Loading branch information
Showing
7 changed files
with
35 additions
and
8 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,14 +1,12 @@ | ||
KNOWNBUG | ||
CORE | ||
sequence5.sv | ||
--bound 0 | ||
^\[main\.p0\] 1: PROVED up to bound 0$ | ||
^\[main\.p1\] 0: REFUTED$ | ||
^\[main\.p2\] 1'bx: PROVED up to bound 0$ | ||
^\[main\.p3\] 1'bz: PROVED up to bound 0$ | ||
^\[main\.p2\] 1'bx: REFUTED$ | ||
^\[main\.p3\] 1'bz: REFUTED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
x and z are recognized as 'true', but 'true' is defined as a "nonzero known | ||
value" (1800-2017 12.4). |
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
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 |
---|---|---|
|
@@ -24,7 +24,9 @@ Author: Daniel Kroening, [email protected] | |
// 1 1 | Z | ||
|
||
bool is_four_valued(const typet &); | ||
bool is_four_valued(const exprt &); | ||
bool is_aval_bval(const typet &); | ||
bool is_aval_bval(const exprt &); | ||
std::size_t aval_bval_width(const typet &); | ||
typet aval_bval_underlying(const typet &); | ||
|
||
|
@@ -50,5 +52,7 @@ exprt aval_bval(const verilog_wildcard_equality_exprt &); | |
exprt aval_bval(const verilog_wildcard_inequality_exprt &); | ||
/// lowering for ** | ||
exprt aval_bval(const power_exprt &); | ||
/// lowering for typecasts | ||
exprt aval_bval(const typecast_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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ Author: Daniel Kroening, [email protected] | |
#include "verilog_typecheck_expr.h" | ||
|
||
#include <cassert> | ||
#include <iostream> | ||
#include <map> | ||
#include <set> | ||
|
||
|
@@ -304,6 +305,13 @@ exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state) | |
} | ||
else if(expr.id()==ID_typecast) | ||
{ | ||
// When casting a four-valued scalar to bool, | ||
// 'true' is defined as a "nonzero known value" (1800-2017 12.4). | ||
if(is_aval_bval(to_typecast_expr(expr).op()) && expr.type().id() == ID_bool) | ||
{ | ||
expr = aval_bval(to_typecast_expr(expr)); | ||
} | ||
else | ||
{ | ||
auto &op = to_typecast_expr(expr).op(); | ||
|
||
|