ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
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 <cstdint>
8 #include <map>
9 #include <memory>
10 #include <ostream>
11 #include <string>
12 
14 namespace ilang {
15 
17 class Value {
18 public:
20  virtual ~Value() {}
22  typedef std::shared_ptr<Value> ValPtr;
23 
24 }; // class Value
25 
28 
30 class BoolVal : public Value {
31 public:
33  typedef std::shared_ptr<BoolVal> BoolValPtr;
34 
35  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
37  BoolVal(const bool& val);
39  BoolVal(const std::string& str);
41  BoolVal(const char* cstr);
43  ~BoolVal();
44 
45  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
47  std::string str() const;
49  const bool& val() const;
50 
51  // ------------------------- METHODS -------------------------------------- //
53  std::ostream& Print(std::ostream& out) const;
55  friend std::ostream& operator<<(std::ostream& out, const BoolVal& val);
56 
57 private:
58  // ------------------------- MEMBERS -------------------------------------- //
60  bool val_;
61 
62 }; // class BoolVal
63 
66 
68 class BvVal : public Value {
69 public:
71  typedef uint64_t BvValType;
73  typedef std::shared_ptr<BvVal> BvValPtr;
74 
75  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
77  BvVal(const BvValType& val);
79  BvVal(const std::string& str);
81  ~BvVal();
82 
83  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
85  std::string str() const;
87  const BvValType& val() const;
88 
89  // ------------------------- METHODS -------------------------------------- //
91  std::ostream& Print(std::ostream& out) const;
93  friend std::ostream& operator<<(std::ostream& out, const BvVal& val);
94 
95 private:
96  // ------------------------- MEMBERS -------------------------------------- //
98  BvValType val_;
99 
100 }; // class BvVal
101 
106 
108 #define BvValTypeBitWidth (8 * sizeof(BvValType))
109 
111 class MemVal : public Value {
112 public:
114  typedef std::shared_ptr<MemVal> MemValPtr;
116  typedef std::map<BvValType, BvValType> MemValMap;
117 
118  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
120  MemVal(const BvValType& def_val);
122  MemVal(const BvValType& def_val, const MemValMap& vals);
124  ~MemVal();
125 
126  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
128  const MemValMap& val_map() const;
130  const BvValType& def_val() const;
131 
133  const BvValType& get_data(const BvValType& addr) const;
135  void set_data(const BvValType& addr, const BvValType& data);
136 
137  // ------------------------- METHODS ---------------------------------------//
139  std::ostream& Print(std::ostream& out) const;
141  friend std::ostream& operator<<(std::ostream& out, const MemVal& val);
142 
143 private:
144  // ------------------------- MEMBERS -------------------------------------- //
146  MemValMap val_map_;
148  BvValType default_;
149 
150 }; // class MemVal
151 
156 
157 } // namespace ilang
158 
159 #endif // ILANG_ILA_AST_SORT_VALUE_H__
MemVal(const BvValType &def_val)
Constructor with only the default value.
friend std::ostream & operator<<(std::ostream &out, const BvVal &val)
Overload output stream operator.
The base type for constant value.
Definition: sort_value.h:17
std::ostream & Print(std::ostream &out) const
Output to stream.
BvVal(const BvValType &val)
Constructor with boolean value.
const MemValMap & val_map() const
Return the map of addr/data.
friend std::ostream & operator<<(std::ostream &out, const MemVal &val)
Overload output stream operator.
~BoolVal()
Default destructor.
Value::ValPtr ValPtr
Pointer type for all use of Value.
Definition: sort_value.h:27
friend std::ostream & operator<<(std::ostream &out, const BoolVal &val)
Overload output stream operator.
std::map< BvValType, BvValType > MemValMap
Type for storing the address/data mapping.
Definition: sort_value.h:116
std::shared_ptr< MemVal > MemValPtr
Pointer type for all use of MemVal.
Definition: sort_value.h:114
MemVal::MemValPtr MemValPtr
Pointer type for all use of MemVal.
Definition: sort_value.h:153
BoolVal(const bool &val)
Constructor with boolean value.
The container for representing Boolean values.
Definition: sort_value.h:30
BoolVal::BoolValPtr BoolValPtr
Pointer type for all use of BoolVal.
Definition: sort_value.h:65
~BvVal()
Default destructor.
void set_data(const BvValType &addr, const BvValType &data)
Set the value stored in the address.
BvVal::BvValPtr BvValPtr
Pointer type for all use of BvVal.
Definition: sort_value.h:105
virtual ~Value()
virtual destructor.
Definition: sort_value.h:20
uint64_t BvValType
Data type for storing BvVal. NOTE: SHOULD BE SYNCED WITH NumericType!!
Definition: sort_value.h:71
const BvValType & get_data(const BvValType &addr) const
Return the value stored in the address.
std::string str() const
Return the string representation of the value.
std::ostream & Print(std::ostream &out) const
Output to stream.
MemVal::MemValMap MemValMap
Type for storing the address/data mapping.
Definition: sort_value.h:155
std::ostream & Print(std::ostream &out) const
Output to stream.
The container for representing memory (array) values.
Definition: sort_value.h:111
std::shared_ptr< BvVal > BvValPtr
Pointer type for all use of BvVal.
Definition: sort_value.h:73
The container for representing Bitvector values.
Definition: sort_value.h:68
const bool & val() const
Return the bool representation of the value.
BvVal::BvValType BvValType
Data type for storing BvVal.
Definition: sort_value.h:103
std::shared_ptr< Value > ValPtr
Pointer type for all use of Value.
Definition: sort_value.h:22
const BvValType & val() const
Return the arithmetic representation of the value.
std::shared_ptr< BoolVal > BoolValPtr
Pointer type for all use of BoolVal.
Definition: sort_value.h:33
const BvValType & def_val() const
Return the default value.
~MemVal()
Default destructor.
std::string str() const
Return the string representation of the value.