14 #ifndef ILANG_VTARGET_OUT_VTARGET_GEN_IMPL_H__
15 #define ILANG_VTARGET_OUT_VTARGET_GEN_IMPL_H__
19 #include <unordered_map>
22 #include "nlohmann/json.hpp"
25 #include <ilang/smt-inout/yosys_smt_parser.h>
26 #include <ilang/verilog-in/verilog_analysis_wrapper.h>
28 #include <ilang/vtarget-out/directive.h>
29 #include <ilang/vtarget-out/supplementary_info.h>
30 #include <ilang/vtarget-out/var_extract.h>
31 #include <ilang/vtarget-out/vtarget_gen.h>
40 typedef enum { INVARIANTS, INSTRUCTIONS, INV_SYN_DESIGN_ONLY }
target_type_t;
76 const std::string& output_path,
83 VerilogInfo* _vlg_info_ptr,
const std::string& vlg_mod_inst_name,
84 const std::string& ila_mod_inst_name,
const std::string& wrapper_name,
85 const std::vector<std::string>& implementation_srcs,
86 const std::vector<std::string>& implementation_include_path,
155 unsigned mapping_counter;
157 unsigned property_counter;
170 std::pair<unsigned, unsigned>
172 GetMemInfo(
const std::string& ila_mem_name)
const;
190 std::string
ReplExpr(
const std::string& expr,
bool force_vlg_sts =
false);
192 std::string
PerStateMap(
const std::string& ila_state_name_or_equ,
193 const std::string& vlg_st_name);
202 nlohmann::json& m,
bool is_assert =
false);
248 nlohmann::json& pv_cond_val,
const std::string& pv_name,
int width,
305 void virtual Export_script(
const std::string& script_name) = 0;
308 const std::string& extra_name) = 0;
312 void virtual Export_mem(
const std::string& mem_name) = 0;
316 void virtual ExportAll(
const std::string& wrapper_name,
317 const std::string& ila_vlg_name,
318 const std::string& script_name,
319 const std::string& extra_name,
320 const std::string& mem_name);
326 const std::string& dspt) = 0;
329 const std::string& dspt) = 0;
334 const std::string& dspt);
337 const std::string& dspt);
342 const std::string& expression,
343 const std::string& dspt);
347 const std::string& expression,
348 int width,
const std::string& cond,
349 const std::string& dspt);
353 virtual void do_not_instantiate(
void) = 0;
396 VlgVerifTgtGen(
const std::vector<std::string>& implementation_include_path,
397 const std::vector<std::string>& implementation_srcs,
398 const std::string& implementation_top_module,
399 const std::string& refinement_variable_mapping,
400 const std::string& refinement_conditions,
468 #ifdef INVSYN_INTERFACE
469 void GenerateInvSynTargetsAbc(
bool useGla,
bool useCorr,
bool useAiger);
472 std::shared_ptr<smt::YosysSmtParser>
475 std::shared_ptr<smt::YosysSmtParser>
476 GenerateInvSynEnhanceTargets(
const InvariantInCnf& cnf);
478 std::shared_ptr<smt::YosysSmtParser> GenerateSmtTargets();
494 void load_json(
const std::string& fname, nlohmann::json& j);
502 virtual void do_not_instantiate()
override {}
508 #endif // ILANG_VTARGET_OUT_VTARGET_GEN_IMPL_H__
const std::vector< std::string > _vlg_impl_include_path
implementation include path
Definition: vtarget_gen_impl.h:419
ExprPtr TryFindIlaVarName(const std::string &sname)
Try to find a ILA var according to a name.
VerilogGenerator vlg_ila
Generator for the ila verilog.
Definition: vtarget_gen_impl.h:111
void ConstructWrapper_add_vlg_input_output()
add the vlg input ouput to the wrapper I/O
std::string ConstructWrapper_get_ila_module_inst()
get the ila module instantiation string
void ConstructWrapper_add_vlg_monitor()
Add Verilog inline monitor.
std::vector< std::string > runnable_script_name
to store the generate script name
Definition: vtarget_gen_impl.h:448
void add_rf_inv_as_assertion()
add rf inv as assumptions (if there are)
advanced_parameters_t * _advanced_param_ptr
to store the advanced parameter configurations
Definition: vtarget_gen_impl.h:446
Used in Verilog Verification Target Generation for dealing with interface directives.
Definition: directive.h:28
bool in_bad_state(void) const
Return true if it is in bad state.
Definition: vtarget_gen_impl.h:464
void ConstructWrapper_add_rf_assumptions()
Add more assumptions for I/O for example (both instruction/invariant)
void ConstructWrapper_add_uf_constraints()
Add buffers and assumption/assertions about the.
VlgTgtSupplementaryInfo supplementary_info
The supplementary information.
Definition: vtarget_gen_impl.h:456
virtual void add_an_assertion(const std::string &asst, const std::string &dspt)
Add an assertion – JasperGold will override this.
const VlgTgtSupplementaryInfo & supplementary_info
The supplementary information.
Definition: vtarget_gen_impl.h:129
backend_selector _backend
Store the selection of backend.
Definition: vtarget_gen_impl.h:292
int ConstructWrapper_add_post_value_holder_handle_obj(nlohmann::json &pv_cond_val, const std::string &pv_name, int width, bool create_reg)
A sub function of the above post-value-holder hanlder.
const bool has_rf_invariant
has rf provided invariant
Definition: vtarget_gen_impl.h:151
target_type_t target_type
target type
Definition: vtarget_gen_impl.h:133
Class of Verilog Generator.
Definition: verilog_gen.h:373
virtual void add_a_direct_assertion(const std::string &asst, const std::string &dspt)=0
Add an assertion.
virtual void Export_mem(const std::string &mem_name)=0
const bool has_gussed_synthesized_invariant
has guessed synthesized invariant
Definition: vtarget_gen_impl.h:147
VerilogInfo * vlg_info_ptr
Analyzer for the implementation.
Definition: vtarget_gen_impl.h:119
void add_rf_inv_as_assumption()
add rf inv as assumptions (if there are)
StateMappingDirectiveRecorder _sdr
state directive recorder
Definition: vtarget_gen_impl.h:115
void add_inv_obj_as_assumption(InvariantObject *inv_obj)
add an invariant object as an assumption
std::string PerStateMap(const std::string &ila_state_name_or_equ, const std::string &vlg_st_name)
handle a single string map (s-name/equ-string)
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
std::pair< unsigned, unsigned > GetMemInfo(const std::string &ila_mem_name) const
Get (a,d) width of a memory, if not existing, (0,0)
nlohmann::json rf_vmap
store the vmap info
Definition: vtarget_gen_impl.h:452
advanced_parameters_t * _advanced_param_ptr
to store the advanced parameter configurations
Definition: vtarget_gen_impl.h:145
InstrPtr _instr_ptr
The pointer to the instruction that is going to export.
Definition: vtarget_gen_impl.h:100
const std::string _vlg_impl_top_name
implementation top module name
Definition: vtarget_gen_impl.h:423
void ConstructWrapper_add_inv_assumption_or_assertion_target_instruction()
Add invariants as assumption/assertion when target is instruction.
void ConstructWrapper_add_varmap_assumptions()
add state equ assumptions
void ConstructWrapper_add_additional_mapping_control()
Add more assumptions for mapping (only use for instruction target)
bool TryFindVlgState(const std::string &sname)
Test if a string represents a Verilog signal name.
virtual void add_wire_assign_assumption(const std::string &varname, const std::string &expression, const std::string &dspt)
ready_type_t ready_type
ready type
Definition: vtarget_gen_impl.h:137
virtual void add_an_assumption(const std::string &aspt, const std::string &dspt)
Add an assumption – JasperGold will override this.
const VerilogGenerator::VlgGenConfig & _vlg_cfg
Store the vlg configurations.
Definition: vtarget_gen_impl.h:290
void ConstructWrapper_reset_setup()
setup reset, add assumptions if necessary
virtual void Export_problem(const std::string &extra_name)=0
export extra things (problem)
void ConstructWrapper_inv_syn_cond_signals()
const InstrLvlAbsPtr & _ila_ptr
The pointer to the instruction that is going to export.
Definition: vtarget_gen_impl.h:432
virtual void add_reg_cassign_assumption(const std::string &varname, const std::string &expression, int width, const std::string &cond, const std::string &dspt)
std::vector< std::string > vlg_include_files_path
include paths
Definition: vtarget_gen_impl.h:286
struct ilang::VlgVerifTgtGenBase::_adv_parameters advanced_parameters_t
const std::string _vlg_mod_inst_name
The name of verilog top module instance in the wrapper.
Definition: vtarget_gen_impl.h:104
void ConstructWrapper_add_inv_assumption_or_assertion_target_inv_syn_design_only()
Add invariants as assumption/assertion when target is inv_syn_design_only.
Definition: vtarget_gen.h:22
void handle_start_condition(nlohmann::json &dc)
add a start condition if it is given
const std::string _output_path
Definition: vtarget_gen_impl.h:98
virtual void Export_modify_verilog()=0
For jasper, this means do nothing, for yosys, you need to add (keep)
the invariant object, it needs smt-info to parse
Definition: inv_obj.h:23
std::vector< std::string > vlg_design_files
design files
Definition: vtarget_gen_impl.h:284
void ConstructWrapper_add_inv_assumption_or_assertion_target_invariant()
Add invariants as assumption/assertion when target is invariant.
unsigned max_bound
max bound , default 127
Definition: vtarget_gen_impl.h:141
VlgSglTgtGen(const std::string &output_path, const InstrPtr &instr_ptr, const InstrLvlAbsPtr &ila_ptr, const VerilogGenerator::VlgGenConfig &config, nlohmann::json &_rf_vmap, nlohmann::json &_rf_cond, VlgTgtSupplementaryInfo &_supplementary_info, VerilogInfo *_vlg_info_ptr, const std::string &vlg_mod_inst_name, const std::string &ila_mod_inst_name, const std::string &wrapper_name, const std::vector< std::string > &implementation_srcs, const std::vector< std::string > &implementation_include_path, const vtg_config_t &vtg_config, backend_selector backend, const target_type_t &target_tp, advanced_parameters_t *adv_ptr)
backend_selector _backend
to store the backend
Definition: vtarget_gen_impl.h:440
bool TryFindIlaState(const std::string &sname)
Test if a string represents an ila state name.
const std::string _ila_mod_inst_name
The name of ila-verilog top module instance in the wrapper.
Definition: vtarget_gen_impl.h:106
std::string GetVlgModuleInstanceName() const
get vlg-module instance name
Definition: vtarget_gen_impl.h:466
unsigned cnt_width
the width of the counter
Definition: vtarget_gen_impl.h:143
const std::vector< std::string > _vlg_impl_srcs
implementatino path
Definition: vtarget_gen_impl.h:421
void GenerateTargets(void)
Generate everything.
IntefaceDirectiveRecorder _idr
inteface directive recorder
Definition: vtarget_gen_impl.h:113
bool has_flush
a shortcut of whether rf has flush condition set
Definition: vtarget_gen_impl.h:135
std::string GetStateVarMapExpr(const std::string &ila_state_name, nlohmann::json &m, bool is_assert=false)
void ConstructWrapper_add_condition_signals()
Generate ISSUE, IEND, ... signals.
backend_selector
Definition: vtarget_gen.h:31
virtual void ConstructWrapper()
bool bad_state_return(void)
If it is bad state, return true and display a message.
virtual void Export_ila_vlg(const std::string &ila_vlg_name)
export the ila verilog
nlohmann::json & rf_vmap
refinement relation variable mapping
Definition: vtarget_gen_impl.h:123
Instr::InstrPtr InstrPtr
Pointer type for normal use of Instr.
Definition: instr.h:132
the structure to configure the verilog generator
Definition: verilog_gen.h:150
const ExprPtr IlaGetState(const std::string &sname) const
Get the pointer of a ila state, it must exist.
virtual void Export_wrapper(const std::string &wrapper_name)
create the wrapper file
std::string top_file_name
top verilog module file
Definition: vtarget_gen_impl.h:280
const std::vector< std::string > & GetRunnableScriptName() const
generate the runable script name
struct ilang::VlgVerifTgtGenBase::_vtg_config vtg_config_t
Verilog Target Generation Configuration.
nlohmann::json & rf_cond
refinement relation instruction conditions
Definition: vtarget_gen_impl.h:125
const VlgTgtSupplementaryInfo & GetSupplementaryInfo() const
return the result from parsing supplymentary information
std::string ModifyCondExprAndRecordVlgName(const VarExtractor::token &t)
Modify a token and record its use.
nlohmann::json empty_json
An empty json for default fallthrough cases.
Definition: vtarget_gen_impl.h:127
target_type_t
Type of the target.
Definition: vtarget_gen_impl.h:40
vtg_config_t _vtg_config
to store the configuration
Definition: vtarget_gen_impl.h:444
Generating a target (just the invairant or for an instruction)
Definition: vtarget_gen_impl.h:36
the class to hold supplementary information
Definition: supplementary_info.h:16
void ConstructWrapper_inv_syn_connect_mem()
Connect the memory even we don't care a lot about them.
std::map< std::string, unsigned > func_app_cnt_t
Per func apply counter.
Definition: vtarget_gen_impl.h:49
void ConstructWrapper_add_helper_memory()
void ConstructWrapper_add_cycle_count_moniter()
add a cycle counter to be used to deal with the end cycle
const ExprPtr IlaGetInput(const std::string &sname) const
Get the pointer of an ila input, it must exist.
void ConstructWrapper_register_extra_io_wire()
Register the extra wires to the idr.
void ConstructWrapper_add_varmap_assertions()
add state equ assertions
void ConstructWrapper_generate_header()
generate the `define TRUE 1
const bool has_confirmed_synthesized_invariant
has confirmed synthesized invariant
Definition: vtarget_gen_impl.h:149
ready_type_t
Type of the ready condition.
Definition: vtarget_gen_impl.h:42
std::string _vlg_mod_inst_name
The name of verilog top module instance in the wrapper.
Definition: vtarget_gen_impl.h:434
void load_json(const std::string &fname, nlohmann::json &j)
load json from a file name to the given j
InstrLvlAbs::InstrLvlAbsPtr InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:326
VerilogInfo * vlg_info_ptr
A pointer to create verilog analyzer.
Definition: vtarget_gen_impl.h:438
vtg_config_t _vtg_config
Store the configuration.
Definition: vtarget_gen_impl.h:288
std::string ila_file_name
top verilog module file
Definition: vtarget_gen_impl.h:282
void ConstructWrapper_add_ila_input()
add ila input to the wrapper
Class to hold signal info.
Definition: verilog_analysis_wrapper.h:112
std::string new_property_id()
Return a new variable name for property.
static unsigned get_width(const ExprPtr &n)
get width of an ila node
virtual ~VlgSglTgtGen()
Destructor: do nothing , most importantly it is virtual.
Definition: vtarget_gen_impl.h:91
_chc_target_t
Type of the chc target.
Definition: vtarget_gen.h:53
InstrLvlAbsPtr _host
The pointer to the host ila.
Definition: vtarget_gen_impl.h:102
VerilogGeneratorBase vlg_wrapper
Generator for the wrapper module.
Definition: vtarget_gen_impl.h:109
VerilogGenerator::VlgGenConfig _cfg
to store the verilog configuration
Definition: vtarget_gen_impl.h:442
Base class of VerilogGenerator.
Definition: verilog_gen.h:31
std::string top_mod_name
top verilog module name
Definition: vtarget_gen_impl.h:278
bool bad_state_return(void)
subroutine for generating synthesis using chc targets
std::string _ila_mod_inst_name
The name of ila-verilog top module instance in the wrapper.
Definition: vtarget_gen_impl.h:436
virtual void add_a_direct_assumption(const std::string &aspt, const std::string &dspt)=0
Add an assumption – backend dependent.
VlgVerifTgtGen(const std::vector< std::string > &implementation_include_path, const std::vector< std::string > &implementation_srcs, const std::string &implementation_top_module, const std::string &refinement_variable_mapping, const std::string &refinement_conditions, const std::string &output_path, const InstrLvlAbsPtr &ila_ptr, backend_selector backend, const vtg_config_t &vtg_config, const VerilogGenerator::VlgGenConfig &config=VerilogGenerator::VlgGenConfig(), advanced_parameters_t *adv_ptr=NULL)
func_app_cnt_t func_cnt
func apply counter
Definition: vtarget_gen_impl.h:139
virtual void PreExportProcess()=0
PreExportWork (modification and etc.)
virtual void Export_script(const std::string &script_name)=0
export the script to run the verification
const std::string _output_path
Definition: vtarget_gen_impl.h:430
synthesis_backend_selector
Type of invariant synthesis backend.
Definition: vtarget_gen.h:45
void set_module_instantiation_name()
Get instance name from rfmap.
bool in_bad_state(void) const
check if this module is in a bad state
Definition: vtarget_gen_impl.h:358
bool TryFindIlaInput(const std::string &sname)
Test if a string represents an ila input name.
nlohmann::json & get_current_instruction_rf()
Find the current instruction-mapping.
Definition: vtarget_gen_impl.h:372
void ConstructWrapper_add_post_value_holder()
Add post value holder (val @ cond == ...)
The class that invoke the analyzer.
Definition: verilog_analysis_wrapper.h:173
Verilog Target Generation Configuration.
Definition: vtarget_gen.h:55
std::map< std::string, ex_info_t > _all_referred_vlg_names
record all the referred vlg names, so you can add (keep) if needed
Definition: vtarget_gen_impl.h:131
const std::string _rf_cond_name
refinement relation - condition path
Definition: vtarget_gen_impl.h:427
std::string new_mapping_id()
Return a new variable name for mapping.
VlgVerifTgtGenBase: do nothing, should not instantiate.
Definition: vtarget_gen.h:17
static unsigned TypeMatched(const ExprPtr &ila_var, const SignalInfoBase &vlg_var)
VarExtractor _vext
variable extractor to handle property expressions
Definition: vtarget_gen_impl.h:121
std::string ReplExpr(const std::string &expr, bool force_vlg_sts=false)
Parse and modify a condition string.
virtual void ExportAll(const std::string &wrapper_name, const std::string &ila_vlg_name, const std::string &script_name, const std::string &extra_name, const std::string &mem_name)
Take care of exporting all of a single target.
Definition: vtarget_gen.h:275
VlgVerifTgtGen & operator=(const VlgVerifTgtGen &)=delete
no assignment, please. I don't want to mess up w. vlg_info_ptr
nlohmann::json rf_cond
store the condition
Definition: vtarget_gen_impl.h:454
void add_inv_obj_as_assertion(InvariantObject *inv_obj)
add an invariant object as assertion
virtual ~VlgVerifTgtGen()
release verilog info pointer
const std::string _rf_var_map_name
refinement relation - variable mapping path
Definition: vtarget_gen_impl.h:425
void ConstructWrapper_add_module_instantiation()
Add instantiation statement of the two modules.
a class to handle state-mapping directives in the refinement relations
Definition: directive.h:164