cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
fixedbv.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
10
#ifndef CPROVER_UTIL_FIXEDBV_H
11
#define CPROVER_UTIL_FIXEDBV_H
12
13
#include "
mp_arith.h
"
14
#include "
format_spec.h
"
15
16
class
constant_exprt
;
17
class
fixedbv_typet
;
18
19
class
fixedbv_spect
20
{
21
public
:
22
std::size_t
integer_bits
,
width
;
23
24
fixedbv_spect
():
integer_bits
(0),
width
(0)
25
{
26
}
27
28
fixedbv_spect
(std::size_t _width, std::size_t _integer_bits):
29
integer_bits
(_integer_bits),
width
(_width)
30
{
31
}
32
33
explicit
fixedbv_spect
(
const
fixedbv_typet
&type);
34
35
std::size_t
get_fraction_bits
()
const
36
{
37
return
width
-
integer_bits
;
38
}
39
};
40
41
class
fixedbvt
42
{
43
public
:
44
fixedbv_spect
spec
;
45
46
fixedbvt
():
v
(0)
47
{
48
}
49
50
explicit
fixedbvt
(
const
fixedbv_spect
&_spec):
spec
(_spec),
v
(0)
51
{
52
}
53
54
explicit
fixedbvt
(
const
constant_exprt
&expr);
55
56
void
from_integer
(
const
mp_integer
&i);
57
mp_integer
to_integer
()
const
;
// this rounds to zero
58
void
from_expr
(
const
constant_exprt
&expr);
59
constant_exprt
to_expr
()
const
;
60
void
round
(
const
fixedbv_spect
&dest_spec);
61
62
std::string
to_ansi_c_string
()
const
63
{
64
return
format
(
format_spect
());
65
}
66
67
std::string
format
(
const
format_spect
&format_spec)
const
;
68
69
bool
operator==
(
int
i)
const
;
70
71
bool
is_zero
()
const
72
{
73
return
v
==0;
74
}
75
76
static
fixedbvt
zero
(
const
fixedbv_typet
&type)
77
{
78
return
fixedbvt
(
fixedbv_spect
(type));
79
}
80
81
void
negate
();
82
83
fixedbvt
&
operator/=
(
const
fixedbvt
&other);
84
fixedbvt
&
operator*=
(
const
fixedbvt
&other);
85
fixedbvt
&
operator+=
(
const
fixedbvt
&other);
86
fixedbvt
&
operator-=
(
const
fixedbvt
&other);
87
88
bool
operator<
(
const
fixedbvt
&other)
const
{
return
v
<other.
v
; }
89
bool
operator<=
(
const
fixedbvt
&other)
const
{
return
v
<=other.
v
; }
90
bool
operator>
(
const
fixedbvt
&other)
const
{
return
v
>other.
v
; }
91
bool
operator>=
(
const
fixedbvt
&other)
const
{
return
v
>=other.
v
; }
92
bool
operator==
(
const
fixedbvt
&other)
const
{
return
v
==other.
v
; }
93
bool
operator!=
(
const
fixedbvt
&other)
const
{
return
v
!=other.
v
; }
94
95
const
mp_integer
&
get_value
()
const
{
return
v
; }
96
void
set_value
(
const
mp_integer
&_v) {
v
=_v; }
97
98
protected
:
99
// negative values stored as such
100
mp_integer
v
;
101
};
102
103
#endif
// CPROVER_UTIL_FIXEDBV_H
constant_exprt
A constant literal expression.
Definition
std_expr.h:2997
fixedbv_spect
Definition
fixedbv.h:20
fixedbv_spect::integer_bits
std::size_t integer_bits
Definition
fixedbv.h:22
fixedbv_spect::fixedbv_spect
fixedbv_spect(std::size_t _width, std::size_t _integer_bits)
Definition
fixedbv.h:28
fixedbv_spect::width
std::size_t width
Definition
fixedbv.h:22
fixedbv_spect::fixedbv_spect
fixedbv_spect()
Definition
fixedbv.h:24
fixedbv_spect::get_fraction_bits
std::size_t get_fraction_bits() const
Definition
fixedbv.h:35
fixedbv_typet
Fixed-width bit-vector with signed fixed-point interpretation.
Definition
bitvector_types.h:280
fixedbvt
Definition
fixedbv.h:42
fixedbvt::spec
fixedbv_spect spec
Definition
fixedbv.h:44
fixedbvt::operator>=
bool operator>=(const fixedbvt &other) const
Definition
fixedbv.h:91
fixedbvt::fixedbvt
fixedbvt()
Definition
fixedbv.h:46
fixedbvt::from_integer
void from_integer(const mp_integer &i)
Definition
fixedbv.cpp:32
fixedbvt::from_expr
void from_expr(const constant_exprt &expr)
Definition
fixedbv.cpp:26
fixedbvt::negate
void negate()
Definition
fixedbv.cpp:90
fixedbvt::operator<=
bool operator<=(const fixedbvt &other) const
Definition
fixedbv.h:89
fixedbvt::operator==
bool operator==(int i) const
Definition
fixedbv.cpp:129
fixedbvt::get_value
const mp_integer & get_value() const
Definition
fixedbv.h:95
fixedbvt::operator+=
fixedbvt & operator+=(const fixedbvt &other)
Definition
fixedbv.cpp:109
fixedbvt::to_integer
mp_integer to_integer() const
Definition
fixedbv.cpp:37
fixedbvt::operator<
bool operator<(const fixedbvt &other) const
Definition
fixedbv.h:88
fixedbvt::operator*=
fixedbvt & operator*=(const fixedbvt &other)
Definition
fixedbv.cpp:95
fixedbvt::set_value
void set_value(const mp_integer &_v)
Definition
fixedbv.h:96
fixedbvt::round
void round(const fixedbv_spect &dest_spec)
Definition
fixedbv.cpp:52
fixedbvt::zero
static fixedbvt zero(const fixedbv_typet &type)
Definition
fixedbv.h:76
fixedbvt::format
std::string format(const format_spect &format_spec) const
Definition
fixedbv.cpp:134
fixedbvt::to_ansi_c_string
std::string to_ansi_c_string() const
Definition
fixedbv.h:62
fixedbvt::operator/=
fixedbvt & operator/=(const fixedbvt &other)
Definition
fixedbv.cpp:121
fixedbvt::operator>
bool operator>(const fixedbvt &other) const
Definition
fixedbv.h:90
fixedbvt::operator-=
fixedbvt & operator-=(const fixedbvt &other)
Definition
fixedbv.cpp:115
fixedbvt::fixedbvt
fixedbvt(const fixedbv_spect &_spec)
Definition
fixedbv.h:50
fixedbvt::is_zero
bool is_zero() const
Definition
fixedbv.h:71
fixedbvt::v
mp_integer v
Definition
fixedbv.h:100
fixedbvt::operator!=
bool operator!=(const fixedbvt &other) const
Definition
fixedbv.h:93
fixedbvt::to_expr
constant_exprt to_expr() const
Definition
fixedbv.cpp:43
fixedbvt::operator==
bool operator==(const fixedbvt &other) const
Definition
fixedbv.h:92
format_spect
Definition
format_spec.h:16
format_spec.h
mp_arith.h
mp_integer
BigInt mp_integer
Definition
smt_terms.h:17
util
fixedbv.h
Generated by
1.17.0