1 / 36

Stavros Tripakis UC Berkeley

Modular code generation from synchronous block diagrams: modularity vs. reusability vs. code size vs. …. Stavros Tripakis UC Berkeley. or … on the compositionality of synchronous (and other) models of computation. Stavros Tripakis UC Berkeley. or … on interface synthesis.

javen
Download Presentation

Stavros Tripakis UC Berkeley

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Modular code generation from synchronous block diagrams:modularity vs. reusability vs. code size vs. … Stavros Tripakis UC Berkeley

  2. or …on the compositionality of synchronous (and other) models of computation Stavros Tripakis UC Berkeley

  3. or …on interface synthesis Stavros Tripakis UC Berkeley

  4. F1 F2 What is the parallel composition of two functions? y1 x1 x2 y2

  5. F F1 F2 What is the parallel composition of two functions? y1 x1 x2 y2

  6. What is the parallel composition of two functions? y1 x1 F x2 y2 a function?

  7. What is the parallel composition of two functions? x1 y1 F y2 x2

  8. F F1 F2 What is the parallel composition of two functions? False I/O dependency x1 y1 y2 x2

  9. F1 F2 What is the parallel composition of two functions? F1 x1 y1 y1 x1 F2 x2 y2 x2 y2 F

  10. What is the parallel composition of two Mealy machines? output1 x1 y1 M1 y1 x1 state update M2 x2 y2 output2 x2 M y2

  11. What about more complex compositions? what about this? or this?

  12. P A B What is the sequential composition of two SDF (Synchronous/Static Data Flow) actors? 3 1 2 3 1 2

  13. P What is the sequential composition of two SDF (Synchronous/Static Data Flow) actors? 3 2

  14. P What is the sequential composition of two SDF (Synchronous/Static Data Flow) actors? Deadlocks! 3 2 3 2 Q

  15. A B What is the sequential composition of two SDF (Synchronous/Static Data Flow) actors? Original diagram does not deadlock 1 2 3 1 P 3 2 Q

  16. P A B What is the sequential composition of two SDF (Synchronous/Static Data Flow) actors? 3 1 2 3 1 2 See tech. report, with D. Bui, B. Rodiers and E.A. Lee: http://www.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-143.html

  17. What has all this got to do with modular code generation?

  18. P A B Code generation • Generate code (in C, C++, Java, …) that implements the semantics of a certain modeling language (Simulink, Lustre, Ptolemy, …) • Code may be used for simulation,embedded control (“X-by-wire”), … • SCADE • Real-Time Workshop • … P.step( in ) returns out { tmp := A.step( in ); out := B.step( tmp ); return out; }

  19. Separate compilation Standard Compiler (e.g., gcc) . . . . . . Linker (e.g., ld) . . . gcc Object code (e.g., .o files) Source code (e.g., .cc files) Executable We want to do the same for synchronous block diagrams

  20. P P A B C D Modular code generation • Goal: generate code for a given block P • Code should be independent from context: • Enables component-based design (c.f., AUTOSAR) Will P be connected like this? …or like that?

  21. Problem with current approaches: “monolithic” code False I/O dependencies F1 y1 F.step(x1, x2) returns (y1, y2) { y1 := F1.step( x1 ); y2 := F2.step( x2 ); return (y1, y2); } x1 F2 x2 y2 F

  22. State of the art • SCADE: add unit delays to “break’’ cycles at all levels of hierarchy • Destroys control properties (stability) • Simulink (Real-Time Workshop): flattening • Not modular • Not scalable • Ptolemy [Edwards, Lee’03]: iterate step() until fixpoint is reached (à la Esterel) • Handles larger class of models • Fixpoint may contain undefined values (“bottom”) • Expensive/undecidable to prove statically that this won’t happen

  23. [DATE’08, RTAS’08, POPL’09], with R. Lublinerman and C. Szegedy P A B Our solution • Generate for each block a PROFILE = INTERFACE • Interface may contain MANY functions • Automatically P.step1( x1 ) returns y1 { return A.step( x1 ); } P.step2( x2 ) returns y2 { return B.step( x2 ); }

  24. How many functions? • Would like to have as few as possible • Scalability, IP concerns, … • Modularity = small number of interface functions => small size of interface • Modularity becomes quantifiable! • The smaller the interface, the more modular

  25. class P { public Pstep( in1, in2 ) returns out1, out2; Pstep( in1, in2 ) { return (Astep( in1 ), Bstep( in2 ) ); } } class P { public Pstep1( in1 ) returns out1; public Pstep2( in2 ) returns out2; Pstep1( in1 ) { return Astep( in1 ); } Pstep2( in2 ) { return Bstep( in2 ); } } P P A A B B Modularity vs. Reusability Number of interface functions Set of allowed contexts more modular, less reusable more reusable, less modular tradeoff technique: graph clustering more interface functions fewer interface functions

  26. unit-delay update output Profile dependency graphs • Profile = Interface functions + DEPENDENCY GRAPH • Graph encodes interface usage constraints class UnitDelay { private state; update( in ) returns void { state := in; } output() returns out { return state; } } in out PROFILE DEPENDENCY GRAPH

  27. Overall method A B C D P

  28. Overall method Interface for B Interface for A P Interface for D Interface for C

  29. Overall method clustering

  30. Overall method Interface for P P

  31. Clustering methods and tradeoffs * N = number of block outputs

  32. Extensions to triggered and timed synchronous block diagrams • Inspired from SCADE and Simulink: Triggered block Simulink/Stateflow diagram Sample time

  33. Extensions to triggered and timed synchronous block diagrams • Extensions of interfaces with additional info:

  34. Tool and experiments Profile library for basic blocks Profiles for macro blocks Modular Code Generator Simulink model (.mdl file) Java code

  35. Related work • Cronos [Hainque et al. ‘99] • [Raymond ’88, Pouzet-Raymond ‘09] • [Benveniste et al. ‘97] • [Schneider et al. ‘06, ‘09] • [Mosterman, Ciolfi ‘04] • … • More in the papers: • http://www-verimag.imag.fr/~tripakis/papers/popl09.pdf • http://www-verimag.imag.fr/~tripakis/papers/rtas08.pdf • http://www-verimag.imag.fr/~tripakis/papers/date08.pdf

  36. In memory of Amir Pnueli

More Related