cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_replication.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/arith_tools.h
>
12
#include <
util/bitvector_expr.h
>
13
14
bvt
boolbvt::convert_replication
(
const
replication_exprt
&expr)
15
{
16
std::size_t width=
boolbv_width
(expr.
type
());
17
18
mp_integer
times =
numeric_cast_v<mp_integer>
(expr.
times
());
19
20
bvt
bv;
21
bv.resize(width);
22
23
const
std::size_t u_times =
numeric_cast_v<std::size_t>
(times);
24
const
bvt
&op =
convert_bv
(expr.
op
());
25
26
INVARIANT
(
27
op.size() * u_times == bv.size(),
28
"result bitvector width shall be equal to the operand bitvector width times"
29
"the number of replications"
);
30
31
std::size_t bit_idx = 0;
32
33
for
(std::size_t i = 0; i < u_times; i++)
34
{
35
for
(
const
auto
&bit : op)
36
{
37
bv[bit_idx] = bit;
38
bit_idx++;
39
}
40
}
41
42
return
bv;
43
}
arith_tools.h
numeric_cast_v
Target numeric_cast_v(const mp_integer &arg)
Convert an mp_integer to integral type Target An invariant will fail if the conversion is not possibl...
Definition
arith_tools.h:135
bitvector_expr.h
API to expression classes for bitvectors.
boolbv.h
boolbvt::convert_bv
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:40
boolbvt::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
boolbvt::convert_replication
virtual bvt convert_replication(const replication_exprt &expr)
Definition
boolbv_replication.cpp:14
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
replication_exprt
Bit-vector replication.
Definition
bitvector_expr.h:886
replication_exprt::times
constant_exprt & times()
Definition
bitvector_expr.h:897
replication_exprt::op
exprt & op()
Definition
bitvector_expr.h:907
bvt
std::vector< literalt > bvt
Definition
literal.h:201
mp_integer
BigInt mp_integer
Definition
smt_terms.h:17
INVARIANT
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition
invariant.h:423
solvers
flattening
boolbv_replication.cpp
Generated by
1.17.0