Compiling Esterel into Sequential Code - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Compiling Esterel into Sequential Code

Description:

Compiling Esterel into. Sequential Code. Stephen Edwards ... Restore state of resuming thread. s=2. C. B. D. C. B. A. 2. 1. s. s=1. RESET. Run First Node. RESET ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 45
Provided by: aha125
Category:

less

Transcript and Presenter's Notes

Title: Compiling Esterel into Sequential Code


1
Compiling Esterel intoSequential Code
  • Stephen Edwards

Advanced Technology Group
2
An Application
CoCentricTM System Studio
Control
Dataflow
Esterel
Dataflow Compiler
This work
C
C
Compiled Simulation
3
The Esterel Language
4
The Esterel Language
  • Developed by G. Berry et al. starting 1983

5
The Esterel Language
emit B if C emit D
Force signal B to be present in this cycle
Emit D if signal C is present
6
The Esterel Language
await A emit B if C emit D
pause
Wait for next cycle with A present
Wait for next cycle
7
The Esterel Language
loop await A emit B if C emit
D pause end
Infinite loop
8
The Esterel Language
loop await A emit B if C emit
D pause end loop if B emit C
pause end
Run concurrently
9
The Esterel Language
loop await A emit B if C emit
D pause end loop if B emit C
pause end
Same-cycle bidirectional communication
10
The Esterel Language
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
Restart when RESET present
11
The Esterel Language
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
Good for hierarchical FSMs
12
The Esterel Language
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
Bad at manipulating data
13
New Compiler
14
The New Compiler
Esterel
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
15
The New Compiler
Esterel
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
16
The New Compiler
Esterel
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
17
The New Compiler
Esterel
C
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
Void foo() switch (st) 0 if (IN3)
st 5 goto L5 1 if (RES)
st 3 goto L8 L5 switch
Step 4 Generate C
18
The New Compiler
Esterel
C
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
Void foo() switch (st) 0 if (IN3)
st 5 goto L5 1 if (RES)
st 3 goto L8 L5 switch
  • Generated code is 2 to 100? faster
  • 1/2 to 1? the size

Concurrent Control-Flow Graph
Sequential Control-Flow Graph
Scheduled CCFG
19
The New Compiler
Esterel
C
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
Void foo() switch (st) 0 if (IN3)
st 5 goto L5 1 if (RES)
st 3 goto L8 L5 switch
Flow similar to Lin DAC 98
Concurrent Control-Flow Graph
Sequential Control-Flow Graph
Scheduled CCFG
20
Step 1 Build Concurrent CFG
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
RESET
21
Add Threads
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
RESET
Fork
Join
22
Split at Pauses
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
RESET
1
1
s
2
2
23
Add Code Between Pauses
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
RESET
1
s
2
A
B
C
D
s2
s1
24
Build Right Thread
every RESET do loop await A emit B
if C emit D pause end loop if B
emit C pause end end
25
Step 2 Schedule
Add arcs for communication
RESET
Topological sort Optimal scheduling
NP-Complete Bad schedules OK
1
s
2
A
B
B
C
C
D
s2
s1
26
Step 3 Sequentialize
  • Hardest part Removing concurrency
  • Simulate the Concurrent CFG
  • Main Loop
  • For each node in scheduled order,
  • Insert context switch if from different thread
  • Copy node connect predecessors

27
Context Switching Code
28
Run First Node
RESET
RESET
29
Run First Part of Left Thread
RESET
1
s
2
B
1
s
A
2
A
B
30
Context switch Save State
RESET
1
s
2
B
A
t0
t1
31
Rejoin
RESET
1
s
2
B
A
t0
t1
32
Run Right Thread
RESET
1
s
2
B
A
t0
t1
B
B
C
C
33
Context Switch Restore State
RESET
1
s
2
B
A
t0
t1
B
C
0
1
t
34
Resume Left Thread
RESET
1
s
2
B
A
t0
t1
B
C
C
0
1
t
D
D
C
s2
s1
s2
s1
35
Step 3 Finished
RESET
RESET
1
s
2
B
1
s
A
2
A
t0
t1
B
B
B
C
C
C
0
1
t
D
D
C
s2
s1
s2
s1
36
Related Work and Experiments
37
Existing Esterel Compilers
Capacity
Simulation Speed
38
Existing Esterel Compilers
Capacity
Automata V3 Berry 87, Polis DAC 95
Simulation Speed
39
Existing Esterel Compilers
Logic gates V4, V5 Berry 92, 96
Capacity
Automata V3 Berry 87, Polis DAC 95
Simulation Speed
40
Speed of Generated Code
Average cycle time (ms)
Size (source lines)
41
Size of Generated Code
Object code size (K)
Size (source lines)
42
Why This Wins
Automata
Zero overhead Code duplicated
Gates
No duplication Not event driven runs idle
code Significant overhead
New
Only active code runs No code duplication
Some overhead
43
Why Not Event-Driven?
  • Already exclusively running active code
  • Behavior of event queue is simulated once at
    compile-time and hardwired
  • Technically difficult for Esterel
  • Netlist includes mixture of event and
    level-sensitive entities

44
Summary
  • Esterel
  • Deterministic concurrency
  • Good for hierarchical FSMs
  • New Compiler
  • Build concurrent control-flow graph
  • Schedule
  • Sequentialize add context switches
  • Results
  • Code runs 2 to 100? faster
  • 1 to 1/2 the size
Write a Comment
User Comments (0)
About PowerShow.com