From 92ab9e5369c5ae0687c7d65d7e61b3e3f994c3c9 Mon Sep 17 00:00:00 2001 From: Erwan Jahier <jahier@imag.fr> Date: Fri, 5 Dec 2008 09:53:15 +0100 Subject: [PATCH] Use V4 style clocks when using the --lustre-v4 option + more work on the release dir. --- release-lv6/Makefile | 13 +- release-lv6/rel-skel/test/Makefile | 45 +++++- src/licDump.ml | 52 +++---- src/test/should_work/Pascal/consensus2.lus | 3 +- src/test/should_work/packEnvTest/complex.lus | 6 +- src/test/test.res.exp | 136 +++++++++---------- 6 files changed, 148 insertions(+), 107 deletions(-) diff --git a/release-lv6/Makefile b/release-lv6/Makefile index 9c3027c5..59575144 100644 --- a/release-lv6/Makefile +++ b/release-lv6/Makefile @@ -2,10 +2,10 @@ RELNAME_PREFIX=lv6-alpha- RELNAME=$(RELNAME_PREFIX)$(shell date +%d-%m-%y)-$(shell uname) LUS2LICDIR=~/lus2lic -LIC2LOCDIR=~/lic2loc +LIC2CDIR=~/lic2loc -all: dir doc lus2lic lic2loc test_files +all: dir doc lus2lic lic2c test_files dir: rm -rf $(RELNAME) && mkdir $(RELNAME) @@ -13,17 +13,18 @@ dir: doc: cp $(LUS2LICDIR)/lv6-ref-man/lv6-ref-man.pdf $(RELNAME)/doc - + cp ~/slides/lv6/*.pdf $(RELNAME)/doc lus2lic: cp $(LUS2LICDIR)/src/lus2lic $(RELNAME)/bin/ -lic2loc: - cp $(LIC2LOCDIR)/src/compiler $(RELNAME)/bin/lic2loc +lic2c: + cp $(LIC2CDIR)/src/lic2c $(RELNAME)/bin/ test_files: for f in $(shell find $(LUS2LICDIR)/src/test/should_work -name \*.lus); do \ $(RELNAME)/bin/lus2lic $$f -o /tmp/xx.lus && \ + $(RELNAME)/bin/lic2c --out-format loc /tmp/xx.lus > /dev/null && \ echo "cp $$f $(RELNAME)/test/" && \ cp $$f $(RELNAME)/test/; \ done @@ -36,4 +37,4 @@ www: $(RELNAME).tgz clean: - rm -rf $(RELNAME_PREFIX)* \ No newline at end of file + rm -rf $(RELNAME_PREFIX)*-* \ No newline at end of file diff --git a/release-lv6/rel-skel/test/Makefile b/release-lv6/rel-skel/test/Makefile index e8676734..b3abb6a3 100644 --- a/release-lv6/rel-skel/test/Makefile +++ b/release-lv6/rel-skel/test/Makefile @@ -1,9 +1,46 @@ -LICDIR=lic +test: lic loc c -test: +# T(ry to t)ranslate all lustre files into lic +lic: for f in $(shell ls *.lus); do \ - echo "../bin/lus2lic $$f -o lic/$$f"; \ - ../bin/lus2lic $$f -o lic/$$f; \ + cmd="../bin/lus2lic $$f -o lic/$$f"; \ + echo $$cmd;\ + $$cmd;\ done + +# Ditto with loc +loc: + for f in $(shell ls *.lus); do \ + basename=`basename $$f .lus`; \ + echo "../bin/lic2c --out-format loc lic/$$f > loc/$$basename.loc"; \ + ../bin/lic2c --out-format loc lic/$$f > loc/$$basename.loc; \ + done + +# Ditto with c +c: + cd c ; \ + for f in $(shell ls *.lus); do \ + cmd="../../bin/lic2c ../lic/$$f"; \ + echo $$cmd;\ + $$cmd;\ + done + +# Ditto with the Lustre V4 syntax +lv4: + for f in $(shell ls *.lus); do \ + basename=`basename $$f .lus`; \ + cmd="mkdir -p lv4/$$basename" ;\ + echo "$$cmd" ; \ + $$cmd ;\ + cmd="../bin/lus2lic --lustre-v4 $$f -o lv4/$$basename/$$f"; \ + echo "$$cmd" ; \ + $$cmd ;\ + nodename="$$basename"__"$$basename";\ + cmd="lus2ec lv4/$$basename/$$f $$nodename -o lv4/ec/$$basename.ec"; \ + echo "$$cmd" ; \ + $$cmd ;\ + done + +.PHONY: lv4 c loc lic test diff --git a/src/licDump.ml b/src/licDump.ml index 162ecb7c..2627c469 100644 --- a/src/licDump.ml +++ b/src/licDump.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 28/11/2008 (at 15:17) by Erwan Jahier> *) +(** Time-stamp: <modified the 01/12/2008 (at 15:47) by Erwan Jahier> *) open Printf open Lxm @@ -324,7 +324,7 @@ and (type_string_of_var_info_eff: Eff.var_info -> string) = and string_of_decl var_info_eff = (Ident.to_string var_info_eff.var_name_eff) ^ ":" ^ (string_of_type_eff var_info_eff.var_type_eff) ^ - (string_of_clock_decl (snd var_info_eff.var_clock_eff)) + (string_of_clock (snd var_info_eff.var_clock_eff)) and (string_of_type_decl_list : Eff.var_info list -> string -> string) = fun tel sep -> @@ -412,7 +412,7 @@ and (string_of_by_pos_op_eff: Eff.by_pos_op srcflagged -> Eff.val_exp list -> st (string_of_val_exp_eff ve1) ^ " -> pre " ^ (string_of_val_exp_eff ve2) else (string_of_val_exp_eff ve1) ^ " fby " ^ (string_of_val_exp_eff ve2) - | WHEN clk, vel -> (tuple vel) ^ " when " ^ (string_of_clock_exp clk) + | WHEN clk, vel -> (tuple vel) ^ (string_of_clock_exp clk) | CURRENT,_ -> "current " ^ (tuple vel) | TUPLE,_ -> (tuple vel) | WITH(ve),_ -> (string_of_val_exp_eff ve) @@ -488,11 +488,6 @@ and string_of_val_exp_eff = function "}" -and string_of_clock_exp = function - | SyntaxTreeCore.Base -> "base" - | SyntaxTreeCore.NamedClock clk -> Ident.string_of_clk clk.it - - and wrap_long_line str = if String.length str < 75 then str else let str_list = Str.split (Str.regexp " ") str in @@ -605,33 +600,42 @@ and (node_of_node_exp_eff: Eff.node_exp -> string) = ) +and (string_of_clock_exp : SyntaxTreeCore.clock_exp -> string) = + function + | SyntaxTreeCore.Base -> "" + | SyntaxTreeCore.NamedClock clk -> + " when " ^ (string_of_ident_clk clk.it) + +and (string_of_ident_clk : Ident.clk -> string) = + fun clk -> + let (cc,v) = clk in + let clk_exp_str = +(* if !Global.lv4 then *) + match Ident.string_of_idref cc with + | "True" -> (Ident.to_string v) + | "False" -> "not " ^ (Ident.to_string v) + | _ -> Ident.string_of_clk clk +(* else *) +(* Ident.string_of_clk clk *) + in + clk_exp_str + + (* exported *) and string_of_clock2 (ck : Eff.clock) = match ck with | BaseEff -> " on base" | On(clk_exp,ceff) -> - let (cc,v) = clk_exp in - let clk_exp_str = - match Ident.string_of_idref cc with - | "True" -> (Ident.to_string v) - | "False" -> " not " ^ (Ident.to_string v) - | _ -> Ident.string_of_clk clk_exp - in + let clk_exp_str = string_of_ident_clk clk_exp in " on " ^ clk_exp_str ^ (string_of_clock2 ceff) | ClockVar i -> "'a" ^ string_of_int i -and string_of_clock_decl (ck : Eff.clock) = +and string_of_clock (ck : Eff.clock) = match ck with | BaseEff -> "" - | On(clk_exp,_) -> - let (cc,v) = clk_exp in - let clk_exp_str = - match Ident.string_of_idref cc with - | "True" -> (Ident.to_string v) - | "False" -> "not " ^ (Ident.to_string v) - | _ -> Ident.string_of_clk clk_exp - in + | On(clk_exp,_) -> + let clk_exp_str = string_of_ident_clk clk_exp in " when " ^ clk_exp_str | ClockVar _ -> assert false (* | ClockVar i -> "_clock_var_" ^ (string_of_int i) *) diff --git a/src/test/should_work/Pascal/consensus2.lus b/src/test/should_work/Pascal/consensus2.lus index e01b44c6..5d15c9fa 100644 --- a/src/test/should_work/Pascal/consensus2.lus +++ b/src/test/should_work/Pascal/consensus2.lus @@ -1,8 +1,7 @@ node consensus<<const n : int>>(T: bool^n) returns (a: bool); let - a = with (n = 1) - then T[0] + a = with (n = 1) then T[0] else T[0] and consensus << n-1 >> (T[1 .. n-1]); tel diff --git a/src/test/should_work/packEnvTest/complex.lus b/src/test/should_work/packEnvTest/complex.lus index 6bf23715..552c5d67 100644 --- a/src/test/should_work/packEnvTest/complex.lus +++ b/src/test/should_work/packEnvTest/complex.lus @@ -1,11 +1,11 @@ -package complex -- uses trigo, math, ... ; +package complex provides type t; -- Encapsulation const i:t; - function re(c: t) returns (r:real); --- + node re(c: t) returns (r:real); --- body type t = struct { re : real ; im : real }; const i:t = t { re = 0. ; im = 1. }; - function re(c: t) returns (re:real); + node re(c: t) returns (re:real); let re = c.re; tel; end \ No newline at end of file diff --git a/src/test/test.res.exp b/src/test/test.res.exp index b805649f..d137a483 100644 --- a/src/test/test.res.exp +++ b/src/test/test.res.exp @@ -183,7 +183,7 @@ let _v8 = not _v7; _v9 = hB and _v8; _v10 = _v5 or _v9; - X = _v16 when True(hX); + X = _v16 when hX; _v11 = current D; _v12 = current _v11; _v13 = hA and _v12; @@ -218,7 +218,7 @@ let hX = _v2 and _v3; _v1 = current hD; _v2 = hC and _v1; - _v3 = h0 when True(h0); + _v3 = h0 when h0; tel -- end of node PCOND1::PCOND1 @@ -1168,7 +1168,7 @@ let lap_state = Watch::TWO_STATES(false, _v6, lap); _v6 = lap and run_state; time = current _v7; - _v7 = internal_time when True(lap_state); + _v7 = internal_time when lap_state; internal_time = if _v8 then Watch::INITIAL_STOPWATCH_TIME else _v13; _v8 = true -> reset; _v9 = run_state and hs; @@ -1372,7 +1372,7 @@ let lap, stop_alarm_beep) = Watch::BUTTONS(UPLEFT, LOWLEFT, UPRIGHT, LOWRIGHT); second = time_unit and _v7; _v4 = Watch::TIME_SCALE(0); - _v5 = _v4 when True(time_unit); + _v5 = _v4 when time_unit; _v6 = Watch::DIVIDE(_v5); _v7 = current _v6; tel @@ -1432,16 +1432,16 @@ var _v9:int when d; let m = _v1 -> _v3; - _v1 = 0 when True(c); + _v1 = 0 when c; _v2 = pre m; _v3 = _v2 + n; d = c and _v5; _v4 = current m; _v5 = _v4 <= 10; p = _v6 -> _v9; - _v6 = 0 when True(d); + _v6 = 0 when d; _v7 = pre p; - _v8 = 1 when True(d); + _v8 = 1 when d; _v9 = _v7 + _v8; tel -- end of node X::X @@ -1455,7 +1455,7 @@ var _v1:int when b; let m = current _v1; - _v1 = n when True(b); + _v1 = n when b; tel -- end of node X1::X1 @@ -1469,7 +1469,7 @@ var _v2:int; let m = 0 -> _v2; - _v1 = n when True(b); + _v1 = n when b; _v2 = current _v1; tel -- end of node X2::X2 @@ -1492,14 +1492,14 @@ var _v4:int when d; let c = p >= _v1; - _v1 = 0 when True(b); - p = n when True(b); - q = p when True(c); + _v1 = 0 when b; + p = n when b; + q = p when c; d = q <= _v3; - _v2 = 10 when True(b); - _v3 = _v2 when True(c); + _v2 = 10 when b; + _v3 = _v2 when c; r = current _v4; - _v4 = q when True(d); + _v4 = q when d; u = current r; m = current u; tel @@ -1528,14 +1528,14 @@ var _v4:int when d; let c = p >= _v1; - _v1 = 0 when True(b); - p = n when True(b); - q = p when True(c); + _v1 = 0 when b; + p = n when b; + q = p when c; d = q <= _v3; - _v2 = 10 when True(b); - _v3 = _v2 when True(c); + _v2 = 10 when b; + _v3 = _v2 when c; r = current _v4; - _v4 = q when True(d); + _v4 = q when d; u = current r; m = current u; tel @@ -2258,7 +2258,7 @@ var _v2:bool when c; let e = current _v2; - _v1 = b when True(c); + _v1 = b when c; _v2 = ck5::edge(_v1); tel -- end of node ck5::ck5 @@ -2271,7 +2271,7 @@ extern function ck6::p(d:int) returns (e:int; f:int); node ck6::N(a:bool; m:int; n:int) returns (q:int; r:int when a); let q = m + n; - r = q when True(a); + r = q when a; tel -- end of node ck6::N node ck6::ck6(b:bool; c:bool; n:int; m:int) returns (k:int; l:int); @@ -2285,9 +2285,9 @@ var _v2:int when b; let (u, v) = ck6::p(_v1); - _v1 = n when True(b); + _v1 = n when b; (w, x) = ck6::N(cc, u, v); - cc = c when True(b); + cc = c when b; k = current w; l = current _v2; _v2 = current x; @@ -2301,7 +2301,7 @@ Opening file should_work/NONREG/ck7.lus node ck7::ck7(a:bool; m:int; n:int) returns (q:int; r:int when a); let q = m + n; - r = q when True(a); + r = q when a; tel -- end of node ck7::ck7 @@ -2348,8 +2348,8 @@ var _v12:A_bool_7; let v1 = clock::inOnIn(in, _v1); - _v1 = true when True(in); - v2 = in when True(v4); + _v1 = true when in; + v2 = in when v4; v3 = clock::outOnIn(in, v1); (v4, v5) = clock::outOnOut(_v2, _v3); _v2 = pre v4; @@ -2983,7 +2983,7 @@ var _v17:A_A_A_int_4_4_4 when a1; _v18:A_A_int_4_4 when a1; let - res = _v2 when True(a1); + res = _v2 when a1; _v1 = h1[0]; _v2 = _v1 > 1; h1 = current _v6; @@ -3771,13 +3771,13 @@ var _v8:int when h; let h = _v1 -> _v4; - _v1 = true when True(c); + _v1 = true when c; _v2 = x + y; - _v3 = _v2 when True(c); + _v3 = _v2 when c; _v4 = _v3 < z; u = _v5 -> _v8; - _v5 = z when True(h); - _v6 = z when True(h); + _v5 = z when h; + _v6 = z when h; _v7 = pre u; _v8 = multiclock::moyenne(_v6, _v7); s = current u; @@ -10039,7 +10039,7 @@ tel Opening file should_work/call/bad_call02.lus node bad_call02::bad_call02(a:int; c:bool) returns (x:int when c); let - x = a when True(c); + x = a when c; tel -- end of node bad_call02::bad_call02 @@ -10227,12 +10227,12 @@ let (z, x) = clock::clock3(_v2); _v1 = pre z; _v2 = true -> _v1; - e = b when True(a); + e = b when a; (c, d) = clock::clock4(a, _v3); - _v3 = b when True(a); + _v3 = b when a; z2 = clock::clock5(a, _v4, _v5); - _v4 = b when True(a); - _v5 = c when True(e); + _v4 = b when a; + _v5 = c when e; tel -- end of node clock::clock @@ -10254,7 +10254,7 @@ var let c = _v1 + _v2; _v1 = 1 + 1; - _v2 = b when True(a); + _v2 = b when a; tel -- end of node clock2::clock @@ -10270,9 +10270,9 @@ var _v4:bool when a; let c = if _v1 then _v2 else _v4; - _v1 = a when True(a); - _v2 = b when True(a); - _v3 = b when True(a); + _v1 = a when a; + _v2 = b when a; + _v3 = b when a; _v4 = not _v3; tel -- end of node clock_ite::clock @@ -10330,7 +10330,7 @@ returns ( *** Error in file "should_work/clock/when_not.lus", line 7, col 12 to 17, token 'clock4': *** *** clock error: The expression has clock ' on a on base', -*** but it is used with clock ' on not a on base'. +*** but it is used with clock ' on not a on base'. @@ -10346,9 +10346,9 @@ returns ( b:int when clk; c:int when clk); let - a = x when True(clk); - b = x when True(clk); - c = x when True(clk); + a = x when clk; + b = x when clk; + c = x when clk; tel -- end of node when_tuple::titi extern node when_tuple::toto(u:bool; v:bool) returns (x:bool; y:bool); @@ -10365,8 +10365,8 @@ var _v2:bool when a; let (x, y) = when_tuple::toto(_v1, _v2); - _v1 = b when True(a); - _v2 = c when True(a); + _v1 = b when a; + _v2 = c when a; tel -- end of node when_tuple::clock @@ -11125,13 +11125,13 @@ var _v3:bool; _v4:bool when a; let - y = _v2 when True(x); - _v1 = b when True(a); + y = _v2 when x; + _v1 = b when a; _v2 = clock::clock2(a, _v1); (z, x) = clock::clock3(_v3); _v3 = pre z; (c, d) = clock::clock4(a, _v4); - _v4 = b when True(a); + _v4 = b when a; tel -- end of node clock::clock @@ -11170,7 +11170,7 @@ var let Clock1ms = clock1_2ms::Clock1ms_node(dummy); Clock2ms = clock1_2ms::Clock2ms_node(_v1); - _v1 = dummy when True(Clock1ms); + _v1 = dummy when Clock1ms; tel -- end of node clock1_2ms::clock1_2ms @@ -11390,7 +11390,7 @@ var _v69:A_A_int_4_4 when a1; _v70:A_int_4 when a1; let - res = _v3 when True(a1); + res = _v3 when a1; _v1 = h1[0]; _v2 = pre _v1; _v3 = _v2 > 0; @@ -11656,19 +11656,19 @@ let Sum = In1 + Unit_Delay1; Unit_Delay1_ = if cl2_6 then _v1 else _v4; _v1 = current zoh2; - _v2 = 0.0 when True(cl1_2); + _v2 = 0.0 when cl1_2; _v3 = pre Unit_Delay1_; _v4 = _v2 -> _v3; Unit_Delay1 = if cl1_2 then _v5 else _v7; _v5 = current Unit_Delay1_; _v6 = pre Unit_Delay1; _v7 = 0.0 -> _v6; - zoh1 = In1 when True(cl1_4); - zoh2 = In2 when True(cl2_6); + zoh1 = In1 when cl1_4; + zoh2 = In2 when cl2_6; out1 = Sum; Out2_ = if cl2_6 then _v8 else _v11; _v8 = current zoh2; - _v9 = 0.0 when True(cl1_2); + _v9 = 0.0 when cl1_2; _v10 = pre Out2_; _v11 = _v9 -> _v10; Out2 = if cl1_2 then _v12 else _v14; @@ -11682,10 +11682,10 @@ let subsys1_Trigger = lustre_test1_ok::rising(In3); subsys1_s1 = zoh1; subsys1_s2 = if subsys1_Trigger then _v20 else _v23; - _v18 = subsys1_s1 when True(subsys1_Trigger); + _v18 = subsys1_s1 when subsys1_Trigger; _v19 = lustre_test1_ok::subsys1(_v18); _v20 = current _v19; - _v21 = 0.0 when True(cl1_4); + _v21 = 0.0 when cl1_4; _v22 = pre subsys1_s2; _v23 = _v21 -> _v22; tel @@ -12061,10 +12061,10 @@ var _v4:real when cl1_4_2; let Unit_Delay1 = _v1 -> _v2; - _v1 = 0.0 when True(cl1_12_3); + _v1 = 0.0 when cl1_12_3; _v2 = pre In3; Unit_Delay2 = _v3 -> _v4; - _v3 = 0.0 when True(cl1_4_2); + _v3 = 0.0 when cl1_4_2; _v4 = pre Unit_Delay2; Out2 = Unit_Delay2; tel @@ -12082,7 +12082,7 @@ let cl1_4_2 = sample_time_change::make_cl1_4_2(true); cl1_12_3 = sample_time_change::make_cl1_12_3(true); Out2_ = sample_time_change::sample_time_change(cl1_4_2, cl1_12_3, _v1); - _v1 = In3 when True(cl1_12_3); + _v1 = In3 when cl1_12_3; Out2 = if cl1_4_2 then _v2 else _v4; _v2 = current Out2_; _v3 = pre Out2; @@ -12104,7 +12104,7 @@ var _v6:bool; let assert(true -> _v6); - o = _v4 when True(i); + o = _v4 when i; _v1 = pre i; _v2 = false -> _v1; _v3 = pre _v2; @@ -15426,7 +15426,7 @@ var _v1:bool when b; let x = current _v1; - _v1 = a when True(b); + _v1 = a when b; tel -- end of node titi::titi @@ -15568,10 +15568,10 @@ var _v2:bool when c; _v3:bool when b; let - c = a when True(b); + c = a when b; x = current _v3; - _v1 = a when True(b); - _v2 = _v1 when True(c); + _v1 = a when b; + _v2 = _v1 when c; _v3 = current _v2; tel -- end of node toto::toto @@ -18382,7 +18382,7 @@ tel Opening file should_work/packEnvTest/complex.lus type _complex::t = struct {re : real; im : real}; const complex::i = _complex::t{re = 0.; im = 1.}; -function complex::re(c:_complex::t) returns (re:real); +node complex::re(c:_complex::t) returns (re:real); let re = c.re; tel -- GitLab