ilang  1.0.0
ILAng: A Modeling and Verification Platform for SoCs
sort_value.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_ILA_AST_SORT_VALUE_H__
5 #define ILANG_ILA_AST_SORT_VALUE_H__
6 
7 #include <map>
8 #include <memory>
9 #include <ostream>
10 #include <string>
11 
13 namespace ilang {
14 
16 class Value {
17 public:
19  virtual ~Value() {}
21  typedef std::shared_ptr<Value> ValPtr;
22 
23 }; // class Value
24 
27 
29 class BoolVal : public Value {
30 public:
32  typedef std::shared_ptr<BoolVal> BoolValPtr;
33 
34  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
36  BoolVal(const bool& val);
38  BoolVal(const std::string& str);
40  BoolVal(const char* cstr);
42  ~BoolVal();
43 
44  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
46  std::string str() const;
48  const bool& val() const;
49 
50  // ------------------------- METHODS -------------------------------------- //
52  std::ostream& Print(std::ostream& out) const;
54  friend std::ostream& operator<<(std::ostream& out, const BoolVal& val);
55 
56 private:
57  // ------------------------- MEMBERS -------------------------------------- //
59  bool val_;
60 
61 }; // class BoolVal
62 
65 
67 class BvVal : public Value {
68 public:
70  typedef int BvValType;
72  typedef std::shared_ptr<BvVal> BvValPtr;
73 
74  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
76  BvVal(const int& val);
78  BvVal(const std::string& str);
80  ~BvVal();
81 
82  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
84  std::string str() const;
86  const int& val() const;
87 
88  // ------------------------- METHODS -------------------------------------- //
90  std::ostream& Print(std::ostream& out) const;
92  friend std::ostream& operator<<(std::ostream& out, const BvVal& val);
93 
94 private:
95  // ------------------------- MEMBERS -------------------------------------- //
97  BvValType val_;
98 
99 }; // class BvVal
100 
105 
107 class MemVal : public Value {
108 public:
110  typedef std::shared_ptr<MemVal> MemValPtr;
112  typedef std::map<int, int> MemValMap;
113 
114  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
116  MemVal(const int& def_val);
118  MemVal(const int& def_val, const MemValMap& vals);
120  ~MemVal();
121 
122  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
124  const MemValMap& val_map() const;
126  const int& def_val() const;
127 
129  const int& get_data(const int& addr) const;
131  void set_data(const int& addr, const int& data);
132 
133  // ------------------------- METHODS ---------------------------------------//
135  std::ostream& Print(std::ostream& out) const;
137  friend std::ostream& operator<<(std::ostream& out, const MemVal& val);
138 
139 private:
140  // ------------------------- MEMBERS -------------------------------------- //
142  MemValMap val_map_;
144  int default_;
145 
146 }; // class MemVal
147 
152 
153 } // namespace ilang
154 
155 #endif // ILANG_ILA_AST_SORT_VALUE_H__
ExprRef operator<<(const ExprRef &a, const ExprRef &b)
Left shift for bit-vectors.
The base type for constant value.
Definition: sort_value.h:16
int BvValType
Data type for storing BvVal.
Definition: sort_value.h:70
std::shared_ptr< MemVal > MemValPtr
Pointer type for all use of MemVal.
Definition: sort_value.h:110
MemVal::MemValPtr MemValPtr
Pointer type for all use of MemVal.
Definition: sort_value.h:149
The container for representing Boolean values.
Definition: sort_value.h:29
BoolVal::BoolValPtr BoolValPtr
Pointer type for all use of BoolVal.
Definition: sort_value.h:64
BvVal::BvValPtr BvValPtr
Pointer type for all use of BvVal.
Definition: sort_value.h:104
virtual ~Value()
virtual destructor.
Definition: sort_value.h:19
MemVal::MemValMap MemValMap
Type for storing the address/data mapping.
Definition: sort_value.h:151
The container for representing memory (array) values.
Definition: sort_value.h:107
std::map< int, int > MemValMap
Type for storing the address/data mapping.
Definition: sort_value.h:112
std::shared_ptr< BvVal > BvValPtr
Pointer type for all use of BvVal.
Definition: sort_value.h:72
The container for representing Bitvector values.
Definition: sort_value.h:67
BvVal::BvValType BvValType
Data type for storing BvVal.
Definition: sort_value.h:102
std::shared_ptr< Value > ValPtr
Pointer type for all use of Value.
Definition: sort_value.h:21
std::shared_ptr< BoolVal > BoolValPtr
Pointer type for all use of BoolVal.
Definition: sort_value.h:32