Skip to content
Snippets Groups Projects
Commit 493bc565 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Take #reset pragma into account

parents 24455b30 05c1267c
No related branches found
No related tags found
No related merge requests found
Pipeline #9627 failed
(* OASIS_START *) (* OASIS_START *)
(* DO NOT EDIT (digest: 3a2bd6bdb1ae972c49dabc09cbadeb27) *) (* DO NOT EDIT (digest: 309bbc8b0d4bd6d778884c99a792df48) *)
This is the INSTALL file for the lustre-v6 distribution. This is the INSTALL file for the lustre-v6 distribution.
...@@ -15,7 +15,7 @@ In order to compile this package, you will need: ...@@ -15,7 +15,7 @@ In order to compile this package, you will need:
* findlib * findlib
* lutils for executable lv6, executable lv6.dbg * lutils for executable lv6, executable lv6.dbg
* extlib for executable lv6, executable lv6.dbg * extlib for executable lv6, executable lv6.dbg
* rdbg-plugin (>= 1.109) for library lustre-v6 * rdbg-plugin (>= 1.177) for library lustre-v6
Installing Installing
========== ==========
......
...@@ -54,7 +54,7 @@ Library "lustre-v6" ...@@ -54,7 +54,7 @@ Library "lustre-v6"
Modules: Lv6Run Modules: Lv6Run
Path: src/ Path: src/
BuildTools: ocamlbuild BuildTools: ocamlbuild
BuildDepends: str,unix,num,rdbg-plugin (>= 1.109) BuildDepends: str,unix,num,rdbg-plugin (>= 1.177)
Install:true Install:true
XMETAEnable: true XMETAEnable: true
InternalModules: SocExecValue,SocUtils,Lv6util,Lv6version,Lv6errors,Lxm,Lv6MainArgs,Lv6Verbose,Soc2cIdent,Soc,SocPredef,Lv6Id,SocExecDbg,SocExec,SocExecEvalPredef,Lv6Compile,AstTab,AstTabSymbol,AstInstanciateModel,Lv6parserUtils,AstV6,FilenameExtras,LicTab,LicDump,AstPredef,Lic,AstCore,FreshName,IdSolver,EvalConst,LicEvalConst,LicEvalType,UnifyType,Ast2lic,AstV6Dump,EvalClock,UnifyClock,LicEvalClock,EvalType,LicPrg,LicMetaOp,L2lCheckOutputs,Lv6Misc,L2lRmPoly,L2lExpandMetaOp,L2lSplit,L2lExpandNodes,L2lExpandArrays,L2lCheckLoops,L2lCheckMemSafe,L2lOptimIte,Lv6lexer,Lv6parser,AstRecognizePredef,Lic2soc,Action,ActionsDeps,SocVar,TopoSort,SortActions,SortActionsExpe,L2lCheckCKeyWord,L2lCheckKcgKeyWord,L2lWhenOnId,L2lNoWhenNot,L2lRemoveAlias,L2lExpandEnum InternalModules: SocExecValue,SocUtils,Lv6util,Lv6version,Lv6errors,Lxm,Lv6MainArgs,Lv6Verbose,Soc2cIdent,Soc,SocPredef,Lv6Id,SocExecDbg,SocExec,SocExecEvalPredef,Lv6Compile,AstTab,AstTabSymbol,AstInstanciateModel,Lv6parserUtils,AstV6,FilenameExtras,LicTab,LicDump,AstPredef,Lic,AstCore,FreshName,IdSolver,EvalConst,LicEvalConst,LicEvalType,UnifyType,Ast2lic,AstV6Dump,EvalClock,UnifyClock,LicEvalClock,EvalType,LicPrg,LicMetaOp,L2lCheckOutputs,Lv6Misc,L2lRmPoly,L2lExpandMetaOp,L2lSplit,L2lExpandNodes,L2lExpandArrays,L2lCheckLoops,L2lCheckMemSafe,L2lOptimIte,Lv6lexer,Lv6parser,AstRecognizePredef,Lic2soc,Action,ActionsDeps,SocVar,TopoSort,SortActions,SortActionsExpe,L2lCheckCKeyWord,L2lCheckKcgKeyWord,L2lWhenOnId,L2lNoWhenNot,L2lRemoveAlias,L2lExpandEnum
......
No preview for this file type
(* Time-stamp: <modified the 28/03/2018 (at 10:53) by Erwan Jahier> *) (* Time-stamp: <modified the 05/07/2018 (at 15:07) by Erwan Jahier> *)
(*----------------------------------------------------------------------- (*-----------------------------------------------------------------------
** Copyright (C) - Verimag. ** Copyright (C) - Verimag.
*) *)
...@@ -15,10 +15,7 @@ let make_do argv opt = ...@@ -15,10 +15,7 @@ let make_do argv opt =
Lv6Verbose.exe ~level:3 (fun () -> Lv6Verbose.exe ~level:3 (fun () ->
Gc.set { (Gc.get ()) with Gc.verbose = 0x01 } Gc.set { (Gc.get ()) with Gc.verbose = 0x01 }
); );
if (opt.infiles = []) then ( if (opt.infiles = []) then (Lv6MainArgs.usage stderr opt; exit 1);
Lv6MainArgs.usage stderr opt;
exit 1
);
let new_dft_pack = Filename.basename (Filename.chop_extension (List.hd opt.infiles)) in let new_dft_pack = Filename.basename (Filename.chop_extension (List.hd opt.infiles)) in
Lv6Id.set_dft_pack_name new_dft_pack; Lv6Id.set_dft_pack_name new_dft_pack;
...@@ -98,7 +95,8 @@ let make_do argv opt = ...@@ -98,7 +95,8 @@ let make_do argv opt =
(String.concat " " (Array.to_list argv)) Lv6version.str; (String.concat " " (Array.to_list argv)) Lv6version.str;
inputs = vntl_i; inputs = vntl_i;
outputs= vntl_o; outputs= vntl_o;
kill=(fun _ -> ()); reset=(fun () -> ctx_ref := SocExecValue.create_ctx soc_tbl soc);
kill=(fun _ -> if opt.outfile <> "" then (flush opt.oc; close_out opt.oc));
init_inputs=mems_in; init_inputs=mems_in;
init_outputs=mems_out; init_outputs=mems_out;
step=step; step=step;
......
(* Time-stamp: <modified the 28/03/2018 (at 10:55) by Erwan Jahier> *) (* Time-stamp: <modified the 06/07/2018 (at 17:07) by Erwan Jahier> *)
(* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *)
...@@ -247,10 +247,10 @@ let (soc2c : int -> out_channel -> out_channel -> Soc.tbl -> Soc.key -> ...@@ -247,10 +247,10 @@ let (soc2c : int -> out_channel -> out_channel -> Soc.tbl -> Soc.key ->
hfmt "void %s_reset(%s_type* ctx);\n" ctx_name ctx_name; hfmt "void %s_reset(%s_type* ctx);\n" ctx_name ctx_name;
cfmt "void %s_reset(%s_type* ctx){" ctx_name ctx_name; cfmt "void %s_reset(%s_type* ctx){" ctx_name ctx_name;
(* Call the reset_ctx functions of the soc instances *) (* Call the reset_ctx functions of the soc instances *)
if Lv6MainArgs.global_opt.Lv6MainArgs.soc2c_inline_loops then () else if Lv6MainArgs.global_opt.Lv6MainArgs.soc2c_inline_loops
sp.cput "\n int _i;\n"; then () else if soc.instances <> [] then sp.cput "\n int _i;\n";
List.iter (gen_instance_init_call sp) List.iter (gen_instance_init_call sp)
(fst (Soc2cInstances.to_array soc.instances)); (fst (Soc2cInstances.to_array soc.instances));
(match soc.key with (match soc.key with
(* set the parameter fields that have a default value (arrow,fby) *) (* set the parameter fields that have a default value (arrow,fby) *)
| (_,_,MemInit (ve)) -> | (_,_,MemInit (ve)) ->
...@@ -628,27 +628,48 @@ static int ISATTY; ...@@ -628,27 +628,48 @@ static int ISATTY;
/* set this macro for testing output clocks */ /* set this macro for testing output clocks */
#endif #endif
void _read_pragma("^ (
if SocUtils.is_memory_less soc then "" else
ctx^"_type* ctx,"
) ^ "char b[]) {
int s = 1;
if (!strcmp(b,\"#quit\")) exit(0);
if (!strcmp(b,\"#q\")) exit(0);"^
(if SocUtils.is_memory_less soc then "" else "
if (!strcmp(b,\"#reset\")) "^ctx^"_reset(ctx);
")^" return;
}
/* Standard Input procedures **************/ /* Standard Input procedures **************/
_boolean _get_bool(char* n){ _boolean _get_bool("^(
if SocUtils.is_memory_less soc then "" else
ctx^"_type* ctx,"
) ^"char* n){
char b[512]; char b[512];
char c;
_boolean r = 0; _boolean r = 0;
int s = 1; int s = 1;
char c;
do { do {
if(ISATTY) { if(ISATTY) {
if((s != 1)||(r == -1)) printf(\"\\a\"); if((s != 1)||(r == -1)) printf(\"\\a\");
// printf(\"%s (1,t,T/0,f,F) ? \", n); // printf(\"%s (1,t,T/0,f,F) ? \", n);
} }
if(scanf(\"%s\", b)==EOF) exit(0); if(scanf(\"%s\", b)==EOF) exit(0);
if (*b == 'q') exit(0);
s = sscanf(b, \"%c\", &c);
r = -1; r = -1;
c=b[0];
if(c == 'q') exit(0);
if(c == '#') _read_pragma("^
(if SocUtils.is_memory_less soc then "" else "ctx,")^"b);
if((c == '0') || (c == 'f') || (c == 'F')) r = 0; if((c == '0') || (c == 'f') || (c == 'F')) r = 0;
if((c == '1') || (c == 't') || (c == 'T')) r = 1; if((c == '1') || (c == 't') || (c == 'T')) r = 1;
} while((s != 1) || (r == -1)); } while((s != 1) || (r == -1));
return r; return r;
} }
_integer _get_int(char* n){ _integer _get_int("^(
if SocUtils.is_memory_less soc then "" else
ctx^"_type* ctx,"
) ^"char* n){
char b[512]; char b[512];
_integer r; _integer r;
int s = 1; int s = 1;
...@@ -658,13 +679,21 @@ _integer _get_int(char* n){ ...@@ -658,13 +679,21 @@ _integer _get_int(char* n){
//printf(\"%s (integer) ? \", n); //printf(\"%s (integer) ? \", n);
} }
if(scanf(\"%s\", b)==EOF) exit(0); if(scanf(\"%s\", b)==EOF) exit(0);
if (*b == 'q') exit(0); if(*b == 'q') exit(0);
s = sscanf(b, \"%d\", &r); if(*b == '#') {
_read_pragma("^
(if SocUtils.is_memory_less soc then "" else "ctx,")^"b);
} else {
s = sscanf(b, \"%d\", &r);
}
} while(s != 1); } while(s != 1);
return r; return r;
} }
#define REALFORMAT ((sizeof(_real)==8)?\"%lf\":\"%f\") #define REALFORMAT ((sizeof(_real)==8)?\"%lf\":\"%f\")
_real _get_real(char* n){ _real _get_real("^(
if SocUtils.is_memory_less soc then "" else
ctx^"_type* ctx,"
) ^"char* n){
char b[512]; char b[512];
_real r; _real r;
int s = 1; int s = 1;
...@@ -674,8 +703,13 @@ _real _get_real(char* n){ ...@@ -674,8 +703,13 @@ _real _get_real(char* n){
//printf(\"%s (real) ? \", n); //printf(\"%s (real) ? \", n);
} }
if(scanf(\"%s\", b)==EOF) exit(0); if(scanf(\"%s\", b)==EOF) exit(0);
if (*b == 'q') exit(0); if(*b == 'q') exit(0);
s = sscanf(b, REALFORMAT, &r); if(*b == '#') {
_read_pragma("^
(if SocUtils.is_memory_less soc then "" else "ctx,")^"b);
} else {
s = sscanf(b, REALFORMAT, &r);
}
} while(s != 1); } while(s != 1);
return r; return r;
} }
...@@ -740,10 +774,11 @@ int main(){ ...@@ -740,10 +774,11 @@ int main(){
let clk = "" in (* XXX finish me: get the clock if id using soc.clock_profile let clk = "" in (* XXX finish me: get the clock if id using soc.clock_profile
and set this string to something like "if (clk_id)" and set this string to something like "if (clk_id)"
*) *)
let str = let str =
let ctx_opt = if SocUtils.is_memory_less soc then "" else "ctx," in
if io_transmit_mode () = Lv6MainArgs.Stack if io_transmit_mode () = Lv6MainArgs.Stack
then Printf.sprintf " %s %s = _get_%s(\"%s\");\n" clk id t id then Printf.sprintf " %s %s = _get_%s(%s\"%s\");\n" clk id t ctx_opt id
else Printf.sprintf " %s ctx->%s = _get_%s(\"%s\");\n" clk id t id else Printf.sprintf " %s ctx->%s = _get_%s(%s\"%s\");\n" clk id t ctx_opt id
in in
putc str putc str
) )
......
(* Time-stamp: <modified the 06/06/2018 (at 16:33) by Erwan Jahier> *) (* Time-stamp: <modified the 06/07/2018 (at 10:32) by Erwan Jahier> *)
open Soc open Soc
open Data open Data
...@@ -231,20 +231,11 @@ let (add_data_subst : var list -> Data.subst list -> SocExecValue.substs ...@@ -231,20 +231,11 @@ let (add_data_subst : var list -> Data.subst list -> SocExecValue.substs
let rec (read_soc_input : Lv6MainArgs.t -> var list -> Data.vntl -> out_channel -> let rec (read_soc_input : Lv6MainArgs.t -> var list -> Data.vntl -> out_channel ->
substs -> substs) = substs -> substs) =
fun opt vntl_i exp_vntl_i_str oc ctx_s -> fun opt vntl_i exp_vntl_i_str oc ctx_s ->
try
let s:Data.subst list = let s:Data.subst list =
RifIO.read ~debug:(Lv6Verbose.level()>0) stdin RifIO.read ~debug:(Lv6Verbose.level()>0) stdin
(if opt.Lv6MainArgs.rif then None else Some oc) exp_vntl_i_str (if opt.Lv6MainArgs.rif then None else Some oc) exp_vntl_i_str
in in
add_data_subst vntl_i s ctx_s add_data_subst vntl_i s ctx_s
with
| RifIO.Reset ->
RifIO.write oc "\n";
RifIO.flush oc;
Printf.eprintf "The '#reset' pragma is (for the time being) ignored.\n";
flush stderr;
read_soc_input opt vntl_i exp_vntl_i_str oc ctx_s
exception AssertViolation of Lxm.t exception AssertViolation of Lxm.t
let (check_assertions : SocExecValue.ctx -> Lxm.t * Soc.var -> unit) = let (check_assertions : SocExecValue.ctx -> Lxm.t * Soc.var -> unit) =
...@@ -255,11 +246,12 @@ let (check_assertions : SocExecValue.ctx -> Lxm.t * Soc.var -> unit) = ...@@ -255,11 +246,12 @@ let (check_assertions : SocExecValue.ctx -> Lxm.t * Soc.var -> unit) =
| Data.B false -> raise (AssertViolation lxm) | Data.B false -> raise (AssertViolation lxm)
| _ -> assert false (* sno *) | _ -> assert false (* sno *)
let rec (loop_step: Lv6MainArgs.t -> Soc.tbl -> Soc.var list -> Data.vntl -> Data.vntl ->
SocExecValue.ctx -> Data.vntl -> Data.vntl -> Soc.t -> SocExecValue.ctx -> int ->
let rec (loop_step : Lv6MainArgs.t -> Soc.tbl -> Soc.var list -> Data.vntl -> Data.vntl out_channel -> unit) =
-> Soc.t -> SocExecValue.ctx -> int -> out_channel -> unit) = fun opt soc_tbl vntl_i init_exp_vntl_i_str init_exp_vntl_o_str init_ctx
fun opt soc_tbl vntl_i exp_vntl_i_str exp_vntl_o_str soc ctx step_nb oc -> exp_vntl_i_str exp_vntl_o_str soc ctx step_nb oc ->
try
if not opt.Lv6MainArgs.rif then if not opt.Lv6MainArgs.rif then
RifIO.write oc ("\n#step " ^ (string_of_int step_nb)^"\n"); RifIO.write oc ("\n#step " ^ (string_of_int step_nb)^"\n");
let ctx = { ctx with s = read_soc_input opt vntl_i exp_vntl_i_str oc ctx.s } in let ctx = { ctx with s = read_soc_input opt vntl_i exp_vntl_i_str oc ctx.s } in
...@@ -268,13 +260,21 @@ let rec (loop_step : Lv6MainArgs.t -> Soc.tbl -> Soc.var list -> Data.vntl -> Da ...@@ -268,13 +260,21 @@ let rec (loop_step : Lv6MainArgs.t -> Soc.tbl -> Soc.var list -> Data.vntl -> Da
let s = SocExecValue.filter_top_subst ctx.s in let s = SocExecValue.filter_top_subst ctx.s in
let s = List.flatten(List.map SocVar.expand_subst s) in let s = List.flatten(List.map SocVar.expand_subst s) in
let f2s = SocUtils.my_string_of_float_precision opt.Lv6MainArgs.precision in let f2s = SocUtils.my_string_of_float_precision opt.Lv6MainArgs.precision in
let step_nb = step_nb + 1 in
if not opt.Lv6MainArgs.rif then RifIO.write oc " #outs "; if not opt.Lv6MainArgs.rif then RifIO.write oc " #outs ";
RifIO.write_outputs oc f2s exp_vntl_o_str s; RifIO.write_outputs oc f2s exp_vntl_o_str s;
RifIO.write oc "\n"; RifIO.write oc "\n";
RifIO.flush oc; RifIO.flush oc;
Lv6Verbose.exe ~flag:dbg (fun () -> dump_substs ctx.s; flush stdout); Lv6Verbose.exe ~flag:dbg (fun () -> dump_substs ctx.s; flush stdout);
List.iter (check_assertions ctx) soc.assertions; List.iter (check_assertions ctx) soc.assertions;
loop_step opt soc_tbl vntl_i exp_vntl_i_str exp_vntl_o_str soc ctx (step_nb+1) oc loop_step opt soc_tbl vntl_i init_exp_vntl_i_str init_exp_vntl_o_str init_ctx
exp_vntl_i_str exp_vntl_o_str soc ctx step_nb oc
with RifIO.Reset ->
let n,_,_ = soc.key in
Printf.eprintf "\nW: Reseting lustre node %s.\n" n;
flush stderr;
loop_step opt soc_tbl vntl_i init_exp_vntl_i_str init_exp_vntl_o_str init_ctx
init_exp_vntl_i_str init_exp_vntl_o_str soc init_ctx step_nb oc
let (f : Lv6MainArgs.t -> Soc.tbl -> Soc.key -> unit) = let (f : Lv6MainArgs.t -> Soc.tbl -> Soc.key -> unit) =
fun opt soc_tbl sk -> fun opt soc_tbl sk ->
...@@ -293,10 +293,10 @@ let (f : Lv6MainArgs.t -> Soc.tbl -> Soc.key -> unit) = ...@@ -293,10 +293,10 @@ let (f : Lv6MainArgs.t -> Soc.tbl -> Soc.key -> unit) =
LicDump.dump_entete oc; LicDump.dump_entete oc;
RifIO.write_interface oc exp_vntl_i exp_vntl_o None None; RifIO.write_interface oc exp_vntl_i exp_vntl_o None None;
RifIO.flush oc; RifIO.flush oc;
try loop_step opt soc_tbl (fst soc.profile) exp_vntl_i exp_vntl_o soc ctx 1 oc try
with loop_step opt soc_tbl (fst soc.profile)
| RifIO.Bye -> close_out oc exp_vntl_i exp_vntl_o ctx exp_vntl_i exp_vntl_o soc ctx 1 oc
with RifIO.Bye -> close_out oc
(**************************************************************************************) (**************************************************************************************)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment