Modular code generation from synchronous block diagrams: modularity vs. code size

We study modular, automatic code generation from hierarchical block diagrams with synchronous semantics. Such diagrams are the fundamental model behind widespread tools in the embedded software domain, such as Simulink and SCADE. Code is modular in the sense that it is generated for a given composite block independently from context (i.e., without knowing in which diagrams the block is to be used) and using minimal information about the internals of the block. In previous work, we have shown how modular code can be generated by computing a set of interface functions for each block and a set of dependencies between these functions that is exported along with the interface. We have also introduced a quantified notion of modularity in terms of the number of interface functions generated per block, and showed how to minimize this number, which is essential for scalability. Finally, we have exposed the fundamental trade-off between modularity and reusability (set of diagrams the block can be used in). In this paper we explore another trade-off: modularity vs. code size. We show that our previous technique, although it achieves maximal reusability and is optimal in terms of modularity, may result in code replication and therefore large code sizes, something often unacceptable in an embedded system context. We propose to remedy this by generating code with no replication, and show that this generally results in some loss of modularity. We show that optimizing modularity while maintaining maximal reusability and zero replication is an intractable problem (NP-complete). We also show that this problem can be solved using a simple iterative procedure that checks satisfiability of a sequence of propositional formulas. We report on a new prototype implementation and experimental results. The latter demonstrate the practical interest in our methods.

[1]  Stephen J. Garland,et al.  Algorithm 97: Shortest path , 1962, Commun. ACM.

[2]  Michael J. Fischer,et al.  Boolean Matrix Multiplication and Transitive Closure , 1971, SWAT.

[3]  Robert E. Tarjan,et al.  Depth-First Search and Linear Graph Algorithms , 1972, SIAM J. Comput..

[4]  Don Coppersmith,et al.  Matrix multiplication via arithmetic progressions , 1987, STOC.

[5]  Nicolas Halbwachs,et al.  LUSTRE: a declarative language for real-time programming , 1987, POPL '87.

[6]  Nicolas Halbwachs,et al.  LUSTRE: A declarative language for programming synchronous systems* , 1987 .

[7]  Gérard Berry,et al.  The Esterel Synchronous Programming Language: Design, Semantics, Implementation , 1992, Sci. Comput. Program..

[8]  S. Malik Analysis of cyclic combinational circuits , 1993, Proceedings of 1993 International Conference on Computer Aided Design (ICCAD).

[9]  Paul Le Guernic,et al.  Distributed Implementation of SIGNAL: Scheduling & Graph Clustering , 1994, FTRTFT.

[10]  Pascal Aubry,et al.  Synchronous distribution of SIGNAL programs , 1996, Proceedings of HICSS-29: 29th Hawaii International Conference on System Sciences.

[11]  Thomas R. Shiple,et al.  Constructive analysis of cyclic circuits , 1996, Proceedings ED&TC European Design and Test Conference.

[12]  Albert Benveniste,et al.  Compositionality in Dataflow Synchronous Languages: Specification and Code Generation , 1997, COMPOS.

[13]  Laurent Pautet,et al.  Cronos: A Separate Compilation Toolset for Modular Esterel Applications , 1999, World Congress on Formal Methods.

[14]  Stephen A. Edwards,et al.  The semantics and execution of a synchronous block-diagram language , 2003, Sci. Comput. Program..

[15]  Stephen A. Edwards,et al.  The synchronous languages 12 years later , 2003, Proc. IEEE.

[16]  P.J. Mosterman,et al.  Using interleaved execution to resolve cyclic dependencies in time-based block diagrams , 2004, 2004 43rd IEEE Conference on Decision and Control (CDC) (IEEE Cat. No.04CH37601).

[17]  Edward A. Lee,et al.  Leveraging synchronous language principles for heterogeneous modeling and design of embedded systems , 2007, EMSOFT '07.

[18]  Stavros Tripakis,et al.  Modularity vs. Reusability: Code Generation from Synchronous Block Diagrams , 2008, 2008 Design, Automation and Test in Europe.

[19]  Stavros Tripakis,et al.  Modular Code Generation from Triggered and Timed Block Diagrams , 2008, 2008 IEEE Real-Time and Embedded Technology and Applications Symposium.

[20]  Marc Pouzet,et al.  Clock-directed modular code generation for synchronous data-flow languages , 2008, LCTES '08.

[21]  TripakisStavros,et al.  Modular code generation from synchronous block diagrams , 2009 .