ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
ilang++.h
Go to the documentation of this file.
1 
4 #ifndef ILANG_ILANG_CPP_H__
5 #define ILANG_ILANG_CPP_H__
6 
7 #include <cstdint>
8 #include <map>
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 #include <z3++.h>
14 #ifdef SMTSWITCH_INTERFACE
15 #include <smt-switch/smt.h>
16 #endif // SMTSWITCH_INTERFACE
17 
18 #include <ilang/config.h>
19 
22 namespace ilang {
23 
25 typedef uint64_t NumericType;
26 
27 /******************************************************************************/
28 // Logging system.
29 /******************************************************************************/
36 void LogLevel(const int& lvl);
40 void LogPath(const std::string& path);
43 void LogToErr(bool to_err);
45 void EnableDebug(const std::string& tag);
47 void DisableDebug(const std::string& tag);
48 
49 /******************************************************************************/
50 // ILA Construction.
51 /******************************************************************************/
52 // implementation-specific structure
53 class Sort;
54 class Func;
55 class Expr;
56 class Instr;
57 class InstrLvlAbs;
58 class Unroller;
59 
60 // forward declaration
61 class Ila;
62 
64 class SortRef {
65 private:
66  typedef std::shared_ptr<Sort> SortPtr;
67  // ------------------------- MEMBERS -------------------------------------- //
69  SortPtr ptr_ = nullptr;
70 
71 public:
72  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
74  SortRef(SortPtr ptr);
76  ~SortRef();
77 
78  // ------------------------- HELPERS -------------------------------------- //
80  static SortRef BOOL();
82  static SortRef BV(const int& bit_w);
84  static SortRef MEM(const int& addr_w, const int& data_w);
85 
86  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
88  inline SortPtr get() const { return ptr_; }
89 }; // class SortRef
90 
92 class ExprRef {
93 private:
94  typedef std::shared_ptr<Expr> ExprPtr;
95  // ------------------------- MEMBERS -------------------------------------- //
97  ExprPtr ptr_ = nullptr;
98 
99 public:
100  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
102  ExprRef(ExprPtr ptr);
104  ~ExprRef();
105 
106  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
108  inline ExprPtr get() const { return ptr_; }
110  int bit_width() const;
112  int addr_width() const;
114  int data_width() const;
116  std::string name() const;
117 
118  // ------------------------- METHODS -------------------------------------- //
119  /****************************************************************************/
120  // Memory-related operations
121  /****************************************************************************/
123  ExprRef Load(const ExprRef& addr) const;
125  ExprRef Store(const ExprRef& addr, const ExprRef& data) const;
127  ExprRef Load(const NumericType& addr) const;
129  ExprRef Store(const NumericType& addr, const NumericType& data) const;
130 
131  /****************************************************************************/
132  // Bit manipulation for bit-vectors.
133  /****************************************************************************/
135  ExprRef Append(const ExprRef& lsbv) const;
137  ExprRef operator()(const int& hi, const int& lo) const;
139  ExprRef operator()(const int& idx) const;
141  ExprRef ZExt(const int& length) const;
143  ExprRef SExt(const int& length) const;
144 
145  /****************************************************************************/
146  // Others
147  /****************************************************************************/
149  void ReplaceArg(const int& i, const ExprRef& new_arg);
151  void ReplaceArg(const ExprRef& org_arg, const ExprRef& new_arg);
152 
154  bool SetEntryNum(const int& num);
156  int GetEntryNum();
157 
158 }; // class ExprRef
159 
160 /******************************************************************************/
161 // Unary operation
162 /******************************************************************************/
164 ExprRef operator-(const ExprRef& a);
166 ExprRef operator!(const ExprRef& a);
168 ExprRef operator~(const ExprRef& a);
169 
170 /******************************************************************************/
171 // Binary operation
172 /******************************************************************************/
174 ExprRef operator&(const ExprRef& a, const ExprRef& b);
176 ExprRef operator|(const ExprRef& a, const ExprRef& b);
178 ExprRef operator^(const ExprRef& a, const ExprRef& b);
180 ExprRef operator<<(const ExprRef& a, const ExprRef& b);
182 ExprRef operator>>(const ExprRef& a, const ExprRef& b);
184 ExprRef Lshr(const ExprRef& a, const ExprRef& b);
186 ExprRef operator+(const ExprRef& a, const ExprRef& b);
188 ExprRef operator-(const ExprRef& a, const ExprRef& b);
190 ExprRef operator*(const ExprRef& a, const ExprRef& b);
192 ExprRef operator/(const ExprRef& a, const ExprRef& b);
193 
195 ExprRef operator&(const ExprRef& a, const bool& b);
197 ExprRef operator|(const ExprRef& a, const bool& b);
199 ExprRef operator^(const ExprRef& a, const bool& b);
201 ExprRef operator<<(const ExprRef& a, const int& b);
203 ExprRef operator>>(const ExprRef& a, const int& b);
205 ExprRef Lshr(const ExprRef& a, const int& b);
207 ExprRef operator+(const ExprRef& a, const NumericType& b);
209 ExprRef operator-(const ExprRef& a, const NumericType& b);
211 ExprRef operator*(const ExprRef& a, const NumericType& b);
213 ExprRef SRem(const ExprRef& a, const ExprRef& b);
215 ExprRef URem(const ExprRef& a, const ExprRef& b);
217 ExprRef SMod(const ExprRef& a, const ExprRef& b);
218 
219 /******************************************************************************/
220 // Binary comparison
221 /******************************************************************************/
224 void SetUnsignedComparison(bool sign);
226 ExprRef operator==(const ExprRef& a, const ExprRef& b);
228 ExprRef operator!=(const ExprRef& a, const ExprRef& b);
230 ExprRef operator<(const ExprRef& a, const ExprRef& b);
232 ExprRef operator>(const ExprRef& a, const ExprRef& b);
234 ExprRef operator<=(const ExprRef& a, const ExprRef& b);
236 ExprRef operator>=(const ExprRef& a, const ExprRef& b);
238 ExprRef Ult(const ExprRef& a, const ExprRef& b);
240 ExprRef Ugt(const ExprRef& a, const ExprRef& b);
242 ExprRef Ule(const ExprRef& a, const ExprRef& b);
244 ExprRef Uge(const ExprRef& a, const ExprRef& b);
246 ExprRef Slt(const ExprRef& a, const ExprRef& b);
248 ExprRef Sgt(const ExprRef& a, const ExprRef& b);
250 ExprRef Sle(const ExprRef& a, const ExprRef& b);
252 ExprRef Sge(const ExprRef& a, const ExprRef& b);
253 
254 // helper functions with constants
255 #if 0
256 ExprRef operator==(const ExprRef& a, const bool& b);
258 #endif
259 ExprRef operator==(const ExprRef& a, const NumericType& b);
262 ExprRef operator!=(const ExprRef& a, const NumericType& b);
264 ExprRef operator<(const ExprRef& a, const NumericType& b);
266 ExprRef operator>(const ExprRef& a, const NumericType& b);
268 ExprRef operator<=(const ExprRef& a, const NumericType& b);
270 ExprRef operator>=(const ExprRef& a, const NumericType& b);
272 ExprRef Ult(const ExprRef& a, const NumericType& b);
274 ExprRef Ugt(const ExprRef& a, const NumericType& b);
276 ExprRef Ule(const ExprRef& a, const NumericType& b);
278 ExprRef Uge(const ExprRef& a, const NumericType& b);
280 ExprRef Slt(const ExprRef& a, const NumericType& b);
282 ExprRef Sgt(const ExprRef& a, const NumericType& b);
284 ExprRef Sle(const ExprRef& a, const NumericType& b);
286 ExprRef Sge(const ExprRef& a, const NumericType& b);
287 
288 /******************************************************************************/
289 // Memory-related operations
290 /******************************************************************************/
292 ExprRef Load(const ExprRef& mem, const ExprRef& addr);
294 ExprRef Store(const ExprRef& mem, const ExprRef& addr, const ExprRef& data);
296 ExprRef Load(const ExprRef& mem, const NumericType& addr);
298 ExprRef Store(const ExprRef& mem, const NumericType& addr,
299  const NumericType& data);
300 
301 /******************************************************************************/
302 // Bit manipulation for bit-vectors.
303 /******************************************************************************/
307 ExprRef Concat(const ExprRef& msbv, const ExprRef& lsbv);
312 ExprRef Extract(const ExprRef& bv, const int& hi, const int& lo);
316 ExprRef SelectBit(const ExprRef& bv, const int& idx);
320 ExprRef ZExt(const ExprRef& bv, const int& length);
324 ExprRef SExt(const ExprRef& bv, const int& length);
328 ExprRef LRotate(const ExprRef& bv, const int& immediate);
332 ExprRef RRotate(const ExprRef& bv, const int& immediate);
333 
334 /******************************************************************************/
335 // Others
336 /******************************************************************************/
340 ExprRef Imply(const ExprRef& ante, const ExprRef& cons);
341 
346 ExprRef Ite(const ExprRef& cond, const ExprRef& t, const ExprRef& f);
347 
348 /******************************************************************************/
349 // Constant
350 /******************************************************************************/
353 ExprRef BoolConst(bool bool_val);
354 
358 ExprRef BvConst(const NumericType& bv_val, const int& bit_width);
359 
365 ExprRef MemConst(const NumericType& def_val,
366  const std::map<NumericType, NumericType>& vals,
367  const int& addr_width, const int& data_width);
368 
369 /******************************************************************************/
370 // Non-AST-construction
371 /******************************************************************************/
373 bool TopEqual(const ExprRef& a, const ExprRef& b);
374 
376 class FuncRef {
377 private:
378  typedef std::shared_ptr<Func> FuncPtr;
379  // ------------------------- MEMBERS -------------------------------------- //
381  FuncPtr ptr_ = nullptr;
382 
383 public:
384  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
386  FuncRef(const std::string& name, const SortRef& range);
388  FuncRef(const std::string& name, const SortRef& range, const SortRef& d0);
390  FuncRef(const std::string& name, const SortRef& range, const SortRef& d0,
391  const SortRef& d1);
393  FuncRef(const std::string& name, const SortRef& range,
394  const std::vector<SortRef>& dvec);
396  ~FuncRef();
397 
398  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
400  std::string name() const;
402  inline FuncPtr get() const { return ptr_; }
403 
404  // ------------------------- METHODS -------------------------------------- //
406  ExprRef operator()() const;
408  ExprRef operator()(const ExprRef& arg0) const;
410  ExprRef operator()(const ExprRef& arg0, const ExprRef& arg1) const;
412  ExprRef operator()(const std::vector<ExprRef>& argvec) const;
413 
414 }; // class FuncRef
415 
417 class InstrRef {
418 private:
419  typedef std::shared_ptr<Instr> InstrPtr;
420  // ------------------------- MEMBERS -------------------------------------- //
422  InstrPtr ptr_ = nullptr;
423 
424 public:
425  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
427  InstrRef(InstrPtr ptr);
429  ~InstrRef();
430 
431  // ------------------------- METHODS -------------------------------------- //
434  void SetDecode(const ExprRef& decode);
435 
439  void SetUpdate(const ExprRef& state, const ExprRef& update);
440 
443  void SetProgram(const Ila& prog);
444 
447  ExprRef GetDecode() const;
448 
452  ExprRef GetUpdate(const ExprRef& state) const;
453 
454  // ------------------------- GENERATORS --------------------------------- //
457  void ExportToVerilog(std::ostream& fout) const;
458 
461  void ExportToVerilogWithChild(std::ostream& fout) const;
462 
463  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
465  inline InstrPtr get() const { return ptr_; }
466 
468  std::string name() const;
469 
470 }; // class InstrRef
471 
473 class Ila {
474 private:
475  typedef std::shared_ptr<InstrLvlAbs> IlaPtr;
476  // ------------------------- MEMBERS -------------------------------------- //
478  IlaPtr ptr_ = nullptr;
479 
480 public:
481  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
483  Ila(const std::string& name);
485  Ila(IlaPtr ptr);
487  ~Ila();
488 
489  // ------------------------- METHODS -------------------------------------- //
492  ExprRef NewBoolState(const std::string& name);
496  ExprRef NewBvState(const std::string& name, const int& bit_width);
501  ExprRef NewMemState(const std::string& name, const int& addr_width,
502  const int& data_width);
503 
506  ExprRef NewBoolInput(const std::string& name);
510  ExprRef NewBvInput(const std::string& name, const int& bit_width);
511 
514  void AddInit(const ExprRef& init);
515 
518  void SetFetch(const ExprRef& fetch);
519 
522  void SetValid(const ExprRef& valid);
523 
526  InstrRef NewInstr(const std::string& name);
527 
530  Ila NewChild(const std::string& name);
531 
532  // ------------------------- ACCESSORS/MUTATORS --------------------------- //
534  size_t input_num() const;
536  size_t state_num() const;
538  size_t instr_num() const;
540  size_t child_num() const;
542  size_t init_num() const;
543 
545  std::string name() const;
547  ExprRef fetch() const;
549  ExprRef valid() const;
550 
552  ExprRef input(const size_t& i) const;
554  ExprRef state(const size_t& i) const;
556  InstrRef instr(const size_t& i) const;
558  Ila child(const size_t& i) const;
560  ExprRef init(const size_t& i) const;
561 
563  ExprRef input(const std::string& name) const;
565  ExprRef state(const std::string& name) const;
567  InstrRef instr(const std::string& name) const;
569  Ila child(const std::string& name) const;
570 
572  inline IlaPtr get() const { return ptr_; }
573 
574  // ------------------------- UTILITIES ------------------------------------ //
577  void ExportToVerilog(std::ostream& fout) const;
578 
581  void FlattenHierarchy();
582 
584  typedef enum PassID {
585  SANITY_CHECK_AND_FIX = 0,
586  SIMPLIFY_SYNTACTIC,
587  SIMPLIFY_SEMANTIC,
588  REWRITE_CONDITIONAL_STORE,
589  REWRITE_LOAD_FROM_STORE
590  } PassID;
591 
594  bool ExecutePass(const std::vector<PassID>& passes) const;
595 
596 }; // class Ila
597 
598 /******************************************************************************/
599 // Output stream helper
600 /******************************************************************************/
602 std::ostream& operator<<(std::ostream& out, const ExprRef& expr);
604 std::ostream& operator<<(std::ostream& out, const InstrRef& instr);
606 std::ostream& operator<<(std::ostream& out, const Ila& ila);
607 
608 /******************************************************************************/
609 // Converters
610 /******************************************************************************/
614 bool ExportIlaPortable(const Ila& ila, const std::string& file_name);
615 
618 Ila ImportIlaPortable(const std::string& file_name);
619 
620 #ifdef SYNTH_INTERFACE
621 Ila ImportSynthAbstraction(const std::string& file_name,
625  const std::string& ila_name);
626 
632 void ImportChildSynthAbstraction(const std::string& file_name, Ila& parent,
633  const std::string& ila_name);
634 #endif // SYNTH_INTERFACE
635 
640 void ExportSysCSim(const Ila& ila, const std::string& dir_path,
641  bool optimize = false);
642 
643 /******************************************************************************/
644 // Verification.
645 /******************************************************************************/
648 public:
649  // ------------------------- CONSTRUCTOR/DESTRUCTOR ----------------------- //
651  IlaZ3Unroller(z3::context& ctx, const std::string& suff = "");
653  ~IlaZ3Unroller();
654 
655  // ------------------------- METHODS -------------------------------------- //
657  inline void AddGlobPred(const ExprRef& p) { glob_pred_.push_back(p); }
659  inline void AddInitPred(const ExprRef& p) { init_pred_.push_back(p); }
661  inline void AddStepPred(const int& k, const ExprRef& p) {
662  step_pred_.push_back({k, p});
663  }
665  inline void ClearGlobPred() { glob_pred_.clear(); }
667  inline void ClearInitPred() { init_pred_.clear(); }
669  inline void ClearStepPred() { step_pred_.clear(); }
670 
675  z3::expr UnrollMonoConn(const Ila& top, const int& k, const int& init = 0);
676 
681  z3::expr UnrollMonoFree(const Ila& top, const int& k, const int& init = 0);
682 
686  z3::expr UnrollPathConn(const std::vector<InstrRef>& path,
687  const int& init = 0);
688 
692  z3::expr UnrollPathSubs(const std::vector<InstrRef>& path,
693  const int& init = 0);
694 
698  z3::expr UnrollPathFree(const std::vector<InstrRef>& path,
699  const int& init = 0);
700 
701  // ------------------------- HELPERS -------------------------------------- //
703  z3::expr CurrState(const ExprRef& v, const int& t);
705  z3::expr NextState(const ExprRef& v, const int& t);
707  z3::expr GetZ3Expr(const ExprRef& v, const int& t = 0);
709  z3::expr Equal(const ExprRef& va, const int& ta, const ExprRef& vb,
710  const int& tb);
712  z3::func_decl GetZ3FuncDecl(const FuncRef& f) const;
713 
714 private:
715  // ------------------------- MEMBERS -------------------------------------- //
717  z3::context& ctx_;
718 
720  std::vector<ExprRef> glob_pred_;
722  std::vector<ExprRef> init_pred_;
724  std::vector<std::pair<int, ExprRef>> step_pred_;
726  std::string extra_suff_;
727 
729  std::shared_ptr<Unroller> univ_ = nullptr;
730 
731  // ------------------------- HELPERS -------------------------------------- //
733  template <class T> void InitializeUnroller(T unroller) {
734  for (auto it = glob_pred_.begin(); it != glob_pred_.end(); it++) {
735  unroller->AddGlobPred(it->get());
736  }
737  for (auto it = init_pred_.begin(); it != init_pred_.end(); it++) {
738  unroller->AddInitPred(it->get());
739  }
740  for (auto it = step_pred_.begin(); it != step_pred_.end(); it++) {
741  unroller->AddStepPred(it->second.get(), it->first);
742  }
743  // unroller->SetExtraSuffix(extra_suff_);
744  }
745 
746 }; // class IlaZ3Unroller
747 
748 #ifdef SMTSWITCH_INTERFACE
749 
754 smt::Term ResetAndGetSmtTerm(smt::SmtSolver& solver, const ExprRef& expr,
755  const std::string& suffix = "");
756 
757 #endif // SMTSWITCH_INTERFACE
758 
759 } // namespace ilang
760 
761 #endif // ILANG_ILANG_CPP_H__
ExprRef operator<<(const ExprRef &a, const ExprRef &b)
Left shift for bit-vectors.
ExprRef BvConst(const NumericType &bv_val, const int &bit_width)
Return a bit-vector constant.
ExprRef init(const size_t &i) const
Access the i-th initial condition.
z3::expr UnrollMonoFree(const Ila &top, const int &k, const int &init=0)
Unroll the ILA monolithically with each step freely defined.
bool TopEqual(const ExprRef &a, const ExprRef &b)
Topologically equivalent.
z3::expr UnrollPathFree(const std::vector< InstrRef > &path, const int &init=0)
Unroll a path with each step freely defined.
Base class for unrolling ILA execution in different settings.
Definition: u_unroller.h:19
ExprRef NewBvInput(const std::string &name, const int &bit_width)
Declare an input of bit-vector type.
static SortRef BV(const int &bit_w)
Return a bit-vector Sort of the given bit-width.
The wrapper of Func (uninterpreted function).
Definition: ilang++.h:376
ExprRef operator&(const ExprRef &a, const ExprRef &b)
Logical AND (bit-wise for bit-vectors).
FuncRef(const std::string &name, const SortRef &range)
Constructor with zero input argument (domain).
ExprRef SRem(const ExprRef &a, const ExprRef &b)
Arithmetic signed remainder.
SortRef(SortPtr ptr)
Constructor with the pointer of the actual data.
int data_width() const
Return the data bit-width if is memory; return -1 otherwise.
bool ExportIlaPortable(const Ila &ila, const std::string &file_name)
Export the ILA portable to file.
ExprRef LRotate(const ExprRef &bv, const int &immediate)
Left-rotate the bit-vector with immediate number of times.
void ExportSysCSim(const Ila &ila, const std::string &dir_path, bool optimize=false)
Generate the SystemC simulator.
ExprRef NewBoolState(const std::string &name)
Declare a state variable of Boolean type.
The wrapper of Sort (type for different AST nodes).
Definition: ilang++.h:64
void LogPath(const std::string &path)
Set the path for log file. If specified, logfiles are written into this directory instead of the defa...
void ExportToVerilog(std::ostream &fout) const
Export instruction without child-program as Verilog.
~InstrRef()
Default destructor.
void EnableDebug(const std::string &tag)
Add a debug tag.
ExprRef Ule(const ExprRef &a, const ExprRef &b)
Unsigned less than or equal to (bit-vectors only).
The class for expression, which is the basic type for variables, constraints, state update expression...
Definition: expr.h:25
void AddInit(const ExprRef &init)
Add one initial constraint.
void SetProgram(const Ila &prog)
Set the child-program of the instruction.
ExprRef operator<=(const ExprRef &a, const ExprRef &b)
Signed/Unsigned less than or equal to (bit-vectors only).
ExprRef Slt(const ExprRef &a, const ExprRef &b)
Signed less than (bit-vectors only).
void AddStepPred(const int &k, const ExprRef &p)
Add a predicate that should be asserted at the k-th step.
Definition: ilang++.h:661
ExprRef URem(const ExprRef &a, const ExprRef &b)
Arithmetic unsigned remainder.
void ClearStepPred()
Clear the step-specific predicates.
Definition: ilang++.h:669
IlaZ3Unroller(z3::context &ctx, const std::string &suff="")
Default constructor.
The class for the Instruction. An Instr object contains:
Definition: instr.h:24
int addr_width() const
Return the address bit-width if is memory; return -1 otherwise.
ExprRef Store(const ExprRef &addr, const ExprRef &data) const
Store to memory.
size_t init_num() const
Return the number of initial condition.
ExprRef Lshr(const ExprRef &a, const ExprRef &b)
Logical right shift for bit-vectors.
ExprRef operator^(const ExprRef &a, const ExprRef &b)
Logical XOR (bit-wise for bit-vectors).
ExprRef operator/(const ExprRef &a, const ExprRef &b)
Unsigned division for bit-vectors.
ExprRef Uge(const ExprRef &a, const ExprRef &b)
Unsigned greater than or equal to (bit-vectors only).
ExprRef Store(const ExprRef &mem, const ExprRef &addr, const ExprRef &data)
Store to memory.
ExprRef operator>(const ExprRef &a, const ExprRef &b)
Signed/Unsigned greater than (bit-vectors only).
void SetFetch(const ExprRef &fetch)
Set the fetch function of the ILA.
ExprRef ZExt(const ExprRef &bv, const int &length)
Zero-extend the bit-vector to the specified length.
ExprRef operator|(const ExprRef &a, const ExprRef &b)
Logical OR (bit-wise for bit-vectors).
ExprRef SMod(const ExprRef &a, const ExprRef &b)
Arithmetic signed modular.
void SetDecode(const ExprRef &decode)
Set the decode function of the instruction.
ExprRef Sle(const ExprRef &a, const ExprRef &b)
Signed less than or equal to (bit-vectors only).
ExprRef valid() const
Return the valid function.
ExprRef Sge(const ExprRef &a, const ExprRef &b)
Signed greater than or equal to (bit-vectors only).
z3::expr UnrollMonoConn(const Ila &top, const int &k, const int &init=0)
Unroll the ILA monolithically with each step connected.
The wrapper of generating z3::expr for verification.
Definition: ilang++.h:647
z3::expr UnrollPathConn(const std::vector< InstrRef > &path, const int &init=0)
Unroll a path with each step connected.
~FuncRef()
Default destructor.
InstrRef NewInstr(const std::string &name)
Declare an instruction.
ExprRef Ugt(const ExprRef &a, const ExprRef &b)
Unsigned greater than (bit-vectors only).
void SetValid(const ExprRef &valid)
Set the valid function of the ILA.
ExprRef operator==(const ExprRef &a, const ExprRef &b)
Equal.
ExprRef operator*(const ExprRef &a, const ExprRef &b)
Unsigned multiply for bit-vectors.
size_t child_num() const
Return the number of child-ILAs.
Ila ImportIlaPortable(const std::string &file_name)
Import the ILA portable from file.
ExprRef operator()(const int &hi, const int &lo) const
Extract bit-field in the bit-vector.
void LogLevel(const int &lvl)
Set the minimun log level. Log messages at or above this level will be logged. (Default: 0) ...
void LogToErr(bool to_err)
Pipe log to stderr. Log messages to stderr instead of logfiles, if set to 1.
The wrapper of InstrLvlAbs (ILA).
Definition: ilang++.h:473
ExprRef Load(const ExprRef &addr) const
Load from memory.
~ExprRef()
Default destructor.
InstrRef(InstrPtr ptr)
Constructor with the pointer of the actual data.
ExprRef operator-(const ExprRef &a)
Arithmetic negate for bit-vectors.
PassID
Supported pass ID.
Definition: ilang++.h:584
std::string name() const
Return the function name as std::string.
std::string name() const
Return the instruction name as std::string.
size_t state_num() const
Return the number of state variables.
bool SetEntryNum(const int &num)
Set the entry number of the memory (size regardless of bit-width).
ExprRef Load(const ExprRef &mem, const ExprRef &addr)
Load from memory.
void ClearInitPred()
Clear the initial predicates.
Definition: ilang++.h:667
The class of Instruction-Level Abstraction (ILA). An ILA contains:
Definition: instr_lvl_abs.h:35
int bit_width() const
Return the bit-width if is bit-vector; return -1 otherwise.
ExprRef operator()() const
Apply the function with no argument.
ExprRef Imply(const ExprRef &ante, const ExprRef &cons)
Logical imply for Booleans.
ExprRef Extract(const ExprRef &bv, const int &hi, const int &lo)
Extract bit-field in the bit-vector.
void DisableDebug(const std::string &tag)
Remove a debug tag.
ExprRef(ExprPtr ptr)
Constructor with the pointer of the actual data.
static SortRef MEM(const int &addr_w, const int &data_w)
Return a memory (array) Sort of the given address/data bit-width.
void AddInitPred(const ExprRef &p)
Add a predicate that should be asserted in the initial condition.
Definition: ilang++.h:659
The wrapper of Expr (e.g. state var, var relation, constant, etc).
Definition: ilang++.h:92
uint64_t NumericType
Data type for numerics. NOTE: SHOULD BE SYNCED WITH BvValType!!
Definition: ilang++.h:25
std::string name() const
Return the Ila name.
The wrapper of Instr (instruction).
Definition: ilang++.h:417
void ExportToVerilog(std::ostream &fout) const
Export an ILA as Verilog.
size_t instr_num() const
Return the number of instructions.
int GetEntryNum()
GEt the entry number of the memory (size regardless of bit-width).
z3::expr NextState(const ExprRef &v, const int &t)
Return the z3::expr representing the next state at the time.
ExprRef GetDecode() const
Get the decode function of the instruction.
z3::expr Equal(const ExprRef &va, const int &ta, const ExprRef &vb, const int &tb)
Return the z3::expr representing a and b are equal at their time.
ExprRef NewMemState(const std::string &name, const int &addr_width, const int &data_width)
Declare a state variable of memory (array) type.
ExprRef operator!(const ExprRef &a)
Logical not for Booleans.
size_t input_num() const
Return the number of input variables.
ExprRef BoolConst(bool bool_val)
Return a Boolean constant.
ExprRef Ite(const ExprRef &cond, const ExprRef &t, const ExprRef &f)
If-then-else on the Boolean condition.
ExprRef MemConst(const NumericType &def_val, const std::map< NumericType, NumericType > &vals, const int &addr_width, const int &data_width)
Return a memory constant.
~IlaZ3Unroller()
Default virtual destructor.
~Ila()
Default destructor.
ExprRef Append(const ExprRef &lsbv) const
Append another bit-vector to the less significant side.
void FlattenHierarchy()
Flatten the hierarchy by lifting child-instructions as the top-level parent instructions.
ExprRef Concat(const ExprRef &msbv, const ExprRef &lsbv)
Concatenate two bit-vectors.
ExprRef SelectBit(const ExprRef &bv, const int &idx)
Extract single bit in the bit-vector.
Ila child(const size_t &i) const
Access the i-th child-ILA.
ExprRef operator!=(const ExprRef &a, const ExprRef &b)
Not equal.
ExprRef fetch() const
Return the fetch function.
The class for sort (type for expr, and the range/domain of functions).
Definition: sort.h:22
bool ExecutePass(const std::vector< PassID > &passes) const
Execute the specified passes in order.
z3::expr UnrollPathSubs(const std::vector< InstrRef > &path, const int &init=0)
Unroll a path with each step connected with rewriting.
ExprRef input(const size_t &i) const
Access the i-th input variable.
ExprRef RRotate(const ExprRef &bv, const int &immediate)
Right-rotate the bit-vector with immediate number of times.
ExprRef SExt(const ExprRef &bv, const int &length)
Sign-extend the bit-vector to the specified length.
ExprRef state(const size_t &i) const
Access the i-th state variable.
void SetUnsignedComparison(bool sign)
ExprRef NewBoolInput(const std::string &name)
Declare an input of Boolean type.
void ClearGlobPred()
Clear the global predicates.
Definition: ilang++.h:665
ExprRef SExt(const int &length) const
Sign-extend the bit-vector to the specified length.
std::string name() const
Return the expression name as std::string.
InstrRef instr(const size_t &i) const
Access the i-th instruction.
z3::expr GetZ3Expr(const ExprRef &v, const int &t=0)
Return the z3::expr representing the current-based Expr at the time.
~SortRef()
Default destructor.
void ExportToVerilogWithChild(std::ostream &fout) const
Export instruction with the child-program as Verilog.
z3::func_decl GetZ3FuncDecl(const FuncRef &f) const
Return the z3::func_decl representing f.
ExprRef operator~(const ExprRef &a)
Bit-wise complement for bit-vectors.
static SortRef BOOL()
Return a Boolean Sort.
ExprRef ZExt(const int &length) const
Zero-extend the bit-vector to the specified length.
ExprRef operator>=(const ExprRef &a, const ExprRef &b)
Signed/Unsigned greater than or equal to (bit-vectors only).
ExprRef operator+(const ExprRef &a, const ExprRef &b)
Unsigned addition for bit-vectors.
ExprRef GetUpdate(const ExprRef &state) const
Set the update function of the given state variable.
void AddGlobPred(const ExprRef &p)
Add a predicate that should be asserted globally when unrolled.
Definition: ilang++.h:657
ExprRef Ult(const ExprRef &a, const ExprRef &b)
Unsigned less than (bit-vectors only).
Ila(const std::string &name)
Constructor with the specified name.
ExprRef Sgt(const ExprRef &a, const ExprRef &b)
Signed greater than (bit-vectors only).
z3::expr CurrState(const ExprRef &v, const int &t)
Return the z3::expr representing the current state at the time.
void ReplaceArg(const int &i, const ExprRef &new_arg)
Replace the i-th argument with the new node.
ExprRef NewBvState(const std::string &name, const int &bit_width)
Declare a state variable of bit-vector type.
void SetUpdate(const ExprRef &state, const ExprRef &update)
Set the update function of the given state variable.
ExprRef operator<(const ExprRef &a, const ExprRef &b)
Signed/Unsigned less than (bit-vectors only).
The class for uninterpreted function.
Definition: func.h:23
Ila NewChild(const std::string &name)
Declare a child-ILA.
ExprRef operator>>(const ExprRef &a, const ExprRef &b)
Arithmetic right shift for bit-vectors.