CBMC
boolbv_not.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "boolbv.h"
10 
11 #include <util/bitvector_types.h>
12 
14 {
15  const bvt &op_bv=convert_bv(expr.op());
16  CHECK_RETURN(!op_bv.empty());
17 
18  const typet &op_type=expr.op().type();
19 
20  if(op_type.id()!=ID_verilog_signedbv ||
21  op_type.id()!=ID_verilog_unsignedbv)
22  {
23  if(
24  (expr.type().id() == ID_verilog_signedbv ||
25  expr.type().id() == ID_verilog_unsignedbv) &&
26  to_bitvector_type(expr.type()).get_width() == 1)
27  {
28  literalt has_x_or_z=bv_utils.verilog_bv_has_x_or_z(op_bv);
29  literalt normal_bits_zero=
31 
32  bvt bv;
33  bv.resize(2);
34 
35  // this returns 'x' for 'z'
36  bv[0]=prop.lselect(has_x_or_z, const_literal(false), normal_bits_zero);
37  bv[1]=has_x_or_z;
38 
39  return bv;
40  }
41  }
42 
43 
44  return conversion_failed(expr);
45 }
CHECK_RETURN
#define CHECK_RETURN(CONDITION)
Definition: invariant.h:495
typet
The type of an expression, extends irept.
Definition: type.h:28
bvt
std::vector< literalt > bvt
Definition: literal.h:201
to_bitvector_type
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
Definition: bitvector_types.h:32
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
boolbvt::convert_bv
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition: boolbv.cpp:39
bitvector_types.h
const_literal
literalt const_literal(bool value)
Definition: literal.h:188
irept::id
const irep_idt & id() const
Definition: irep.h:396
unary_exprt::op
const exprt & op() const
Definition: std_expr.h:326
bitvector_typet::get_width
std::size_t get_width() const
Definition: std_types.h:876
boolbvt::bv_utils
bv_utilst bv_utils
Definition: boolbv.h:117
literalt
Definition: literal.h:25
boolbvt::conversion_failed
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
Definition: boolbv.cpp:83
boolbv.h
bv_utilst::verilog_bv_normal_bits
static bvt verilog_bv_normal_bits(const bvt &)
Definition: bv_utils.cpp:1408
boolbvt::convert_not
virtual bvt convert_not(const not_exprt &expr)
Definition: boolbv_not.cpp:13
bv_utilst::is_zero
literalt is_zero(const bvt &op)
Definition: bv_utils.h:143
propt::lselect
virtual literalt lselect(literalt a, literalt b, literalt c)=0
bv_utilst::verilog_bv_has_x_or_z
literalt verilog_bv_has_x_or_z(const bvt &)
Definition: bv_utils.cpp:1393
prop_conv_solvert::prop
propt & prop
Definition: prop_conv_solver.h:130
not_exprt
Boolean negation.
Definition: std_expr.h:2277