4 #ifndef ILANG_TARGET_SC_ILA_SIM_H__
5 #define ILANG_TARGET_SC_ILA_SIM_H__
15 #define EXTERNAL_MEM 0
55 void sim_gen(std::string export_dir,
bool external_mem =
false,
56 bool readable =
false,
bool qemu_device =
false);
60 void sim_gen_init(std::string export_dir,
bool external_mem,
bool readable,
63 void sim_gen_init_header();
67 void sim_gen_decode();
68 void sim_gen_state_update();
69 void sim_gen_execute_kernel();
70 void sim_gen_execute_invoke();
71 void sim_gen_export();
73 void create_input(
const ExprPtr& input_expr);
74 void create_bool_input(
const ExprPtr& expr);
75 void create_bv_input(
const ExprPtr& expr);
77 void create_state(
const ExprPtr& state_expr);
78 void create_child_state(
const ExprPtr& state_expr);
79 void create_mem_state(
const ExprPtr& expr);
80 void create_bool_state(
const ExprPtr& expr,
bool child =
false);
81 void create_bv_state(
const ExprPtr& expr,
bool child =
false);
82 void create_external_mem_port(
const ExprPtr& expr);
85 void init_decl(std::stringstream& valid_function, std::string& indent,
86 std::string& valid_func_name);
87 void init_check_valid(std::stringstream& init_function, std::string& indent,
89 void init_return(std::stringstream& init_function, std::string& indent);
90 void init_export(std::stringstream& init_function,
91 std::string& init_func_name);
92 void init_mk_file(std::string& init_func_name);
94 void create_decode(
const InstrPtr& instr_expr);
95 void decode_decl(std::stringstream& decode_function, std::string& indent,
96 std::string& decode_func_name);
97 void decode_check_valid(std::stringstream& decode_function,
98 std::string& indent,
const ExprPtr& valid_expr,
100 void decode_return(std::stringstream& decode_function, std::string& indent,
102 void decode_export(std::stringstream& decode_function,
103 std::string& decode_func_name);
104 void decode_mk_file(std::string& decode_func_name);
106 void create_state_update(
const InstrPtr& instr_expr);
107 void state_update_decl(std::stringstream& state_update_function,
108 std::string& indent,
const ExprPtr& updated_state,
110 std::string& state_update_func_name);
111 void state_update_return(std::stringstream& state_update_function,
112 std::string& indent,
const ExprPtr& updated_state,
114 void state_update_export(std::stringstream& state_update_function,
115 std::string& state_update_func_name);
116 void state_update_mk_file(std::string& state_update_func_name);
117 void mem_state_update_decl(std::stringstream& state_update_function,
118 std::string& indent,
const ExprPtr& expr);
120 void execute_init(std::stringstream& execute_kernel, std::string& indent);
121 void execute_parent_instructions(std::stringstream& execute_kernel,
122 std::string& indent);
123 void execute_child_instructions(std::stringstream& execute_kernel,
124 std::string& indent);
125 void execute_instruction(std::stringstream& execute_kernel,
126 std::string& indent,
const InstrPtr& instr_expr,
128 void execute_decode(std::stringstream& execute_kernel, std::string& indent,
130 void execute_state_update_func(std::stringstream& execute_kernel,
134 void execute_update_state(std::stringstream& execute_kernel,
135 std::string& indent,
const InstrPtr& instr_expr,
137 void execute_external_mem_load_begin(std::stringstream& execute_kernel,
140 void execute_external_mem_load_end(std::stringstream& execute_kernel,
141 std::string& indent);
142 void execute_read_external_mem(std::stringstream& execute_kernel,
143 std::string& indent);
144 void execute_write_external_mem(std::stringstream& execute_kernel,
145 std::string& indent);
146 void execute_external_mem_before_input(std::stringstream& execute_kernel,
147 std::string& indent);
148 void execute_external_mem_after_output(std::stringstream& execute_kernel,
149 std::string& indent);
150 void execute_external_mem_return(std::stringstream& execute_kernel,
151 std::string& indent);
152 void execute_read_input(std::stringstream& execute_kernel,
153 std::string& indent);
154 void execute_write_output(std::stringstream& execute_kernel,
155 std::string& indent);
156 void execute_kernel_export(std::stringstream& execute_kernel);
157 void execute_kernel_mk_file();
158 void execute_kernel_header();
160 void dfs_store_op(
const ExprPtr& expr);
161 void dfs_load_from_store(
const ExprPtr& expr);
162 void dfs_int_var_width(
const ExprPtr& expr);
163 void dfs_external_mem_load(
const ExprPtr& expr);
164 void dfs_kernel(std::stringstream& dfs_simulator, std::string& indent,
166 void dfs_uninterpreted_func_decl(
const FuncPtr& func);
167 void dfs_const_node(std::stringstream& dfs_simulator, std::string& indent,
169 void dfs_unary_op(std::stringstream& dfs_simulator, std::string& indent,
171 void dfs_unary_op_check(
const ExprPtr& expr);
172 void dfs_binary_op_bool_out(std::stringstream& dfs_simulator,
173 std::string& indent,
const ExprPtr& expr);
174 void dfs_binary_op_bool_out_check(
const ExprPtr& expr);
175 void dfs_binary_op_non_mem(std::stringstream& dfs_simulator,
176 std::string& indent,
const ExprPtr& expr);
177 void dfs_binary_op_non_mem_check(
const ExprPtr& expr);
178 void dfs_binary_op_mem(std::stringstream& dfs_simulator, std::string& indent,
180 void dfs_extract_op(std::stringstream& dfs_simulator, std::string& indent,
182 void dfs_ext_op(std::stringstream& dfs_simulator, std::string& indent,
184 void dfs_func_op(std::stringstream& dfs_simulator, std::string& indent,
186 void dfs_func_op_check(
const ExprPtr& expr);
187 void dfs_ite_op(std::stringstream& dfs_simulator, std::string& indent,
189 std::string get_type_str(
const ExprPtr& expr);
191 std::string get_arg_str(
const ExprPtr& arg);
192 void increase_indent(std::string& indent);
193 void decrease_indent(std::string& indent);
194 int get_update_state_num(
const InstrPtr& instr_expr);
195 bool load_from_store_analysis(
const ExprPtr& expr);
196 void declare_variable_with_id(
size_t id,
const std::string& v_type,
197 const std::string& v_name);
198 void int_var_width_scan();
201 void generate_cmake_support();
203 std::string export_dir_;
204 std::string systemc_path_;
206 std::stringstream header_;
207 std::stringstream mk_script_;
208 std::stringstream obj_list_;
209 std::string header_indent_;
211 bool cmake_support_ =
false;
212 std::vector<std::string> source_file_list_;
213 std::vector<std::string> header_file_list_;
215 std::set<size_t> searched_id_set_;
216 std::set<size_t> store_ite_set_;
217 std::set<size_t> const_mem_set_;
218 std::set<size_t> declared_id_set_;
219 std::set<std::string> func_set_;
220 std::set<size_t> defined_store_ite_set_;
221 std::set<size_t> defined_state_set_;
222 std::set<int> dfs_ld_search_set_;
223 std::vector<ld_info> external_ld_set_;
224 std::vector<st_info> external_st_set_;
225 int ld_st_counter_ = 0;
226 bool EXTERNAL_MEM_ =
false;
227 const int MEM_MAP_ARRAY_DIV = 16;
228 std::set<int> int_var_width_set_;
234 bool readable_ =
true;
235 bool qemu_device_ =
false;
242 #endif // ILANG_TARGET_SC_ILA_SIM_H__
void enable_cmake_support()
Set to CMake build mode.
Expr::ExprPtr ExprPtr
Pointer type for normal use of Expr.
Definition: expr.h:138
TODO.
Definition: ila_sim.h:37
A class to generate SystemC simulator model from ILA model Example Use:
Definition: ila_sim.h:27
void set_systemc_path(std::string systemc_path)
(To be deprecated) set the path to SystemC library.
Instr::InstrPtr InstrPtr
Pointer type for normal use of Instr.
Definition: instr.h:132
void sim_gen(std::string export_dir, bool external_mem=false, bool readable=false, bool qemu_device=false)
Generate the simulator.
Func::FuncPtr FuncPtr
Pointer type for normal use of Func.
Definition: func.h:83
TODO.
Definition: ila_sim.h:30
InstrLvlAbs::InstrLvlAbsPtr InstrLvlAbsPtr
Pointer type for normal use of InstrLvlAbs.
Definition: instr_lvl_abs.h:326
void set_instr_lvl_abs(const InstrLvlAbsPtr &model_ptr)
Set the target ILA model.
IlaSim()
Default constructor.