ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
instr.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_ILA_INSTR_H__
5 #define ILANG_ILA_INSTR_H__
6 
7 #include <memory>
8 #include <set>
9 #include <string>
10 
11 #include <ilang/ila/hash_ast.h>
12 #include <ilang/ila/object.h>
13 
15 namespace ilang {
16 
17 // Forward declaration for adding host ila.
18 class InstrLvlAbs;
19 
24 class Instr : public Object {
25 public:
27  typedef std::shared_ptr<Instr> InstrPtr;
29  typedef std::shared_ptr<const Instr> InstrCnstPtr;
31  typedef std::set<std::string> StateNameSet;
32 
33 private:
35  typedef std::map<std::string, ExprPtr> ExprPtrMap;
37  typedef std::shared_ptr<InstrLvlAbs> InstrLvlAbsPtr;
38 
39 public:
40  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
42  Instr(const std::string& name, const InstrLvlAbsPtr& host = nullptr);
44  ~Instr();
45 
46  // ------------------------- HELPERS -------------------------------------- //
49  static InstrPtr New(const std::string& name, InstrLvlAbsPtr host = nullptr);
50 
51  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
53  bool is_instr() const { return true; }
55  inline InstrLvlAbsPtr host() const { return host_; }
56 
59  void set_decode(const ExprPtr& decode);
60 
64  void set_update(const std::string& name, const ExprPtr& update);
65 
70  void set_update(const ExprPtr& state, const ExprPtr& update);
71 
74  void set_program(const InstrLvlAbsPtr& program);
75 
77  inline ExprPtr decode() const { return decode_; }
78 
82  ExprPtr update(const std::string& name) const;
83 
86  ExprPtr update(const ExprPtr& state) const;
87 
90 
92  inline InstrLvlAbsPtr program() const { return prog_; }
93 
94  // ------------------------- METHODS -------------------------------------- //
97  void ForceSetDecode(const ExprPtr& decode);
98 
102  void ForceAddUpdate(const std::string& name, const ExprPtr& update);
103 
105  std::ostream& Print(std::ostream& out) const;
106 
108  friend std::ostream& operator<<(std::ostream& out, InstrPtr i);
110  friend std::ostream& operator<<(std::ostream& out, InstrCnstPtr i);
111 
112 private:
113  // ------------------------- MEMBERS -------------------------------------- //
115  ExprPtr decode_ = nullptr;
117  ExprPtrMap updates_;
118 
120  InstrLvlAbsPtr host_ = nullptr;
121 
123  InstrLvlAbsPtr prog_ = nullptr;
124 
125  // ------------------------- HELPERS -------------------------------------- //
127  ExprPtr Unify(const ExprPtr& e);
128 
129 }; // class Instr
130 
136 typedef std::vector<InstrPtr> InstrVec;
137 
138 } // namespace ilang
139 
140 #endif // ILNAG_ILA_INSTR_H__
std::shared_ptr< const Instr > InstrCnstPtr
Pointer type for read-only use of Instr.
Definition: instr.h:29
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
std::vector< InstrPtr > InstrVec
Type for storing a set of Instr.
Definition: instr.h:136
std::ostream & Print(std::ostream &out) const
Output function.
InstrLvlAbsPtr program() const
Returun the child-ILA comprising the child-program.
Definition: instr.h:92
friend std::ostream & operator<<(std::ostream &out, InstrPtr i)
Overload output stream operator.
bool is_instr() const
Return true if Is type Instr.
Definition: instr.h:53
The class for the Instruction. An Instr object contains:
Definition: instr.h:24
void ForceSetDecode(const ExprPtr &decode)
Set the decode function.
Instr::InstrCnstPtr InstrCnstPtr
Pointer type for read-only use of Instr.
Definition: instr.h:134
ExprPtr update(const std::string &name) const
Return the update function for the state specified by name.
void ForceAddUpdate(const std::string &name, const ExprPtr &update)
Overwrite update function for the state variable specified by name.
void set_decode(const ExprPtr &decode)
Set the decode function if not yet assigned.
Instr::InstrPtr InstrPtr
Pointer type for normal use of Instr.
Definition: instr.h:132
std::shared_ptr< Instr > InstrPtr
Pointer type for normal use of Instr.
Definition: instr.h:27
StateNameSet updated_states() const
return the (potentially) updated state of this function
std::set< std::string > StateNameSet
Type for a set of state names.
Definition: instr.h:31
InstrLvlAbs::InstrLvlAbsPtr InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:326
static InstrPtr New(const std::string &name, InstrLvlAbsPtr host=nullptr)
Create a new instruction (Instr) binded with the host. Used for hiding implementation specific type d...
The basest type in the ILA structure. It can be either Ast, Instr, or InstrLvlAbs.
Definition: object.h:17
void set_update(const std::string &name, const ExprPtr &update)
Set the update function for the state variable specified by name.
ExprPtr decode() const
Return the decode function.
Definition: instr.h:77
~Instr()
Default destructor.
void set_program(const InstrLvlAbsPtr &program)
Set the child-program (as a child-ILA) of the instruction.
InstrLvlAbsPtr host() const
Return the host ILA.
Definition: instr.h:55
Instr(const std::string &name, const InstrLvlAbsPtr &host=nullptr)
Constructor with the ast simplifier.
const Symbol & name() const
Get the symbol (name).