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 }
Pre-defined bitvector types.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
std::size_t get_width() const
Definition: std_types.h:925
virtual const bvt & convert_bv(const exprt &expr, const std::optional< 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
virtual bvt convert_not(const not_exprt &expr)
Definition: boolbv_not.cpp:13
bv_utilst bv_utils
Definition: boolbv.h:117
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:94
static bvt verilog_bv_normal_bits(const bvt &)
Definition: bv_utils.cpp:1633
literalt is_zero(const bvt &op)
Definition: bv_utils.h:143
literalt verilog_bv_has_x_or_z(const bvt &)
Definition: bv_utils.cpp:1618
typet & type()
Return the type of the expression.
Definition: expr.h:84
const irep_idt & id() const
Definition: irep.h:388
Boolean negation.
Definition: std_expr.h:2337
virtual literalt lselect(literalt a, literalt b, literalt c)=0
The type of an expression, extends irept.
Definition: type.h:29
const exprt & op() const
Definition: std_expr.h:391
std::vector< literalt > bvt
Definition: literal.h:201
literalt const_literal(bool value)
Definition: literal.h:188
#define CHECK_RETURN(CONDITION)
Definition: invariant.h:495