Revision 6eeafd52
src/plugins/scopes/scopes.ml | ||
---|---|---|
33 | 33 |
List.find (fun m -> m.mname.node_id = name) machines |
34 | 34 |
with Not_found -> raise Not_found |
35 | 35 |
|
36 |
let rec compute_scopes prog main_node : scope_t list = |
|
37 | 36 |
|
37 |
let rec compute_scopes ?(first=true) prog root_node : scope_t list = |
|
38 |
let compute_scopes = compute_scopes ~first:false in |
|
38 | 39 |
(* Format.eprintf "Compute scope of %s@." main_node; *) |
39 | 40 |
try |
40 |
let node = get_node main_node prog in
|
|
41 |
let node = get_node root_node prog in
|
|
41 | 42 |
let all_vars = node.node_inputs @ node.node_locals @ node.node_outputs in |
42 |
let local_vars = node.node_inputs @ node.node_locals in |
|
43 |
let local_vars = if first then |
|
44 |
node.node_locals |
|
45 |
else |
|
46 |
node.node_inputs @ node.node_locals in |
|
43 | 47 |
let local_scopes = List.map (fun x -> [], x) local_vars in |
44 | 48 |
let sub_scopes = |
45 | 49 |
let sub_nodes = |
... | ... | |
164 | 168 |
let option_show_scopes = ref false |
165 | 169 |
let option_scopes = ref false |
166 | 170 |
let option_all_scopes = ref false |
167 |
let option_mem_scopes = ref false
|
|
168 |
let option_input_scopes = ref false
|
|
171 |
(* let option_mems_scopes = ref false
|
|
172 |
* let option_input_scopes = ref false *)
|
|
169 | 173 |
|
170 | 174 |
let scopes_map : (Lustre_types.ident list * scope_t) list ref = ref [] |
171 | 175 |
|
... | ... | |
218 | 222 |
(fun fmt -> C_backend_common.print_put_var fmt ("_scopes_" ^ string_of_int (idx+1)) id (*var*) typ var) |
219 | 223 |
) scopes_vars |
220 | 224 |
|
221 |
let update_machine machine = |
|
225 |
let update_machine main_node machine =
|
|
222 | 226 |
let stateassign vdecl = |
223 | 227 |
mkinstr |
224 | 228 |
(MStateAssign (vdecl, mk_val (Var vdecl) vdecl.var_type)) |
225 | 229 |
in |
226 |
let local_decls = machine.mstep.step_inputs |
|
230 |
let local_decls = |
|
231 |
(* We only register inputs for non root node *) |
|
232 |
(if machine.mname.node_id = main_node then |
|
233 |
[] |
|
234 |
else |
|
235 |
machine.mstep.step_inputs |
|
236 |
) |
|
227 | 237 |
(* @ machine.mstep.step_outputs *) |
228 | 238 |
@ machine.mstep.step_locals |
229 | 239 |
in |
... | ... | |
246 | 256 |
struct |
247 | 257 |
let name = "scopes" |
248 | 258 |
let is_active () = |
249 |
!option_scopes || !option_show_scopes || !option_all_scopes || !option_mem_scopes || !option_input_scopes |
|
259 |
!option_scopes || !option_show_scopes || !option_all_scopes |
|
260 |
(* || !option_mem_scopes || !option_input_scopes *) |
|
250 | 261 |
|
251 | 262 |
let show_scopes () = |
252 | 263 |
!option_show_scopes && ( |
... | ... | |
258 | 269 |
"-input", Arg.String register_inputs, "specifies the simulation input"; |
259 | 270 |
"-show-possible-scopes", Arg.Set option_show_scopes, "list possible variables to log"; |
260 | 271 |
"-select-all", Arg.Set option_all_scopes, "select all possible variables to log"; |
261 |
"-select-mem", Arg.Set option_mem_scopes, "select all memory variables to log";
|
|
262 |
"-select-inputs", Arg.Set option_input_scopes, "select all input variables to log";
|
|
272 |
(* "-select-mems", Arg.Set option_mems_scopes, "select all memory variables to log";
|
|
273 |
* "-select-inputs", Arg.Set option_input_scopes, "select all input variables to log"; *)
|
|
263 | 274 |
] |
264 | 275 |
|
265 | 276 |
let activate () = |
... | ... | |
323 | 334 |
in |
324 | 335 |
scopes_map := check_scopes main_node prog machines all_scopes selected_scopes; |
325 | 336 |
(* Each machine is updated with fresh memories and declared as stateful *) |
326 |
let machines = List.map update_machine machines in
|
|
337 |
let machines = List.map (update_machine main_node) machines in
|
|
327 | 338 |
machines |
328 | 339 |
|
329 | 340 |
(* let pp fmt = pp_scopes fmt !scopes_map *) |
Also available in: Unified diff