ilang  1.0.2
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 <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__
ilang::BvVal::BvVal
BvVal(const BvValType &val)
Constructor with boolean value.
ilang::MemVal::def_val
const BvValType & def_val() const
Return the default value.
ilang::MemVal::operator<<
friend std::ostream & operator<<(std::ostream &out, const MemVal &val)
Overload output stream operator.
ilang::MemVal::~MemVal
~MemVal()
Default destructor.
ilang::BvVal::val
const BvValType & val() const
Return the arithmetic representation of the value.
ilang::MemVal::MemValMap
std::map< BvValType, BvValType > MemValMap
Type for storing the address/data mapping.
Definition: sort_value.h:116
ilang::MemVal
The container for representing memory (array) values.
Definition: sort_value.h:111
ilang::BvVal::Print
std::ostream & Print(std::ostream &out) const
Output to stream.
ilang::BoolVal::Print
std::ostream & Print(std::ostream &out) const
Output to stream.
ilang::MemVal::val_map
const MemValMap & val_map() const
Return the map of addr/data.
ilang::ValPtr
Value::ValPtr ValPtr
Pointer type for all use of Value.
Definition: sort_value.h:27
ilang::BvValPtr
BvVal::BvValPtr BvValPtr
Pointer type for all use of BvVal.
Definition: sort_value.h:105
ilang::BoolVal::BoolVal
BoolVal(const bool &val)
Constructor with boolean value.
ilang::MemVal::get_data
const BvValType & get_data(const BvValType &addr) const
Return the value stored in the address.
ilang::BoolVal::~BoolVal
~BoolVal()
Default destructor.
ilang::BvVal::BvValPtr
std::shared_ptr< BvVal > BvValPtr
Pointer type for all use of BvVal.
Definition: sort_value.h:73
ilang::MemVal::MemValPtr
std::shared_ptr< MemVal > MemValPtr
Pointer type for all use of MemVal.
Definition: sort_value.h:114
ilang::MemVal::set_data
void set_data(const BvValType &addr, const BvValType &data)
Set the value stored in the address.
ilang::BoolValPtr
BoolVal::BoolValPtr BoolValPtr
Pointer type for all use of BoolVal.
Definition: sort_value.h:65
ilang::BvVal::~BvVal
~BvVal()
Default destructor.
ilang
ilang::BoolVal
The container for representing Boolean values.
Definition: sort_value.h:30
ilang::BvVal::BvValType
uint64_t BvValType
Data type for storing BvVal. NOTE: SHOULD BE SYNCED WITH NumericType!!
Definition: sort_value.h:71
ilang::Value::ValPtr
std::shared_ptr< Value > ValPtr
Pointer type for all use of Value.
Definition: sort_value.h:22
ilang::BoolVal::BoolValPtr
std::shared_ptr< BoolVal > BoolValPtr
Pointer type for all use of BoolVal.
Definition: sort_value.h:33
ilang::BvVal::str
std::string str() const
Return the string representation of the value.
ilang::BoolVal::val
const bool & val() const
Return the bool representation of the value.
ilang::BvValType
BvVal::BvValType BvValType
Data type for storing BvVal.
Definition: sort_value.h:103
ilang::MemVal::Print
std::ostream & Print(std::ostream &out) const
Output to stream.
ilang::BoolVal::str
std::string str() const
Return the string representation of the value.
ilang::Value
The base type for constant value.
Definition: sort_value.h:17
ilang::MemVal::MemVal
MemVal(const BvValType &def_val)
Constructor with only the default value.
ilang::Value::~Value
virtual ~Value()
virtual destructor.
Definition: sort_value.h:20
ilang::BvVal
The container for representing Bitvector values.
Definition: sort_value.h:68
ilang::BoolVal::operator<<
friend std::ostream & operator<<(std::ostream &out, const BoolVal &val)
Overload output stream operator.
ilang::MemValPtr
MemVal::MemValPtr MemValPtr
Pointer type for all use of MemVal.
Definition: sort_value.h:153
ilang::MemValMap
MemVal::MemValMap MemValMap
Type for storing the address/data mapping.
Definition: sort_value.h:155
ilang::BvVal::operator<<
friend std::ostream & operator<<(std::ostream &out, const BvVal &val)
Overload output stream operator.