ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
vtarget_gen_inv_chc.h
1 // ---Hongce Zhang
8 
9 #ifndef VTARGET_GEN_INV_CHC_H__
10 #define VTARGET_GEN_INV_CHC_H__
11 
12 #include <ilang/config.h>
13 #ifdef INVSYN_INTERFACE
14 
16 #include <ilang/smt-inout/yosys_smt_parser.h>
17 #include <ilang/vtarget-out/vlg_mod.h>
18 #include <ilang/vtarget-out/vtarget_gen_impl.h>
19 #include <iostream>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace ilang {
25 
26 class VlgSglTgtGen_Chc;
27 
29 class Chc_problem {
30  friend class VlgSglTgtGen_Chc;
32  typedef std::vector<std::string> prop_t;
35  typedef struct {
36  // the name in [??]
37  // std::string problem_name;
39  prop_t exprs;
40  } problem_t;
42  typedef std::map<std::string, problem_t> problemset_t;
43 
44 protected:
46  problemset_t assumptions;
48  problemset_t assertions;
49 
50 }; // Chc_problem
51 
53 class VlgSglTgtGen_Chc : public VlgSglTgtGen {
54 
55 public:
57  using target_type_t = VlgSglTgtGen::target_type_t;
59  using info_t = VerilogModifier::info_t;
61  using fn_l_map_t = VerilogModifier::fn_l_map_t;
63  using advanced_parameters_t = VlgVerifTgtGenBase::advanced_parameters_t;
65  using _chc_target_t = VlgVerifTgtGenBase::_chc_target_t;
66 
67 public:
68  // --------------------- CONSTRUCTOR ---------------------------- //
82  VlgSglTgtGen_Chc(
83  const std::string& output_path, // will be a sub directory of the
84  // output_path of its parent
85  const InstrPtr& instr_ptr, // which could be an empty pointer, and it will
86  // be used to verify invariants
87  const InstrLvlAbsPtr& ila_ptr,
88  const VerilogGenerator::VlgGenConfig& config, nlohmann::json& _rf_vmap,
89  nlohmann::json& _rf_cond, VlgTgtSupplementaryInfo& _sup_info,
90  VerilogInfo* _vlg_info_ptr, const std::string& vlg_mod_inst_name,
91  const std::string& ila_mod_inst_name, const std::string& wrapper_name,
92  const std::vector<std::string>& implementation_srcs,
93  const std::vector<std::string>& include_dirs,
94  const vtg_config_t& vtg_config, backend_selector vbackend,
95  synthesis_backend_selector sbackend, const target_type_t& target_tp,
96  advanced_parameters_t* adv_ptr, bool generate_proof,
97  _chc_target_t chc_target);
98 
99  // --------------------- Destructor ---------------------------- //
101  virtual ~VlgSglTgtGen_Chc();
102 
103 protected:
105  Chc_problem _problems;
107  std::string chc_prob_fname;
109  std::string chc_run_script_name;
111  std::vector<std::string> vlg_mod_inv_vec;
113  synthesis_backend_selector s_backend;
115  std::shared_ptr<smt::YosysSmtParser> design_smt_info;
117  bool generate_proof;
119  bool has_cex;
121  _chc_target_t chc_target;
122 
123 protected:
125  virtual void add_a_direct_assumption(const std::string& aspt,
126  const std::string& dspt) override;
128  virtual void add_a_direct_assertion(const std::string& asst,
129  const std::string& dspt) override;
130 
132  void virtual PreExportProcess() override;
134  virtual void Export_script(const std::string& script_name) override;
136  virtual void Export_problem(const std::string& extra_name) override;
140  virtual void Export_mem(const std::string& mem_name) override;
142  virtual void Export_modify_verilog() override;
143 
144 private:
146  void convert_smt_to_chc_datatype(const std::string& smt_fname,
147  const std::string& chc_fname);
149  void convert_smt_to_chc_bitvec(const std::string& smt_fname,
150  const std::string& chc_fname,
151  const std::string& wrapper_mod_name);
153  void design_only_gen_smt(const std::string& smt_name,
154  const std::string& ys_script_name);
155 
156 public:
158  void virtual ExportAll(const std::string& wrapper_name,
159  const std::string& ila_vlg_name,
160  const std::string& script_name,
161  const std::string& extra_name,
162  const std::string& mem_name) override;
164  std::shared_ptr<smt::YosysSmtParser> GetDesignSmtInfo() const;
166  virtual void do_not_instantiate(void) override{};
167 
168 }; // class VlgVerifTgtGenChc
169 
170 }; // namespace ilang
171 
172 #endif // INVSYN_INTERFACE
173 
174 #endif // VTARGET_GEN_INV_CHC_H__
std::tuple< long, std::string, bool > info_t
a tuple to store all related info for modification
Definition: vlg_mod.h:29
struct ilang::VlgVerifTgtGenBase::_adv_parameters advanced_parameters_t
Instr::InstrPtr InstrPtr
Pointer type for normal use of Instr.
Definition: instr.h:132
target_type_t
Type of the target.
Definition: vtarget_gen_impl.h:40
VerilogGeneratorBase::VlgGenConfig VlgGenConfig
the structure to configure the verilog generator
Definition: verilog_gen.h:421
std::map< std::string, std::vector< info_t > > fn_l_map_t
filename -&gt; (lineno, varname, is_port_sig) vec
Definition: vlg_mod.h:33
InstrLvlAbs::InstrLvlAbsPtr InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:326
_chc_target_t
Type of the chc target.
Definition: vtarget_gen.h:53