4 #ifndef ILANG_ILA_INSTR_LVL_ABS_H__
5 #define ILANG_ILA_INSTR_LVL_ABS_H__
36 public std::enable_shared_from_this<InstrLvlAbs> {
70 inline bool is_spec()
const {
return is_spec_; }
77 inline void set_spec(
bool spec) { is_spec_ = spec; }
92 inline size_t init_num()
const {
return inits_.size(); }
100 inline const ExprPtr input(
const size_t& i)
const {
return inputs_[i]; }
102 inline const ExprPtr state(
const size_t& i)
const {
return states_[i]; }
130 const InstrSeqPtr& instr_seq()
const {
return instr_seq_; }
180 const int& data_width);
199 const int& data_width);
218 const int& data_width);
248 std::ostream&
Print(std::ostream& out)
const;
263 auto child_i = this->
child(i);
264 child_i->DepthFirstVisit<F>(func);
267 func(shared_from_this());
274 if (func.pre(shared_from_this())) {
279 auto child_i = this->
child(i);
280 child_i->DepthFirstVisitPrePost<F>(func);
283 func.post(shared_from_this());
308 bool is_spec_ =
true;
330 typedef std::map<InstrLvlAbsCnstPtr, InstrLvlAbsPtr>
CnstIlaMap;
334 #endif // ILANG_ILA_INSTR_LVL_ABS_H__
size_t input_num() const
Return the number of input variables.
Definition: instr_lvl_abs.h:84
const ExprPtr init(const size_t &i) const
Access the i-th initial condition.
Definition: instr_lvl_abs.h:110
void ForceSetFetch(const ExprPtr &fetch_expr)
Set the fetch function no matter if is already set.
const InstrPtr find_instr(const Symbol &name) const
Return the named instruction; return NULL if not registered.
const ExprPtr find_input(const Symbol &name) const
Return the named input variable; return NULL if not registered.
ExprMngr::ExprMngrPtr ExprMngrPtr
Pointer type for passing shared ast simplifier.
Definition: hash_ast.h:56
std::shared_ptr< const InstrLvlAbs > InstrLvlAbsCnstPtr
Pointer type for read-only usage of InstrLvlAbs.
Definition: instr_lvl_abs.h:41
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
size_t instr_num() const
Return the number of instructions.
Definition: instr_lvl_abs.h:88
bool is_instr_lvl_abs() const
Return true if is InstrLvlAbs.
Definition: instr_lvl_abs.h:67
InstrLvlAbs::InstrLvlAbsCnstPtr InstrLvlAbsCnstPtr
Pointer type for read-only usage of InstrLvlAbs.
Definition: instr_lvl_abs.h:328
std::string GetRootName() const
Return the ancestor names in sequence.
void AddSeqTran(const InstrPtr &src, const InstrPtr &dst, const ExprPtr &cnd)
Define instruction sequencing by adding a transition edge.
std::shared_ptr< InstrLvlAbs > InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:39
std::ostream & Print(std::ostream &out) const
Output stream function.
void set_expr_mngr(const ExprMngrPtr expr_mngr)
Update the ast simplifier.
Definition: instr_lvl_abs.h:79
const ExprPtr NewBvState(const std::string &name, const int &bit_width)
Create one Bitvector variable and register as a state.
void AddChild(const InstrLvlAbsPtr &child)
Add one ILA to the child list. No simplification between ILAs.
const InstrLvlAbsPtr find_child(const Symbol &name) const
Return the named child-ILA; return NULL if not registered.
const ExprPtr fetch() const
Return the fetch function.
Definition: instr_lvl_abs.h:95
const ExprPtr state(const size_t &i) const
Access the i-th state variable.
Definition: instr_lvl_abs.h:102
size_t state_num() const
Return the number of state variables.
Definition: instr_lvl_abs.h:86
void ForceSetValid(const ExprPtr &valid_expr)
Set the valid function no matter if is already set.
void set_spec(bool spec)
Set the ILA to be specification if true.
Definition: instr_lvl_abs.h:77
KeyVec< Symbol, InstrLvlAbsPtr > InstrLvlAbsMap
Type for storing a set of ILA (child-ILAs).
Definition: instr_lvl_abs.h:43
void SetFetch(const ExprPtr &fetch_expr)
Set the fetch function, and simplify (if needed) by the simplifier.
void AddInit(const ExprPtr &cntr_expr)
Add one constraint to the initial condition, i.e. no contraint means arbitrary initial values to the ...
void DepthFirstVisit(F &func) const
Templated visitor: visit each child-ILA in a depth-first order.
Definition: instr_lvl_abs.h:260
Instr::InstrPtr InstrPtr
Pointer type for normal use of Instr.
Definition: instr.h:132
size_t size() const
Return the number of data stored.
Definition: container.h:78
const ExprPtr NewMemState(const std::string &name, const int &addr_width, const int &data_width)
Create one Memory variable and register as a state.
const InstrPtr NewInstr(const std::string &name="")
Create and register one instruction.
The class of Instruction-Level Abstraction (ILA). An ILA contains:
Definition: instr_lvl_abs.h:35
const ExprPtr valid() const
Return the valid function.
Definition: instr_lvl_abs.h:97
std::map< InstrLvlAbsCnstPtr, InstrLvlAbsPtr > CnstIlaMap
Type for storing a mapping from constant ILA ptr to ILA ptr.
Definition: instr_lvl_abs.h:330
InstrLvlAbs(const std::string &name="", const InstrLvlAbsPtr &parent=nullptr)
Consturctor.
Expr::ExprPtrVec ExprPtrVec
Type for storing a set of Expr.
Definition: expr.h:140
InstrLvlAbs::InstrLvlAbsPtr InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:326
void DepthFirstVisitPrePost(F &func) const
Templated visitor: visit each child-ILA in a depth-first order and apply the function object F pre/po...
Definition: instr_lvl_abs.h:272
const InstrLvlAbsPtr child(const size_t &i) const
Access the i-th child-ILA.
Definition: instr_lvl_abs.h:106
const ExprPtr NewBvInput(const std::string &name, const int &bit_width)
Create one Bitvector variable and register as an input.
const InstrLvlAbsPtr parent() const
Return the parent ILA.
Definition: instr_lvl_abs.h:72
void AddInstr(const InstrPtr &instr)
Add one instruction to the ILA, and simplify (if needed). Note that only fully constructed instructio...
size_t child_num() const
Return the number of child-ILAs.
Definition: instr_lvl_abs.h:90
The basest type in the ILA structure. It can be either Ast, Instr, or InstrLvlAbs.
Definition: object.h:17
InstrSeq::InstrSeqPtr InstrSeqPtr
Pointer type for passing around InstrSeq.
Definition: transition.h:140
const InstrPtr instr(const size_t &i) const
Access the i-th instruction.
Definition: instr_lvl_abs.h:104
void AddState(const ExprPtr &state_var)
Add one state variable to the ILA, and register to the simplifier.
const ExprPtr NewBoolInput(const std::string &name)
Create one Boolean variable and register as an input.
bool is_spec() const
Return true if is specification (not implementation).
Definition: instr_lvl_abs.h:70
The symbol is the name and ID of an object. Every object has an unique symbol.
Definition: symbol.h:16
const ExprPtr input(const size_t &i) const
Access the i-th input variable.
Definition: instr_lvl_abs.h:100
const ExprPtr NewMemInput(const std::string &name, const int &addr_width, const int &data_width)
Create one Memory variable and register as an input.
friend std::ostream & operator<<(std::ostream &out, InstrLvlAbs &ila)
Overload output stream for object.
static InstrLvlAbsPtr New(const std::string &name, const InstrLvlAbsPtr &parent=nullptr)
Create a new ILA (InstrLvlAbs) with the name. Used for hiding implementation specific type details...
const ExprPtr NewBoolFreeVar(const std::string &name)
Create one free Boolean variable.
void SetValid(const ExprPtr &valid_expr)
Set the valid function, and simplify (if needed) by the simplifier.
void AddInput(const ExprPtr &input_var)
Add one input variable to the ILA, and register to the simplifier.
~InstrLvlAbs()
Default destructor.
size_t init_num() const
Return the number of initial condition.
Definition: instr_lvl_abs.h:92
const ExprPtr NewMemFreeVar(const std::string &name, const int &addr_width, const int &data_width)
Create one free Memory variable.
const ExprPtr NewBoolState(const std::string &name)
Create one Boolean variable and register as a state.
const InstrLvlAbsPtr NewChild(const std::string &name)
Create and register one child-ILA.
const ExprMngrPtr expr_mngr() const
Return the ast simplifier.
Definition: instr_lvl_abs.h:74
const ExprPtr NewBvFreeVar(const std::string &name, const int &bit_width)
Create one free bit-vector variable.
const ExprPtr find_state(const Symbol &name) const
Return the named state variable; return NULL if not registered.
const Symbol & name() const
Get the symbol (name).