ilasynth  1.0
ILASynth: Template-based ILA Synthesis Engine
abstraction.hpp
Go to the documentation of this file.
1 #ifndef __ABSTRACTION_HPP_DEFINED__
2 #define __ABSTRACTION_HPP_DEFINED__
3 
4 #include <boost/python.hpp>
5 #include <map>
6 #include <set>
7 #include <string>
8 #include <vector>
9 
12 #include <ilasynth/ast.hpp>
13 #include <ilasynth/boogie.hpp>
14 #include <ilasynth/common.hpp>
15 #include <ilasynth/cppsimgen.hpp>
16 #include <ilasynth/genCBMC.hpp>
17 #include <ilasynth/horn.hpp>
18 #include <ilasynth/imexport.hpp>
19 #include <ilasynth/smt.hpp>
20 
21 namespace ilasynth {
22 class Abstraction;
23 class AbstractionWrapper;
24 class MicroEQCheck;
25 typedef boost::shared_ptr<Abstraction> abstraction_ptr_t;
26 
28  virtual void useAssump(const nptr_t& a) = 0;
29 };
30 
31 class Abstraction {
32 public:
33  // type of the state element/input.
34  enum state_t { INP, REG, BIT, MEM, FUN };
35 
36  struct uabstraction_t {
37  // when is the abstraction valid.
39  // the abstraction.
41  };
42 
43  // list of microabstractions.
44  typedef std::map<std::string, uabstraction_t> uabs_map_t;
45 
46 private:
47  static int objCnt;
49 
50 protected:
51  // parent abstraction.
53 
54  // name of this abstraction.
55  const std::string name;
56 
57  // list of known names.
58  std::map<std::string, state_t> names;
59 
60  // list of inputs
62  // list of registers.
64  // list of bits.
66  // list of memories.
68  // list of functions.
70 
71  // fetch
74 
75  // decode
77 
78  // assumptions.
80 
81  // list of sub-abstractions.
83 
84  void initMap(nmap_t& from_m, nmap_t& to_m);
85 
86  void extractModelValues(Z3ExprAdapter& c, z3::model& m, py::dict& result);
87 
88  NodeRef* getVar(const nmap_t& m, const std::string& name);
89  void addVar(state_t st, nmap_t& m, nptr_t& n);
90 
91 public:
92  int paramSyn;
95 
96  // Constructor.
97  Abstraction(const std::string& name);
98 
99  // Constructor for a micro-abstraction
100  Abstraction(Abstraction* parent, const std::string& name);
101 
102  // Destructor.
103  ~Abstraction();
104 
105  // Get abstraction name
106  const std::string& getName() const { return name; }
107  // Get a new ID.
108  static int getObjId();
109 
110  // Create a bitvector input.
111  NodeRef* addInp(const std::string& name, int width);
112 
113  // Create a boolean variable.
114  NodeRef* addBit(const std::string& name);
115 
116  // Create a bitvector variable.
117  NodeRef* addReg(const std::string& name, int width);
118 
119  // Create a memory.
120  NodeRef* addMem(const std::string& name, int addrW, int dataW);
121 
122  // Create a function.
123  NodeRef* addFun(const std::string& name, int retW, const py::list& l);
124 
125  // Get an existing input port
126  NodeRef* getInp(const std::string& name);
127  // Get an existing boolean.
128  NodeRef* getBit(const std::string& name);
129  // Get an existing bitvector.
130  NodeRef* getReg(const std::string& name);
131  // Get an existing memory.
132  NodeRef* getMem(const std::string& name);
133  // Get an existing function.
134  NodeRef* getFun(const std::string& name);
135  // Get and existing stage variable.
136  NodeRef* getStage(const std::string& name);
137 
138  // add a var if it does not exist.
139  void addVar(nptr_t& nref);
140 
141  // Set the init value for this var.
142  void setInit(const std::string& name, NodeRef* n);
143  // Get the initial value for this var.
144  NodeRef* getInit(const std::string& name) const;
145  // Set a predicate on the initial value.
146  void setIpred(const std::string& name, NodeRef* n);
147  // Get the predicate on the initial value.
148  NodeRef* getIpred(const std::string& name) const;
149 
150  // Set the next template for this var.
151  void setNext(const std::string& name, NodeRef* n);
152  // Get the next template.
153  NodeRef* getNext(const std::string& name) const;
154  // Get the next template for the i-th instruction.
155  NodeRef* getNextI(const std::string& name, int i) const;
156 
157  // Create a uabstraction.
158  AbstractionWrapper* addUAbs(const std::string& name, NodeRef* valid);
159  // Get an existing uabstraction.
160  AbstractionWrapper* getUAbs(const std::string& name);
161  // Connect a microinstruction.
162  void connectUInst(const std::string& name, const abstraction_ptr_t& uabs);
163 
164  // Create a bitvector constant with a long integer.
165  static NodeRef* bvConstLong(py::long_ l, int width);
166  // Create a bitvector constant with an integer.
167  static NodeRef* bvConstInt(unsigned int l, int width);
168 
169  // Create a boolean constant (from a bool).
170  static NodeRef* boolConstB(bool b);
171  // Create a boolean constant (from an integer: nonzero = true).
172  static NodeRef* boolConstI(int b);
173  // Create a boolean constant (from an python long).
174  static NodeRef* boolConstL(py::long_ b);
175 
176  // Create a memory constant (from a memvalues object).
177  static NodeRef* memConst(const MemValues& mv);
178 
179  // return the current fetch expression.
180  NodeRef* getFetchExpr() const;
181  // set the fetch expression.
182  void setFetchExpr(NodeRef* expr);
183  // return the fetch valid expression.
184  NodeRef* getFetchValid() const;
185 
186  nptr_t getFetchValidNode() const;
187 
188  // set the fetch valid expresssion.
189  void setFetchValid(NodeRef* expr);
190  // set decode.
191  void setDecodeExpressions(const py::list& l);
192  // get decode expressions.
193  py::list getDecodeExpressions() const;
194  const nptr_vec_t& getDecodeNodes() const;
195 
196  // add an assumption.
197  void addAssumption(NodeRef* expr);
198  // get all assumptions.
199  py::list getAllAssumptions() const;
200 
201  // the real synthesize function.
202  void synthesizeAll(PyObject* fun);
203 
204  // synthesize only one register.
205  void synthesizeReg(const std::string& name, PyObject* fun);
206 
207  // the synthesis function.
208  NodeRef* synthesizeElement(const std::string& name, NodeRef* expr,
209  PyObject* fun);
210 
211  // the export function that export only one expression.
212  void exportOneToFile(NodeRef* node, const std::string& fileName) const;
213  // the export function that export a list of expressions.
214  void exportListToFile(const py::list& l, const std::string& fileName) const;
215  // the export function that export the overall model.
216  void exportAllToFile(const std::string& fileName) const;
217 
218  // the export function that export to a outstream
219  void exportAllToStream(std::ofstream& out) const;
220 
221  // generate verilog file that is equivelant to the ILA
222  void generateVerilogToFile(const std::string& fileName) const;
223 
224  // generate verilog file that is equivelant to the ILA with a different
225  // top-level module name
226  void generateVerilogToFile(const std::string& fileName,
227  const std::string& topModName) const;
228 
229  // the import function that import only one expression.
230  NodeRef* importOneFromFile(const std::string& fileName);
231  // the import function that import a list of expression.
232  py::list importListFromFile(const std::string& fileName);
233  // the import function that import the overall model.
234  void importAllFromFile(const std::string& fileName);
235  // the import function that import the overall ILA abstraction from Stream
236  void importAllFromStream(std::ifstream& in, bool Clear);
237 
238  // the simulator generating function, output to one file.
239  void generateSimToFile(const std::string& fileName) const;
240  // the simulator generating function, output to seperated files in dir.
241  void generateSimToDir(const std::string& dirName) const;
242 
243  // the CBMC C generating function, output to one file.
244  void generateCbmcCtoFile(const std::string& fileName) const;
245  // the CBMC C generating function, output to seperated files in dir.
246  void generateCbmcCtoDir(const std::string& dirName) const;
247 
248  // check equality function.
249  bool areEqual(NodeRef* left, NodeRef* right) const;
250  // check quality under assumption
251  bool areEqualAssump(NodeRef* assump, NodeRef* left, NodeRef* right);
252  // check after unrolling.
253  bool areEqualUnrolled(unsigned n, NodeRef* reg, NodeRef* exp);
254  // unroll two abstractions and check
255  static bool bmc(unsigned n, Abstraction* a, NodeRef* r, bool init,
256  NodeRef* initAssump);
257  static bool bmc(unsigned n1, Abstraction* a1, NodeRef* r1, unsigned n2,
258  Abstraction* a2, NodeRef* r2);
259 
260  // unroll two abstraction including microabstraction and check
261  static bool EQcheckSimple(Abstraction* a1, Abstraction* a2);
262 
263  // convert this abstraction to boogie.
264  void toBoogie(const std::string& filename);
265 
266  // convert this abstraction to horn clauses.
267  void hornifyAll(const std::string& fileName);
268  // convert one node to horn clause,
269  void hornifyNode(NodeRef* node, const std::string& ruleName);
270  // generate mapping for instructions. (Interleave/Blocking)
271  void generateHornMapping(const std::string& type);
272  // dump horn clauses to file.
273  void exportHornToFile(const std::string& fileName);
274  // set flag to hornify ITE as node.
275  void hornifyIteAsNode(bool iteAsNode);
276  // set flag to hornify bitvector as Int.
277  void hornifyBvAsInt(bool bvAsInt);
278  // create an instruction with name i and decode d.
279  void addHornInstr(const std::string& i, NodeRef* d);
280  // add next state function n for state s to (child-)instruction i.
281  void addHornNext(const std::string& i, const std::string& s, NodeRef* n);
282  // create a child-instruction with name c and decode d to instr i.
283  void addHornChild(const std::string& c, const std::string& i, NodeRef* d);
284 
285  // get memories.
286  const nmap_t& getMems() const { return mems; }
287  // get (bitvector) inputs.
288  const nmap_t& getInps() const { return inps; }
289  // get bitvectors.
290  const nmap_t& getRegs() const { return regs; }
291  // get booleans.
292  const nmap_t& getBits() const { return bits; }
293  // get functions.
294  const nmap_t& getFuns() const { return funs; }
295 
296  // visit each assumption.
297  void forEachAssump(assump_visitor_i& i) const;
298  // get all assumptions in a vector.
299  void getAllAssumptions(nptr_vec_t& assump_vec) const;
300 
301  // collect all assumptions in a vector.
305  void useAssump(const nptr_t& a);
306  };
307 
308  // accessors.
309  nptr_t getFetchExprRef() const { return fetchExpr; }
310  nptr_t getFetchValidRef() const { return fetchValid; }
312  const npair_t* getMapEntry(const std::string& name) const;
313  bool isInput(const std::string& name) const {
314  auto pos = names.find(name);
315  if (pos == names.end())
316  return false;
317  else
318  return pos->second == INP;
319  }
320 
321  friend class Synthesizer;
322  friend class BoogieTranslator;
323  friend unsigned DetermineUnrollBound(Abstraction* pAbs,
324  const std::string& nodeName);
325  friend class MicroUnroller;
326 
327 protected:
328  nptr_t _synthesize(const std::string& name, const nptr_vec_t& assumps,
329  const nptr_t& expr, PyObject* pyfun);
330 
331  bool checkAndInsertName(state_t st, const std::string& name);
332 
333  // does the next expr exist?
334  bool doesNextExist(const nmap_t& m) const;
335  // which is the map containing this node?
336  nmap_t* getMap(const std::string& name, NodeRef* n);
337  // same as above, but use only name.
338  nmap_t* getMap(const std::string& name);
339  // what is the map containing this name?
340  nmap_t::const_iterator findInMap(const std::string& name) const;
341  nmap_t::iterator findInMap(const std::string& name);
342 
343  nmap_t::const_iterator findInMapNoExcept(const std::string& name) const;
344  nmap_t::iterator findInMapNoExcept(const std::string& name);
345  nmap_t::const_iterator MapEnd() const;
346  nmap_t::iterator MapEnd();
347 
348  friend class AbstractionWrapper;
349 
350 private:
351  // function reduce helper
353  // horn clause translator.
355  // The simulator generating function.
356  CppSimGen* generateSim(bool hier) const;
357  // CBMC C generation
358  CVerifGen* generateCBMCC(bool hier) const;
359  // Set inputs, states, and functions to the simulator generator.
360  void addVarToSimulator(CppSimGen* gen) const;
361  // Set next value to the function.
362  void setUpdateToFunction(CppSimGen* gen, CppFun* fun, nptr_t valid,
363  bool doHier = false) const;
364 };
365 
366 // This class contains a shared pointer to an underlying
367 // abstraction. We use this to wrap up objects and pass them
368 // around in python and the shared_ptr does the refcounting for us.
371 
372  // constructor.
373  AbstractionWrapper(const std::string& name) : abs(new Abstraction(name)) {}
374 
375  // constructor for microabstraction.
376  AbstractionWrapper(Abstraction* parent, const std::string& name)
377  : abs(new Abstraction(parent, name)) {}
378 
379  // constructor with existing pointer.
381 
382  // destructor.
384 
385  // Create a bitvector input.
386  NodeRef* addInp(const std::string& name, int width) {
387  return abs->addInp(name, width);
388  }
389 
390  // Create a boolean variable.
391  NodeRef* addBit(const std::string& name) { return abs->addBit(name); }
392 
393  // Create a bitvector variable.
394  NodeRef* addReg(const std::string& name, int width) {
395  return abs->addReg(name, width);
396  }
397 
398  // Create a memory.
399  NodeRef* addMem(const std::string& name, int addrW, int dataW) {
400  return abs->addMem(name, addrW, dataW);
401  }
402 
403  // Create a function.
404  NodeRef* addFun(const std::string& name, int retW, const py::list& l) {
405  return abs->addFun(name, retW, l);
406  }
407 
408  // Get an existing input port
409  NodeRef* getInp(const std::string& name) { return abs->getInp(name); }
410 
411  // Get an existing boolean.
412  NodeRef* getBit(const std::string& name) { return abs->getBit(name); }
413 
414  // Get an existing bitvector.
415  NodeRef* getReg(const std::string& name) { return abs->getReg(name); }
416 
417  // Get an existing memory.
418  NodeRef* getMem(const std::string& name) { return abs->getMem(name); }
419 
420  // Get an existing function.
421  NodeRef* getFun(const std::string& name) { return abs->getFun(name); }
422 
423  // Set the init value for this var.
424  void setInit(const std::string& name, NodeRef* n) { abs->setInit(name, n); }
425  // Get the initial value for this var.
426  NodeRef* getInit(const std::string& name) const { return abs->getInit(name); }
427 
428  // Set a predicate associated with the initial value.
429  void setIpred(const std::string& name, NodeRef* n) { abs->setIpred(name, n); }
430  // Get the predicate associated with the initial vlaue.
431  NodeRef* getIpred(const std::string& name) const {
432  return abs->getIpred(name);
433  }
434 
435  // Set the next template for this var.
436  void setNext(const std::string& name, NodeRef* n) { abs->setNext(name, n); }
437  // Get the next template.
438  NodeRef* getNext(const std::string& name) const { return abs->getNext(name); }
439 
440  // Get the next state fn for the ith instruction.
441  NodeRef* getNextI(const std::string& name, int i) const {
442  return abs->getNextI(name, i);
443  }
444 
445  // Create a microabstraction.
446  AbstractionWrapper* addUAbs(const std::string& name, NodeRef* valid) {
447  return abs->addUAbs(name, valid);
448  }
449  // Get an existing microabstraction
450  AbstractionWrapper* getUAbs(const std::string& name) {
451  return abs->getUAbs(name);
452  }
453  // Connect a variable to its corresponding value in the ubs
454  void connectUInst(const std::string& name, const AbstractionWrapper* uabs) {
455  abs->connectUInst(name, uabs->abs);
456  }
457 
458  // Create a bitvector constant with a long integer.
459  NodeRef* bvConstLong(py::long_ l, int width) {
460  return abs->bvConstLong(l, width);
461  }
462  static NodeRef* bvConstLongStatic(py::long_ l, int width) {
463  return Abstraction::bvConstLong(l, width);
464  }
465 
466  // Create a bitvector constant with an integer.
467  NodeRef* bvConstInt(unsigned int l, int width) {
468  return abs->bvConstInt(l, width);
469  }
470  static NodeRef* bvConstIntStatic(unsigned int l, int width) {
471  return Abstraction::bvConstInt(l, width);
472  }
473 
474  // Create a boolean constant (from a bool).
475  NodeRef* boolConstB(bool b) { return abs->boolConstB(b); }
476  static NodeRef* boolConstBStatic(bool b) {
477  return Abstraction::boolConstB(b);
478  }
479 
480  // Create a boolean constant (from an integer: nonzero = true).
481  NodeRef* boolConstI(int b) { return abs->boolConstI(b); }
482  static NodeRef* boolConstIStatic(int b) { return Abstraction::boolConstI(b); }
483 
484  // Create a boolean constant (from an python long).
485  NodeRef* boolConstL(py::long_ b) { return abs->boolConstL(b); }
486  static NodeRef* boolConstLStatic(py::long_ b) {
487  return Abstraction::boolConstL(b);
488  }
489 
490  // Create a memory constant (from a memvalues object).
491  NodeRef* memConst(const MemValues& mv) { return abs->memConst(mv); }
492  static NodeRef* memConstStatic(const MemValues& mv) {
493  return Abstraction::memConst(mv);
494  }
495 
496  // return the current fetch expression.
497  NodeRef* getFetchExpr() const { return abs->getFetchExpr(); }
498 
499  // set the fetch expression.
500  void setFetchExpr(NodeRef* expr) { abs->setFetchExpr(expr); }
501 
502  // return the fetch valid expression.
503  NodeRef* getFetchValid() const { return abs->getFetchValid(); }
504 
505  // set the fetch valid expresssion.
506  void setFetchValid(NodeRef* expr) { abs->setFetchValid(expr); }
507 
508  // set decode.
509  void setDecodeExpressions(const py::list& l) { abs->setDecodeExpressions(l); }
510 
511  // get decode expressions.
512  py::list getDecodeExpressions() const { return abs->getDecodeExpressions(); }
513 
514  // add an assumption.
515  void addAssumption(NodeRef* expr) { abs->addAssumption(expr); }
516 
517  // get all assumptions.
518  py::list getAllAssumptions() const { return abs->getAllAssumptions(); }
519 
520  // the real synthesize function.
521  void synthesizeAll(PyObject* fun) { return abs->synthesizeAll(fun); }
522 
523  // synthesize only one register.
524  void synthesizeReg(const std::string& name, PyObject* fun) {
525  return abs->synthesizeReg(name, fun);
526  }
527 
528  // the synthesis function.
529  NodeRef* synthesizeElement(const std::string& name, NodeRef* expr,
530  PyObject* fun) {
531  return abs->synthesizeElement(name, expr, fun);
532  }
533 
534  // the export function that export only one expression.
535  void exportOneToFile(NodeRef* node, const std::string& fileName) const {
536  abs->exportOneToFile(node, fileName);
537  }
538 
539  // the export function that export a list of expressions.
540  void exportListToFile(const py::list& l, const std::string& fileName) const {
541  abs->exportListToFile(l, fileName);
542  }
543 
544  // the export function that export the overall model.
545  void exportAllToFile(const std::string& fileName) const {
546  abs->exportAllToFile(fileName);
547  }
548 
549  void generateVerilogToFile(const std::string& fileName) const {
550  abs->generateVerilogToFile(fileName);
551  }
552  void generateVerilogModule(const std::string& fileName,
553  const std::string& modName) const {
554  abs->generateVerilogToFile(fileName, modName);
555  }
556 
557  // the import function that import only one expression.
558  NodeRef* importOneFromFile(const std::string& fileName) {
559  return abs->importOneFromFile(fileName);
560  }
561 
562  // the improt function that import a list of expressions.
563  py::list importListFromFile(const std::string& fileName) {
564  return abs->importListFromFile(fileName);
565  }
566 
567  // the import function that import the overall model.
568  void importAllFromFile(const std::string& fileName) {
569  abs->importAllFromFile(fileName);
570  }
571 
572  // the simulator generating function.
573  void generateSimToFile(const std::string& fileName) const {
574  abs->generateSimToFile(fileName);
575  }
576 
577  void generateSimToDir(const std::string& dirName) const {
578  abs->generateSimToDir(dirName);
579  }
580 
581  void generateCbmcCtoFile(const std::string& fileName) const {
582  abs->generateCbmcCtoFile(fileName);
583  }
584 
585  void generateCbmcCtoDir(const std::string& dirName) const {
586  abs->generateCbmcCtoDir(dirName);
587  }
588 
589  // check equality function.
590  bool areEqual(NodeRef* left, NodeRef* right) const {
591  return abs->areEqual(left, right);
592  }
593 
594  // check quality under assumption
595  bool areEqualAssump(NodeRef* assump, NodeRef* left, NodeRef* right) {
596  return abs->areEqualAssump(assump, left, right);
597  }
598 
599  // check equality after unrolling.
600  bool areEqualUnrolled(unsigned n, NodeRef* reg, NodeRef* exp) {
601  return abs->areEqualUnrolled(n, reg, exp);
602  }
603  bool bmcInit(NodeRef* assertion, unsigned n, bool init) {
604  Abstraction* aptr = abs.get();
605  return Abstraction::bmc(n, aptr, assertion, init, NULL);
606  }
607  bool bmcCond(NodeRef* assertion, unsigned n, NodeRef* assumpt) {
608  Abstraction* aptr = abs.get();
609  return Abstraction::bmc(n, aptr, assertion, false, assumpt);
610  }
611 
612  static bool bmc(unsigned n1, AbstractionWrapper* a1, NodeRef* r1, unsigned n2,
613  AbstractionWrapper* a2, NodeRef* r2) {
614  Abstraction* a1ptr = a1->abs.get();
615  Abstraction* a2ptr = a2->abs.get();
616 
617  return Abstraction::bmc(n1, a1ptr, r1, n2, a2ptr, r2);
618  }
619 
621  Abstraction* a1ptr = a1->abs.get();
622  Abstraction* a2ptr = a2->abs.get();
623 
624  return Abstraction::EQcheckSimple(a1ptr, a2ptr);
625  }
626 
627  static bool EQcheck(MicroUnroller* m1, MicroUnroller* m2,
628  const std::string& n1, const std::string& n2) {
629  return MicroUnroller::EqCheck(m1, m2, n1, n2);
630  }
631  static void EQcheckExport(const std::string& fn, MicroUnroller* m1,
632  MicroUnroller* m2, const std::string& n1,
633  const std::string& n2) {
634  MicroUnroller::EqOffline(fn, m1, m2, n1, n2);
635  }
636 
638  const std::string& n1, const std::string& n2,
639  py::list& assumps) {
640  return MicroUnroller::EqCheck(m1, m2, n1, n2, assumps);
641  }
642  static void EQcheckWithAssumpExport(const std::string& fn, MicroUnroller* m1,
643  MicroUnroller* m2, const std::string& n1,
644  const std::string& n2,
645  py::list& assumps) {
646  MicroUnroller::EqOffline(fn, m1, m2, n1, n2, assumps);
647  }
648 
649  MicroUnroller* newUnroller(AbstractionWrapper* uILA, bool initCondition) {
650  return MicroUnroller::NewUnroller(this, uILA, initCondition);
651  }
652 
653  void toBoogie(const std::string& name) { abs->toBoogie(name); }
654 
655  void hornifyAll(const std::string& name) { abs->hornifyAll(name); }
656 
657  void hornifyNode(NodeRef* node, const std::string& rule) {
658  abs->hornifyNode(node, rule);
659  }
660 
661  void generateHornMapping(const std::string& type) {
662  abs->generateHornMapping(type);
663  }
664 
665  void exportHornToFile(const std::string& fileName) {
666  abs->exportHornToFile(fileName);
667  }
668 
669  void hornifyIteAsNode(bool iteAsNode) { abs->hornifyIteAsNode(iteAsNode); }
670 
671  void hornifyBvAsInt(bool bvAsInt) { abs->hornifyBvAsInt(bvAsInt); }
672 
673  void addHornInstr(const std::string& i, NodeRef* d) {
674  abs->addHornInstr(i, d);
675  }
676 
677  void addHornNext(const std::string& i, const std::string& s, NodeRef* n) {
678  abs->addHornNext(i, s, n);
679  }
680 
681  void addHornChild(const std::string& c, const std::string& i, NodeRef* d) {
682  abs->addHornChild(c, i, d);
683  }
684 
685  int getEnParamSyn() const { return abs->paramSyn; }
686 
687  void setEnParamSyn(int en) { abs->paramSyn = en; }
688 
689  void setVlgExpConfig(bool extMem, bool fAsM) {
690  abs->vlgExpConfig._extMem = extMem;
691  abs->vlgExpConfig._fmodule = fAsM;
692  }
693 
694  int getReduceWhenImport() const { return abs->reduceWhenImport; }
695 
696  void setReduceWhenImport(int en) { abs->reduceWhenImport = en; }
697 
698  std::string getName() const { return abs->name; }
699 
700  // get memories.
701  const nmap_t& getMems() const { return abs->getMems(); }
702  // get (bitvector) inputs.
703  const nmap_t& getInps() const { return abs->getInps(); }
704  // get bitvectors.
705  const nmap_t& getRegs() const { return abs->getRegs(); }
706  // get booleans.
707  const nmap_t& getBits() const { return abs->getBits(); }
708  // get functions.
709  const nmap_t& getFuns() const { return abs->getFuns(); }
710 };
711 
712 } // namespace ilasynth
713 #endif
void setDecodeExpressions(const py::list &l)
Definition: abstraction.hpp:509
void setEnParamSyn(int en)
Definition: abstraction.hpp:687
void exportListToFile(const py::list &l, const std::string &fileName) const
Definition: abstraction.hpp:540
void addHornNext(const std::string &i, const std::string &s, NodeRef *n)
void forEachAssump(assump_visitor_i &i) const
NodeRef * boolConstI(int b)
Definition: abstraction.hpp:481
Definition: VerilogExport.hpp:14
void synthesizeAll(PyObject *fun)
const nmap_t & getBits() const
Definition: abstraction.hpp:707
Definition: abstraction.hpp:302
void generateCbmcCtoFile(const std::string &fileName) const
Definition: abstraction.hpp:581
void setNext(const std::string &name, NodeRef *n)
Definition: abstraction.hpp:436
int paramSyn
Definition: abstraction.hpp:92
void addHornChild(const std::string &c, const std::string &i, NodeRef *d)
Definition: abstraction.hpp:681
static bool EqCheck(MicroUnroller *m1, MicroUnroller *m2, const std::string &n1, const std::string &n2)
bool isInput(const std::string &name) const
Definition: abstraction.hpp:313
nmap_t mems
Definition: abstraction.hpp:67
CppSimGen * generateSim(bool hier) const
void exportAllToFile(const std::string &fileName) const
Definition: abstraction.hpp:545
nptr_vec_t decodeExprs
Definition: abstraction.hpp:76
void setFetchExpr(NodeRef *expr)
Definition: abstraction.hpp:500
static NodeRef * boolConstBStatic(bool b)
Definition: abstraction.hpp:476
NodeRef * getInp(const std::string &name)
Definition: abstraction.hpp:27
void generateHornMapping(const std::string &type)
Definition: abstraction.hpp:661
NodeRef * addInp(const std::string &name, int width)
Definition: abstraction.hpp:386
void setVlgExpConfig(bool extMem, bool fAsM)
Definition: abstraction.hpp:689
static NodeRef * boolConstIStatic(int b)
Definition: abstraction.hpp:482
NodeRef * importOneFromFile(const std::string &fileName)
nptr_t getFetchValidNode() const
NodeRef * memConst(const MemValues &mv)
Definition: abstraction.hpp:491
void exportAllToStream(std::ofstream &out) const
bool areEqual(NodeRef *left, NodeRef *right) const
static int objCnt
Definition: abstraction.hpp:47
assump_collector_t(nptr_vec_t &v)
Definition: abstraction.hpp:304
NodeRef * synthesizeElement(const std::string &name, NodeRef *expr, PyObject *fun)
NodeRef * getFetchValid() const
Definition: abstraction.hpp:503
void extractModelValues(Z3ExprAdapter &c, z3::model &m, py::dict &result)
bool areEqualAssump(NodeRef *assump, NodeRef *left, NodeRef *right)
const nmap_t & getInps() const
Definition: abstraction.hpp:288
void addHornInstr(const std::string &i, NodeRef *d)
bool areEqualUnrolled(unsigned n, NodeRef *reg, NodeRef *exp)
Definition: abstraction.hpp:600
Definition: abstraction.hpp:34
std::map< std::string, uabstraction_t > uabs_map_t
Definition: abstraction.hpp:44
bool areEqual(NodeRef *left, NodeRef *right) const
Definition: abstraction.hpp:590
NodeRef * addReg(const std::string &name, int width)
Definition: abstraction.hpp:34
NodeRef * bvConstInt(unsigned int l, int width)
Definition: abstraction.hpp:467
CVerifGen * generateCBMCC(bool hier) const
void generateVerilogModule(const std::string &fileName, const std::string &modName) const
Definition: abstraction.hpp:552
void setUpdateToFunction(CppSimGen *gen, CppFun *fun, nptr_t valid, bool doHier=false) const
void importAllFromFile(const std::string &fileName)
const nptr_vec_t & getDecodeNodes() const
NodeRef * addInp(const std::string &name, int width)
void generateSimToDir(const std::string &dirName) const
Definition: abstraction.hpp:577
Definition: abstraction.hpp:34
VlgExportConfig vlgExpConfig
Definition: abstraction.hpp:94
NodeRef * getBit(const std::string &name)
std::vector< nptr_t > nptr_vec_t
Definition: node.hpp:27
NodeRef * importOneFromFile(const std::string &fileName)
Definition: abstraction.hpp:558
Definition: boogie.hpp:23
NodeRef * getInit(const std::string &name) const
nmap_t inps
Definition: abstraction.hpp:61
bool bmcInit(NodeRef *assertion, unsigned n, bool init)
Definition: abstraction.hpp:603
static MicroUnroller * NewUnroller(AbstractionWrapper *Abs, AbstractionWrapper *Uabs, bool InitCond)
void generateSimToDir(const std::string &dirName) const
abstraction_ptr_t abs
Definition: abstraction.hpp:370
NodeRef * getMem(const std::string &name)
Definition: abstraction.hpp:418
static bool EQcheckSimple(Abstraction *a1, Abstraction *a2)
void addHornChild(const std::string &c, const std::string &i, NodeRef *d)
int getReduceWhenImport() const
Definition: abstraction.hpp:694
AbstractionWrapper * getUAbs(const std::string &name)
Definition: abstraction.hpp:450
NodeRef * getInp(const std::string &name)
Definition: abstraction.hpp:409
Definition: abstraction.hpp:34
nptr_t _synthesize(const std::string &name, const nptr_vec_t &assumps, const nptr_t &expr, PyObject *pyfun)
std::map< std::string, npair_t > nmap_t
Definition: node.hpp:53
nptr_t getFetchValidRef() const
Definition: abstraction.hpp:310
Definition: abstraction.hpp:31
void hornifyBvAsInt(bool bvAsInt)
Definition: abstraction.hpp:671
Definition: funcReduct.hpp:13
AbstractionWrapper * getUAbs(const std::string &name)
const nmap_t & getInps() const
Definition: abstraction.hpp:703
void hornifyNode(NodeRef *node, const std::string &rule)
Definition: abstraction.hpp:657
nmap_t bits
Definition: abstraction.hpp:65
AbstractionWrapper(const std::string &name)
Definition: abstraction.hpp:373
Definition: genCBMC.hpp:130
void setNext(const std::string &name, NodeRef *n)
NodeRef * synthesizeElement(const std::string &name, NodeRef *expr, PyObject *fun)
Definition: abstraction.hpp:529
static NodeRef * boolConstB(bool b)
NodeRef * getNext(const std::string &name) const
void exportOneToFile(NodeRef *node, const std::string &fileName) const
Definition: abstraction.hpp:535
void addAssumption(NodeRef *expr)
Definition: abstraction.hpp:515
void setFetchValid(NodeRef *expr)
Definition: abstraction.hpp:506
void toBoogie(const std::string &name)
Definition: abstraction.hpp:653
void generateSimToFile(const std::string &fileName) const
NodeRef * getBit(const std::string &name)
Definition: abstraction.hpp:412
void initMap(nmap_t &from_m, nmap_t &to_m)
nptr_t fetchValid
Definition: abstraction.hpp:73
boost::shared_ptr< Node > nptr_t
Definition: node.hpp:24
void synthesizeReg(const std::string &name, PyObject *fun)
Definition: abstraction.hpp:524
NodeRef * getStage(const std::string &name)
static bool EQcheckSimple(AbstractionWrapper *a1, AbstractionWrapper *a2)
Definition: abstraction.hpp:620
Definition: synthesizer.hpp:156
nmap_t::const_iterator findInMapNoExcept(const std::string &name) const
const nmap_t & getFuns() const
Definition: abstraction.hpp:709
static NodeRef * memConst(const MemValues &mv)
py::list importListFromFile(const std::string &fileName)
NodeRef * getReg(const std::string &name)
NodeRef * getNext(const std::string &name) const
Definition: abstraction.hpp:438
NodeRef * boolConstL(py::long_ b)
Definition: abstraction.hpp:485
std::string getName() const
Definition: abstraction.hpp:698
static void EqOffline(const std::string &fileName, MicroUnroller *m1, MicroUnroller *m2, const std::string &n1, const std::string &n2)
NodeRef * getFetchExpr() const
Definition: abstraction.hpp:497
void hornifyAll(const std::string &name)
Definition: abstraction.hpp:655
friend unsigned DetermineUnrollBound(Abstraction *pAbs, const std::string &nodeName)
static NodeRef * boolConstL(py::long_ b)
Definition: cppsimgen.hpp:77
~AbstractionWrapper()
Definition: abstraction.hpp:383
static int getObjId()
NodeRef * getMem(const std::string &name)
void setIpred(const std::string &name, NodeRef *n)
AbstractionWrapper(Abstraction *parent, const std::string &name)
Definition: abstraction.hpp:376
static void EQcheckExport(const std::string &fn, MicroUnroller *m1, MicroUnroller *m2, const std::string &n1, const std::string &n2)
Definition: abstraction.hpp:631
bool doesNextExist(const nmap_t &m) const
NodeRef * bvConstLong(py::long_ l, int width)
Definition: abstraction.hpp:459
void generateVerilogToFile(const std::string &fileName) const
Definition: abstraction.hpp:549
NodeRef * getFun(const std::string &name)
Definition: abstraction.hpp:421
NodeRef * getFun(const std::string &name)
const std::string name
Definition: abstraction.hpp:55
state_t
Definition: abstraction.hpp:34
Definition: memvalues.hpp:20
Definition: smt.hpp:14
static bool EQcheckWithAssump(MicroUnroller *m1, MicroUnroller *m2, const std::string &n1, const std::string &n2, py::list &assumps)
Definition: abstraction.hpp:637
void addHornNext(const std::string &i, const std::string &s, NodeRef *n)
Definition: abstraction.hpp:677
nptr_vec_t & vec
Definition: abstraction.hpp:303
NodeRef * getFetchExpr() const
static NodeRef * bvConstIntStatic(unsigned int l, int width)
Definition: abstraction.hpp:470
Definition: abstraction.hpp:21
void exportAllToFile(const std::string &fileName) const
nmap_t::const_iterator findInMap(const std::string &name) const
bool checkAndInsertName(state_t st, const std::string &name)
static void EQcheckWithAssumpExport(const std::string &fn, MicroUnroller *m1, MicroUnroller *m2, const std::string &n1, const std::string &n2, py::list &assumps)
Definition: abstraction.hpp:642
NodeRef * addFun(const std::string &name, int retW, const py::list &l)
Definition: abstraction.hpp:404
NodeRef * getNextI(const std::string &name, int i) const
void hornifyNode(NodeRef *node, const std::string &ruleName)
void exportHornToFile(const std::string &fileName)
Definition: abstraction.hpp:665
py::list getAllAssumptions() const
Definition: abstraction.hpp:518
void importAllFromFile(const std::string &fileName)
Definition: abstraction.hpp:568
void synthesizeReg(const std::string &name, PyObject *fun)
int MAX_SYN_ITER
Definition: abstraction.hpp:48
NodeRef * getInit(const std::string &name) const
Definition: abstraction.hpp:426
py::list getAllAssumptions() const
nptr_vec_t getDecodeExprs() const
Definition: abstraction.hpp:311
NodeRef * getVar(const nmap_t &m, const std::string &name)
void generateVerilogToFile(const std::string &fileName) const
void hornifyIteAsNode(bool iteAsNode)
void connectUInst(const std::string &name, const AbstractionWrapper *uabs)
Definition: abstraction.hpp:454
void connectUInst(const std::string &name, const abstraction_ptr_t &uabs)
bool areEqualUnrolled(unsigned n, NodeRef *reg, NodeRef *exp)
void toBoogie(const std::string &filename)
const std::string & getName() const
Definition: abstraction.hpp:106
Abstraction(const std::string &name)
void setFetchValid(NodeRef *expr)
bool areEqualAssump(NodeRef *assump, NodeRef *left, NodeRef *right)
Definition: abstraction.hpp:595
void hornifyBvAsInt(bool bvAsInt)
const nmap_t & getMems() const
Definition: abstraction.hpp:701
NodeRef * addBit(const std::string &name)
Definition: abstraction.hpp:391
void addVar(state_t st, nmap_t &m, nptr_t &n)
std::map< std::string, state_t > names
Definition: abstraction.hpp:58
void generateSimToFile(const std::string &fileName) const
Definition: abstraction.hpp:573
const nmap_t & getMems() const
Definition: abstraction.hpp:286
static NodeRef * boolConstLStatic(py::long_ b)
Definition: abstraction.hpp:486
void exportListToFile(const py::list &l, const std::string &fileName) const
AbstractionWrapper(const abstraction_ptr_t &a)
Definition: abstraction.hpp:380
nptr_vec_t assumps
Definition: abstraction.hpp:79
void addAssumption(NodeRef *expr)
NodeRef * boolConstB(bool b)
Definition: abstraction.hpp:475
nptr_t getFetchExprRef() const
Definition: abstraction.hpp:309
static NodeRef * bvConstLongStatic(py::long_ l, int width)
Definition: abstraction.hpp:462
void setInit(const std::string &name, NodeRef *n)
Definition: abstraction.hpp:424
Definition: abstraction.hpp:34
abstraction_ptr_t abs
Definition: abstraction.hpp:40
void generateHornMapping(const std::string &type)
void importAllFromStream(std::ifstream &in, bool Clear)
void synthesizeAll(PyObject *fun)
Definition: abstraction.hpp:521
void exportHornToFile(const std::string &fileName)
virtual void useAssump(const nptr_t &a)=0
NodeRef * getNextI(const std::string &name, int i) const
Definition: abstraction.hpp:441
NodeRef * addMem(const std::string &name, int addrW, int dataW)
void setReduceWhenImport(int en)
Definition: abstraction.hpp:696
Definition: abstraction.hpp:369
void hornifyAll(const std::string &fileName)
nmap_t funs
Definition: abstraction.hpp:69
void addHornInstr(const std::string &i, NodeRef *d)
Definition: abstraction.hpp:673
nptr_t fetchExpr
Definition: abstraction.hpp:72
static bool bmc(unsigned n1, AbstractionWrapper *a1, NodeRef *r1, unsigned n2, AbstractionWrapper *a2, NodeRef *r2)
Definition: abstraction.hpp:612
NodeRef * addReg(const std::string &name, int width)
Definition: abstraction.hpp:394
Definition: cppsimgen.hpp:113
void exportOneToFile(NodeRef *node, const std::string &fileName) const
const nmap_t & getBits() const
Definition: abstraction.hpp:292
const nmap_t & getRegs() const
Definition: abstraction.hpp:290
HornTranslator * _ht
Definition: abstraction.hpp:354
Definition: abstraction.hpp:36
static NodeRef * boolConstI(int b)
const nmap_t & getRegs() const
Definition: abstraction.hpp:705
nmap_t::const_iterator MapEnd() const
py::list importListFromFile(const std::string &fileName)
Definition: abstraction.hpp:563
void addVarToSimulator(CppSimGen *gen) const
void generateCbmcCtoDir(const std::string &dirName) const
py::list getDecodeExpressions() const
Definition: abstraction.hpp:512
NodeRef * getIpred(const std::string &name) const
bool bmcCond(NodeRef *assertion, unsigned n, NodeRef *assumpt)
Definition: abstraction.hpp:607
MicroUnroller * newUnroller(AbstractionWrapper *uILA, bool initCondition)
Definition: abstraction.hpp:649
void hornifyIteAsNode(bool iteAsNode)
Definition: abstraction.hpp:669
void setFetchExpr(NodeRef *expr)
nmap_t regs
Definition: abstraction.hpp:63
static NodeRef * memConstStatic(const MemValues &mv)
Definition: abstraction.hpp:492
Definition: ast.hpp:29
NodeRef * getFetchValid() const
py::list getDecodeExpressions() const
void generateCbmcCtoDir(const std::string &dirName) const
Definition: abstraction.hpp:585
boost::shared_ptr< Abstraction > abstraction_ptr_t
Definition: abstraction.hpp:24
NodeRef * addBit(const std::string &name)
const nmap_t & getFuns() const
Definition: abstraction.hpp:294
FuncReduction funcReducer
Definition: abstraction.hpp:352
static bool bmc(unsigned n, Abstraction *a, NodeRef *r, bool init, NodeRef *initAssump)
AbstractionWrapper * addUAbs(const std::string &name, NodeRef *valid)
uabs_map_t uabs
Definition: abstraction.hpp:82
void generateCbmcCtoFile(const std::string &fileName) const
NodeRef * getIpred(const std::string &name) const
Definition: abstraction.hpp:431
AbstractionWrapper * addUAbs(const std::string &name, NodeRef *valid)
Definition: abstraction.hpp:446
NodeRef * getReg(const std::string &name)
Definition: abstraction.hpp:415
void setIpred(const std::string &name, NodeRef *n)
Definition: abstraction.hpp:429
void setDecodeExpressions(const py::list &l)
const npair_t * getMapEntry(const std::string &name) const
int reduceWhenImport
Definition: abstraction.hpp:93
static bool EQcheck(MicroUnroller *m1, MicroUnroller *m2, const std::string &n1, const std::string &n2)
Definition: abstraction.hpp:627
Abstraction * parent
Definition: abstraction.hpp:52
nmap_t * getMap(const std::string &name, NodeRef *n)
static NodeRef * bvConstInt(unsigned int l, int width)
void setInit(const std::string &name, NodeRef *n)
nptr_t valid
Definition: abstraction.hpp:38
NodeRef * addFun(const std::string &name, int retW, const py::list &l)
Definition: horn.hpp:251
Definition: MicroUnroller.hpp:22
int getEnParamSyn() const
Definition: abstraction.hpp:685
NodeRef * addMem(const std::string &name, int addrW, int dataW)
Definition: abstraction.hpp:399
Definition: node.hpp:31
static NodeRef * bvConstLong(py::long_ l, int width)