Model-based code generation (MBCG) is a new field of research that arises from the advancement of high-level modeling languages. It is the syntactical transformation of a source model into some textual representation or program. Its applicability ranges from accelerating execution, targeting various platforms to enhancing model interoperability. MBCG is a key agent in sharing models across different research communities and maximizing the impact of the model-based design methodology. However, because of the raised level of abstractions, code generation in a model-based environment brings up a new set of problems beyond traditional compiler research.

Using Ptolemy II as an exemplar modeling environment, this report explores the challenges and problems that exist for model-based code generation. The report describes a reusable code generation framework built using two simple design patterns, code template and adapter, that are well-suited for an actor-based environment. The extensible infrastructure helps simplify the process for future experiments, especially for new models of computation (MoCs). The report tackles the challenges posed by configurable higher-order actors. It also demonstrates a system for incorporating multiple datatypes and specializing polymorphic functions to increase code efficiency.




Download Full History