7 #include <ilang/smt-inout/chc_inv_in_wrapper.h>
8 #include <ilang/smt-inout/yosys_smt_parser.h>
15 #include "smtparser/smtlib2abstractparser.h"
16 #include "smtparser/smtlib2abstractparser_private.h"
23 class SmtlibInvariantParser;
52 typedef SmtTermInfo<std::string> SmtTermInfoVerilog;
54 typedef SmtTermInfoVerilog* SmtTermInfoVlgPtr;
61 typedef std::function<std::string(const std::string&)>
81 bool _flatten_hierarchy,
82 const std::set<std::string>& _inv_pred_name,
83 const std::string& dut_instance_name,
84 bool discourageOutOfScopeVariable =
true);
97 bool virtual ParseInvResultFromFile(
const std::string& fname)
override;
99 void virtual ParseSmtResultFromString(
const std::string& text)
override;
171 const std::vector<int>& idx,
172 const std::vector<SmtTermInfoVlgPtr>& args);
183 const std::vector<SmtTermInfoVlgPtr>& args,
186 #define DECLARE_OPERATOR(name) \
187 SmtTermInfoVlgPtr mk_##name(const std::string& symbol, var_type* sort, \
188 const std::vector<int>& idx, \
189 const std::vector<SmtTermInfoVlgPtr>& args)
192 DECLARE_OPERATOR(
true);
193 DECLARE_OPERATOR(
false);
195 DECLARE_OPERATOR(and);
196 DECLARE_OPERATOR(or);
197 DECLARE_OPERATOR(not);
198 DECLARE_OPERATOR(implies);
199 DECLARE_OPERATOR(eq);
200 DECLARE_OPERATOR(ite);
201 DECLARE_OPERATOR (xor);
202 DECLARE_OPERATOR(nand);
203 DECLARE_OPERATOR(concat);
204 DECLARE_OPERATOR(bvnot);
205 DECLARE_OPERATOR(bvand);
206 DECLARE_OPERATOR(bvnand);
207 DECLARE_OPERATOR(bvor);
208 DECLARE_OPERATOR(bvnor);
209 DECLARE_OPERATOR(bvxor);
210 DECLARE_OPERATOR(bvxnor);
211 DECLARE_OPERATOR(bvult);
212 DECLARE_OPERATOR(bvslt);
213 DECLARE_OPERATOR(bvule);
214 DECLARE_OPERATOR(bvsle);
215 DECLARE_OPERATOR(bvugt);
216 DECLARE_OPERATOR(bvsgt);
217 DECLARE_OPERATOR(bvuge);
218 DECLARE_OPERATOR(bvsge);
219 DECLARE_OPERATOR(bvcomp);
220 DECLARE_OPERATOR(bvneg);
221 DECLARE_OPERATOR(bvadd);
222 DECLARE_OPERATOR(bvsub);
223 DECLARE_OPERATOR(bvmul);
224 DECLARE_OPERATOR(bvudiv);
225 DECLARE_OPERATOR(bvsdiv);
226 DECLARE_OPERATOR(bvsmod);
227 DECLARE_OPERATOR(bvurem);
228 DECLARE_OPERATOR(bvsrem);
229 DECLARE_OPERATOR(bvshl);
230 DECLARE_OPERATOR(bvlshr);
231 DECLARE_OPERATOR(bvashr);
232 DECLARE_OPERATOR(extract);
233 DECLARE_OPERATOR(bit2bool);
234 DECLARE_OPERATOR(repeat);
235 DECLARE_OPERATOR(zero_extend);
236 DECLARE_OPERATOR(sign_extend);
237 DECLARE_OPERATOR(rotate_left);
238 DECLARE_OPERATOR(rotate_right);
240 #undef DECLARE_OPERATOR
247 #endif // CHC_INV_IN_H__
virtual SmtTermInfoVlgPtr mk_number(const std::string &rep, int width, int base)
call back function to make a number term
local_vars_lookup_t local_vars_lookup
to hold map for search string -> local variables
Definition: chc_inv_in.h:128
std::map< std::string, int > free_vars_t
the container of all the free variables
Definition: chc_inv_in.h:76
std::function< std::string(const std::string &)> verilog_internal_name_lookup_fn_t
a function to map state name (internal name reference to verilog signal)
Definition: chc_inv_in.h:62
bool bad_state_return(void)
If it is bad state, return true and display a message.
SmtlibInvariantParser & operator=(const SmtlibInvariantParser &)=delete
no assignment
virtual void assert_formula(SmtTermInfoVlgPtr result)
this function receives the final assert result
the class for parsing invariant
Definition: chc_inv_in.h:57
a wrapper of the abstract parser so it is okay to do crazy stuff
Definition: chc_inv_in.h:27
the type of term info that needs to be carried
Definition: chc_inv_in.h:35
virtual SmtTermInfoVlgPtr search_quantified_var_stack(const std::string &name)
find if a certain var is a quantified variable
sort_container_t sort_container
we will allocate in this container
Definition: chc_inv_in.h:116
virtual void define_function(const std::string &func_name, const std::vector< SmtTermInfoVlgPtr > &args, var_type *ret_type, SmtTermInfoVlgPtr func_body)
this function receives the final result
std::map< std::string, SmtTermInfoVerilog > quantifier_temp_def_t
then we need stack for forall infos
Definition: chc_inv_in.h:66
std::map< std::string, std::string > local_vars_lookup_t
search_string to local var name
Definition: chc_inv_in.h:74
const local_vars_t & GetLocalVarDefs() const
get the local variable definitions
this a base class, should not be instantiated
Definition: chc_inv_in_wrapper.h:13
bool _bad_state
bad state
Definition: chc_inv_in.h:146
virtual SmtTermInfoVlgPtr pop_quantifier_scope()
call back function to handle ) of forall
smtlib2_abstract_parser_wrapper * parser_wrapper
the parser interface
Definition: chc_inv_in.h:110
to parse an smt file this will only work on the yosys's generated smt and not on the assembled CHC ...
Definition: yosys_smt_parser.h:22
std::vector< unsigned > quantifier_var_def_idx_stack
the quantifier declare index (order)
Definition: chc_inv_in.h:124
free_vars_t free_vars
to hold the free variables
Definition: chc_inv_in.h:130
virtual SmtTermInfoVlgPtr mk_function(const std::string &name, var_type *sort, const std::vector< int > &idx, const std::vector< SmtTermInfoVlgPtr > &args)
std::map< std::string, var_type > sort_container_t
the sort container
Definition: chc_inv_in.h:70
const bool datatype_flattened
whether we are on a design w. datatype flattened
Definition: chc_inv_in.h:139
the type Bool or (_ BitVec)
Definition: smt_ast.h:82
std::vector< quantifier_temp_def_t > quantifier_def_stack_t
and the stack
Definition: chc_inv_in.h:68
SmtlibInvariantParser * inv_parser
a pointer to allow us to access to the object-oriented part
Definition: chc_inv_in.h:31
unsigned mask
sentry – probably no use
Definition: chc_inv_in.h:120
term_container_t term_container
the term container
Definition: chc_inv_in.h:114
const std::set< std::string > inv_pred_name
a collection of functions that should be treated as inv predicates
Definition: chc_inv_in.h:122
var_type _type
the type uptill now
Definition: chc_inv_in.h:39
local_vars_t local_vars
to hold the local variables
Definition: chc_inv_in.h:126
virtual var_type * make_sort(const std::string &name, const std::vector< int > &)
call back function to create a sort
virtual void declare_function(const std::string &name, var_type *sort)
declare function (useful for Grain)
virtual SmtTermInfoVlgPtr push_quantifier_scope()
call back function to handle (forall
SmtlibInvariantParser * _context
the context – all predefined datatypes/predicates/functions
Definition: chc_inv_in.h:41
T _translate
the corresponding translation (for verilog: std::string)
Definition: chc_inv_in.h:37
std::string GetFinalTranslateResult() const override
get the translate result
const free_vars_t & GetFreeVarDefs() const
get the free variable definitions
const bool no_outside_var_refer
discourage out-of-scope variable referall
Definition: chc_inv_in.h:143
const bool hierarchy_flattened
whether we are on a design w. hierarchy flattened
Definition: chc_inv_in.h:141
YosysSmtParser * design_smt_info_ptr
a pointer to get the knowlege of the context
Definition: chc_inv_in.h:137
virtual void declare_quantified_variable(const std::string &name, var_type *sort)
call back function to create a temporary (quantified variable)
SmtTermInfo(const T &trans, const var_type &p, SmtlibInvariantParser *c)
complete constructor
Definition: chc_inv_in.h:46
smtlib2_abstract_parser parser
this is equivalent to its parent
Definition: chc_inv_in.h:29
std::string final_translate_result
the final translated result
Definition: chc_inv_in.h:132
bool in_bad_state(void) const
check if this module is in a bad state
Definition: chc_inv_in.h:152
std::map< std::string, SmtTermInfoVerilog > term_container_t
the type of container to hold the terms
Definition: chc_inv_in.h:64
std::map< std::string, SmtTermInfoVerilog > local_vars_t
the container of temporary variables
Definition: chc_inv_in.h:72
const std::string dut_verilog_instance_name
we need to store the right vlog instance name
Definition: chc_inv_in.h:134
quantifier_def_stack_t quantifier_def_stack
the temporary def stacks
Definition: chc_inv_in.h:118
SmtTermInfo()
default constructor
Definition: chc_inv_in.h:44