Skip to content
Snippets Groups Projects
Commit e76ba203 authored by erwan's avatar erwan
Browse files

Update: enhance the oracle generation (-glos)

The generation scheme is now makes it easier to write oracles that do
not depend on the topology.  The idea is to generate an oracle
(specific to the graph) that includes a file that the user should
provide, and which ougth to define a generic oracle, i.e., depending
on m and n (process and actions numbers).
parent b5ae2b4b
No related branches found
No related tags found
No related merge requests found
Pipeline #26675 failed
(* Time-stamp: <modified the 26/06/2019 (at 12:16) by Erwan Jahier> *) (* Time-stamp: <modified the 05/07/2019 (at 11:30) by Erwan Jahier> *)
open Process open Process
let (f: 'v Process.t list -> string) = let (f: 'v Process.t list -> string) =
fun pl -> fun pl ->
let degree = 0 in let degree = Register.max_degree () in
let diameter = 0 in let diameter = Register.diameter () in
let actions_nb = List.map (fun p -> List.length p.actions) pl in let actions_nb = List.map (fun p -> List.length p.actions) pl in
let m = List.fold_left max (List.hd actions_nb) (List.tl actions_nb) in let m = List.fold_left max (List.hd actions_nb) (List.tl actions_nb) in
let n = List.length pl in let n = List.length pl in
let al = List.flatten (List.map (fun p -> List.map (fun a -> p.pid^"_"^a) p.actions) pl) in let al = List.map (fun p -> List.map (fun a -> p.pid^"_"^a) p.actions) pl in
let al = List.flatten al in
let enabl = List.map (fun a -> "Enab_"^a) al in let enabl = List.map (fun a -> "Enab_"^a) al in
let input_decl = (String.concat ","(al@enabl)) ^ ":bool" in let input_decl = (String.concat ","(al@enabl)) ^ ":bool" in
let array_decl = Printf.sprintf "\tActi:bool^%d^%d;\n\tEnab:bool^%d^%d;\n" m n m n in let array_decl = Printf.sprintf "\tActi:bool^%d^%d;\n\tEnab:bool^%d^%d;\n" m n m n in
...@@ -20,33 +21,39 @@ let (f: 'v Process.t list -> string) = ...@@ -20,33 +21,39 @@ let (f: 'v Process.t list -> string) =
let array_def_acti = let array_def_acti =
Printf.sprintf "\tActi = [%s];\n" Printf.sprintf "\tActi = [%s];\n"
(String.concat "," (String.concat ","
(List.map (fun p -> "["^(String.concat "," (List.map (acti_name p) p.actions))^"]") pl)) (List.map (fun p ->
"["^(String.concat "," (List.map (acti_name p) p.actions))^"]") pl))
in in
let array_def_enab = let array_def_enab =
Printf.sprintf "\tEnab = [%s];\n" Printf.sprintf "\tEnab = [%s];\n"
(String.concat "," (String.concat ","
(List.map (fun p -> "["^(String.concat "," (List.map (enab_name p) p.actions))^"]") pl)) (List.map (fun p ->
"["^(String.concat "," (List.map (enab_name p) p.actions))^"]") pl))
in
let algo = Filename.basename (Sys.getcwd()) in
let algo = (* Make sure that we generate valid Lustre idents *)
Str.global_replace (Str.regexp "[-,\\.]") "_" algo
in in
Printf.sprintf "%sconst n=%d; Printf.sprintf "%sinclude \"%s_oracle.lus\"
const n=%d;
const m=%d; const m=%d;
const degree=%d; const degree=%d;
const diameter=%d; const diameter=%d;
node oracle(%s) returns (ok:bool); node oracle(%s) returns (ok:bool);
var var
%slet %slet
%s %s %s
%s ok = %s_oracle<<m,n>>(Enab,Acti);
ok = false; -- XXX set me !
tel tel
" "
(Mypervasives.entete "--" SasaVersion.str SasaVersion.sha) (Mypervasives.entete "--" SasaVersion.str SasaVersion.sha)
n m degree diameter algo
input_decl n m degree diameter
array_decl input_decl
array_def_acti array_decl
array_def_enab array_def_acti
array_def_enab
algo
# Time-stamp: <modified the 26/06/2019 (at 14:50) by Erwan Jahier> # Time-stamp: <modified the 05/07/2019 (at 11:09) by Erwan Jahier>
test: test0 test2 lurette0 lurette1 test: test0 test2 lurette0 lurette1
...@@ -31,11 +31,11 @@ lurette0:cmxs fig5.1-noinit.lut ...@@ -31,11 +31,11 @@ lurette0:cmxs fig5.1-noinit.lut
-env "$(sasa) fig5.1-noinit.dot -custd -rif" \ -env "$(sasa) fig5.1-noinit.dot -custd -rif" \
-sut "lutin fig5.1-noinit.lut -n distributed" -sut "lutin fig5.1-noinit.lut -n distributed"
lurette1:cmxs fig5.1-noinit.lut lurette1:cmxs fig5.1.lut
rdbg -lurette -o lurette.rif \ rdbg -lurette -o lurette.rif \
-env "$(sasa) fig5.1-noinit.dot -custd -rif" \ -env "$(sasa) fig5.1.dot -custd -rif" \
-sut "lutin fig5.1-noinit.lut -n distributed" \ -sut "lutin fig5.1.lut -n distributed" \
-oracle "lv6 fig5.1-noinit_oracle.lus -n oracle" -oracle "lv6 fig5.1_oracle.lus -n oracle"
lurette: lurette0 lurette: lurette0
sim2chrogtk -ecran -in lurette.rif > /dev/null sim2chrogtk -ecran -in lurette.rif > /dev/null
...@@ -46,6 +46,11 @@ rdbg: cmxs fig5.1-noinit.lut ...@@ -46,6 +46,11 @@ rdbg: cmxs fig5.1-noinit.lut
-env "$(sasa) fig5.1-noinit.dot -custd -rif" \ -env "$(sasa) fig5.1-noinit.dot -custd -rif" \
-sut-nd "lutin fig5.1-noinit.lut -n distributed" -sut-nd "lutin fig5.1-noinit.lut -n distributed"
rdbg2: cmxs fig5.1.lut
rdbg -o lurette.rif \
-env "$(sasa) fig5.1.dot -custd -rif" \
-sut-nd "lutin fig5.1.lut -n distributed"
manual:cmxs fig5.1-noinit.lut manual:cmxs fig5.1-noinit.lut
lurette -o lurette.rif --sim2chro \ lurette -o lurette.rif --sim2chro \
......
-- -- Time-stamp: <modified the 26/06/2019 (at 15:13) by Erwan Jahier> -- -- Time-stamp: <modified the 05/07/2019 (at 11:34) by Erwan Jahier>
-- --
-- Computing rounds in Lustre -- Computing rounds in Lustre
-- The inputs are 2 arrays Enab and Acti, where: -- The inputs are 2 arrays Enab and Acti, where:
...@@ -14,12 +14,11 @@ var ...@@ -14,12 +14,11 @@ var
let let
pres = true -> pre res; pres = true -> pre res;
mask = merge pres (true -> mask_init<<m, n>> (Enab, Acti) when pres) mask = merge pres (true -> mask_init<<m, n>> (Enab, Acti) when pres)
(false -> mask_update<<m, n>>(Enab, Acti, pre mask) when not pres); (false -> mask_update<<m, n>>(Enab, Acti, pre mask) when not pres);
res = boolred<<0,0,n>>(mask); -- when all are false, res = boolred<<0,0,n>>(mask); -- when all are false,
tel tel
node mask_init <<const m:int; const n:int>> (E,A: bool^m^n) returns (res : bool^n); function mask_init <<const m:int; const n:int>> (E,A: bool^m^n) returns (res : bool^n);
var var
enab:bool^n; -- at least one action is enabled enab:bool^n; -- at least one action is enabled
acti:bool^n; -- at least one action is active acti:bool^n; -- at least one action is active
...@@ -34,7 +33,8 @@ let ...@@ -34,7 +33,8 @@ let
res = not(a=>b); res = not(a=>b);
tel tel
node mask_update<<const m: int; const n: int>> (E,A: bool^m^n; pmask:bool^n) returns (res : bool^n); function mask_update<<const m: int; const n: int>> (E,A: bool^m^n; pmask:bool^n)
returns (res : bool^n);
var var
acti:bool^n; -- at least one action is active acti:bool^n; -- at least one action is active
let let
...@@ -53,7 +53,7 @@ let ...@@ -53,7 +53,7 @@ let
tel tel
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
node silent<<const m: int; const n: int>> (Enab: bool^m^n) returns (ok:bool); function silent<<const m: int; const n: int>> (Enab: bool^m^n) returns (ok:bool);
var var
enab:bool^n; -- at least one action is enabled enab:bool^n; -- at least one action is enabled
let let
......
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