ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
yosys_smt_parser.h
1 
7 #ifndef YOSYS_SMT_PARSER_H__
8 #define YOSYS_SMT_PARSER_H__
9 
10 #include <ilang/smt-inout/smt_ast.h>
11 
12 #include <iostream>
13 #include <set>
14 #include <string>
15 
16 namespace ilang {
17 namespace smt {
18 
23 public:
24  typedef std::map<std::string, state_var_t*> variable_idx_t;
25  // ---------------- TYPE DEFs -------------------- //
26 protected:
30  datatypes_t flatten_datatype;
32  variable_idx_t variable_idx;
33  // ------------- HELPER FUNCTIONS ---------------- //
41  void create_variable_idx();
42 
43 public:
44  // ----------- HELPER FUNCTIONS - Low Level ----- //
46  static void
47  convert_flatten_datatype_to_arg_vec(const std::vector<state_var_t>&,
48  std::vector<arg_t>&,
49  const std::string& suffix);
51  static void convert_datatype_to_type_vec(
52  const std::vector<state_var_t>& all_flattened_state_var,
53  std::vector<var_type>& args);
55  static std::string st_name_add_suffix(const std::string& stname,
56  const std::string& suffix);
58  static std::string st_name_add_prefix(const std::string& stname,
59  const std::string& prefix);
61  static std::vector<std::string> str_to_list(const std::string& in);
62 
63 protected:
64  // ----------- HELPER FUNCTIONS - Low Level ----- //
66  std::string replace_a_body(
67  const std::string& current_module,
68  const std::map<std::string, state_var_t>& current_mod_state_var_idx,
69  const std::vector<std::string>& arg_def, // [state] or [state,next_state]
70  const std::set<std::string>& defined_func, const std::string& body_text);
72  void replace_a_func(
73  std::shared_ptr<func_def_t> fn, const std::string& current_module,
74  // string -> state_var of current map
75  const std::map<std::string, state_var_t>& current_mod_state_var_idx,
76  const std::set<std::string>& defined_func);
77 
78 public:
79  // -------------- CONSTRUCTOR -------------------- //
80  YosysSmtParser(const std::string& buf);
81  // -------------- DESTRUCTOR -------------------- //
82  virtual ~YosysSmtParser();
83  // -------------- Procedures -------------------- //
85  void BreakDatatypes();
89  std::string Export();
91  const smt_file& GetRawSmtAst() const;
92  // -------------- Helpers -------------------- //
94  const std::vector<std::string>& get_module_def_orders() const;
96  const std::vector<state_var_t>&
97  get_module_flatten_dt(const std::string& mod_name) const;
99  const variable_idx_t& get_var_idx() const;
101  bool is_state_name(const std::string& state_name) const;
102 }; // class YosysSmtParser
103 
104 }; // namespace smt
105 }; // namespace ilang
106 
107 #endif
static std::vector< std::string > str_to_list(const std::string &in)
extract list from a space seped text
std::string replace_a_body(const std::string &current_module, const std::map< std::string, state_var_t > &current_mod_state_var_idx, const std::vector< std::string > &arg_def, const std::set< std::string > &defined_func, const std::string &body_text)
replace : handle a func_body
void construct_flatten_dataype()
construct flatten_datatype (hierarchically)
the class that holds the whole file
Definition: smt_ast.h:183
datatypes_t flatten_datatype
the datatype defs without datatypes
Definition: yosys_smt_parser.h:30
void replace_a_func(std::shared_ptr< func_def_t > fn, const std::string &current_module, const std::map< std::string, state_var_t > &current_mod_state_var_idx, const std::set< std::string > &defined_func)
replace : handle a func (arg) and invoke the body repl part
void add_no_change_function()
add the no-change-function (hierarchically)
void BreakDatatypes()
Process (replace and add)
const smt_file & GetRawSmtAst() const
Get the unflattened datatype.
void replace_all_function_arg_body()
replace function body and argument
void AddNoChangeStateUpdateFunction()
Add the no change function.
variable_idx_t variable_idx
the variable indices — only top level
Definition: yosys_smt_parser.h:32
const std::vector< state_var_t > & get_module_flatten_dt(const std::string &mod_name) const
return a module&#39;s flatten datatypes
to parse an smt file this will only work on the yosys&#39;s generated smt and not on the assembled CHC ...
Definition: yosys_smt_parser.h:22
bool is_state_name(const std::string &state_name) const
check if a name is a state
const variable_idx_t & get_var_idx() const
return the top module&#39;s variable index
static void convert_datatype_to_type_vec(const std::vector< state_var_t > &all_flattened_state_var, std::vector< var_type > &args)
convert a flatten_datatype to function type decl
smt_file smt_ast
the internal smt-ast
Definition: yosys_smt_parser.h:28
void create_variable_idx()
create the variable indices
static std::string st_name_add_suffix(const std::string &stname, const std::string &suffix)
add a suffix (for next state)
const std::vector< std::string > & get_module_def_orders() const
return a reference to module def order
std::string Export()
Export to string.
static void convert_flatten_datatype_to_arg_vec(const std::vector< state_var_t > &, std::vector< arg_t > &, const std::string &suffix)
convert a flatten_datatype to function arg
static std::string st_name_add_prefix(const std::string &stname, const std::string &prefix)
add a prefix (for state name)