SLIDE 1 Abstraction of Clocks in Synchronous Data-flow Systems
- A. Cohen 1
- L. Mandel 2
- F. Plateau 2
- M. Pouzet23
(1) INRIA Saclay - Ile-de-France, Orsay, France (2) LRI, Univ. Paris-Sud 11, Orsay, France and INRIA Saclay (3) Institut Universitaire de France
Synchron Workshop - 2 December 2008
SLIDE 2
N-Synchronous Model: A Relaxed Notion of Synchrony
A B
ha hb
◮ 0-synchronous : no buffers (ha = hb).
For instance (1010) = (0110).
◮ n-synchronous : buffer of size n (ha <: hb).
For instance (1010) <: (0110) Interest: more flexible, as much guaranties as in synchronous model.
SLIDE 3 N-Synchronous Model: picture in picture example
!"#$%"&'() *)'+# ,+"#-+# .+#'$/() *)'+#
β1 β1 on hf β2 β2 on reorder β3 β3 on vf
0"1&2/()+#
α α on hf on reorder on vf hf = (10100100) reorder = 03600(1) vf = (172007201720072007201720072007201720)
0"1&2/()+# 13+&
not incrust
4+#5+
α1 α1 on hf on reorder on vf α2 α2 on not incrust α3 on not incrust α3 on incrust incrust α3
◮ Previous work: subtyping relation can be checked provided
clocks are periodic.
◮ Motivations:
- 1. dealing with long patterns in periodic clocks
- 2. modelizing jitter
How to deal with “almost periodic” clocks ? For instance α on w with w = 00.( (10) + (01) )ω (e.g. w = 00 01 10 01 01 10 01 10 . . . )
SLIDE 4 Clocks as Infinite Binary Words
Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 13 12 11 10 9 8 7 6 5 4 3 2 1
Ow1 Ow2 Ow3
[w1]6 |w1[1..8]|1 w1
w ::= 0.w | 1.w Notations: w[i] : element at index i [w]j : position of the jth 1 Ow(i): number of 1s seen in w until index i. buffer size(w1, w2) = maxi∈N(Ow1(i) − Ow2(i)) precedence w1 w2
def
⇔ ∀i, Ow1(i) ≥ Ow2(i)
synchronizability w1 ⊲ ⊳ w2
def
⇔ ∃b1, b2 ∈ Z, ∀i, b1 ≤ Ow1(i) − Ow2(i) ≤ b2
subtyping w1 <: w2
def
⇔ (w1 w2)/ (w2 w2)
composed clocks c ::= w | not w | c on c
SLIDE 5 Abstraction of Infinite Binary Words [SYNCHRON’07, APLAS’08]: abs(w) = [d, D] (T)
concr ([d, D] (T)) def ⇔ {w, ∀j ≥ 0, T ×j +d ≤ [w]j+1 ≤ T ×j +D}
Instants Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1
fw1 fw2
[w2]5
{ a1
}a2
w2 d = 5
3
T = 5
3
D = 9
3
T = 5
3
SLIDE 6 Drawbacks
◮ sets of 1s in prefix are badly abstracted.
Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 2 1
fnot w4 fw4
⇒ a ⊆ not∼ not∼ a.
◮ words with finite number number of 1s cannot be abstracted.
⇒ not∼ can not be applied to 000(1).
SLIDE 7 New Abstraction [JFLA’09]:
concr
def ⇔
w[i] = 1 ⇒ Ow(i − 1) < r × i + b1 ∧ w[i] = 0 ⇒ Ow(i − 1) ≥ r × i + b0
Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1
Ow1 Ow2
SLIDE 8
◮ Initial sets of 1s are well abstracted. Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Ow4
SLIDE 9
◮ Clocks with a nul rate can be abstracted. Instants Number of ones 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 9 8 7 6 5 4 3 2 1
Ow5
SLIDE 10 Abstract Clocks as Automata
4, 1 7, 2 6, 2 5, 1 4, 0 3, 0 2, 0 1, 0 1 1 1 1 1
a2 =
5, − 7 5, 3 5
3, 0 2, 0 1, 0 1 1
a4 =
2, − 2 2, 1 2
◮ The set of states Q = {(i, j) ∈ N2} : coordinates in the
2D-chronograms. Finite number of state equivalence classes.
◮ The initial state qo is (0, 0) ◮ The alphabet Σ is {0, 1} ◮ The transition function δ is defined by:
δ(1, (i, j)) = nf (i + 1, j + 1) if Ow(i − 1) < r × i + b1 δ(0, (i, j)) = nf (i + 1, j) if Ow(i − 1) ≥ r × i + b0 It is undefined otherwise.
SLIDE 11
Checking Clocks are in an Abstraction
type rat = { num: int; den: int; } (* "+:", "<:" ... are operations over rat *) let norm { num = n; den = l; } i j = if i >= l && j >= n then (i - l, j - n) else (i, j) let node check (b0, b1, r) clk = ok where rec i, j = (1,0) fby norm r (i+1) (if clk then j + 1 else j) and ok = if clk then (rat_of_int j) <: r *: (rat_of_int i) +: b1 else (rat_of_int j) >=: r *: (rat_of_int i) +: b0
SLIDE 12
Generating Clocks in an Abstraction
let node generate choice (b0, b1, r) = clk where rec i, j = (1,0) fby norm r (i+1) (if clk then j + 1 else j) and one = (rat_of_int j) <: (r *: (rat_of_int i) +: b1) and zero = (rat_of_int j) >=: (r *: (rat_of_int i) +: b0) and clk = choice one zero let node early a = generate (fun x y -> x) a let node late a = generate (fun x y -> not y) a
SLIDE 13 Generating Clocks in an Abstraction with Lustre Compiler (Pascal Raymond)
node generate(x : bool) returns (clk: bool); let
- - we simply copy the input on the output
clk = x ;
- - but we enforce the correctness of x
assert check(-9, -7, 3, 5, x) ; tel node early() returns (clk: bool); let clk = generate(true); tel node late() returns (clk: bool); let clk = generate(false); tel
SLIDE 14
~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/0 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 0/0 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1 ~/1
SLIDE 15 Abstract Operators:
◮ abstract not operator:
not∼
b0, b1, r
- =
- −b1 − ε, −b0 − ε, 1 − r
- with r = n
l ,
b0 = k0
l ,
b1 = k1
l ,
ε = l−1
l
Property: a = not∼ not∼ a
◮ abstract on operator:
b02, b12, r2
r12 = r1 × r2, b012 = b01 × r2 + b02, b112 = b11 × r2 + b12 + ε.
SLIDE 16
Abstraction of a composed clock
◮ abs(c)
abs(not w)
def
⇔
not∼ abs(w)
abs(c1 on c2)
def
⇔ abs(c1) on∼ abs(c2) Proposition: c ∈ concr(abs(c))
SLIDE 17 Abstract Relations
◮ synchronizability:
⊳∼ b02, b12, r2
Proposition: abs(c1) ⊲ ⊳∼ abs(c2) ⇔ c1 ⊲ ⊳ c2
◮ precedence: b01 ≥ b12 ⇒ a1 ∼ a2
Proposition: abs(c1) ∼ abs(c2) ⇒ c1 c2
◮ subtyping: a1 <:∼ a2 ⇔ (a1 ⊲
⊳∼ a2) ∧ (a1 ∼ a2) ⇒ can be checked in constant time.
SLIDE 18 Proofs in Coq
concr
def ⇔
w[i] = 1 ⇒ Ow(i − 1) < r × i + b1 ∧ w[i] = 0 ⇒ Ow(i − 1) ≥ r × i + b0
- Definition in_abstractionj (w: ibw) (a:abstractionj) :=
forall i: nat, forall H_i_ge_1: (i >= 1)%nat, (w i = true -> ones w (pred i) < absj_r a * i + absj_b1 a) /\ (w i = false -> ones w (pred i) >= absj_r a * i + absj_b0 a).
SLIDE 19
Proofs in Coq
For instance, on∼ correctness:
Property on_correctness: forall (w1:ibw) (w2:ibw), forall H_wf_w1: well_formed_ibw w1, forall H_wf_w2: well_formed_ibw w2, forall (a1:abstractionj) (a2:abstractionj), forall H_wf_a1: well_formed_abstractionj a1, forall H_wf_a2: well_formed_abstractionj a2, forall (H_a1_eq_absj_w1: in_abstractionj w1 a1), forall (H_a2_eq_absj_w2: in_abstractionj w2 a2), in_abstractionj (on w1 w2) (on_absj a1 a2).
SLIDE 20 Other Applications - Modelizing Execution Time
Instants Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1
f :: ∀α.α on∼ 0, 0, 1
2
− 3
2, − 1 2, 1 2
f o f :: ∀α.α on∼ 0, 0, 1
2
− 6
2, − 2 2, 1 2
SLIDE 21
Other Applications
Modelizing Several Reads (or writes) at the Same Instant
Instants Number of ones 12 11 10 9 8 7 6 5 4 3 2 1 14 13 12 11 10 9 8 7 6 5 4 3 2 1