COMP 763 B Modeling and Simulation Based Design
COMP 763 B - Modeling and Simulation Based Design Rule Based Operational Semantics Specification in Ptolemy Yanwar Asrigo 30 th April 2008
Overview • • Recap: Ptolemy Problem Statement Implementation Testing 30 th April 2008 2
[1] • Started at UC Berkeley by Prof. Edward Lee • Studies modeling, simulation, and design of concurrent, real-time, and embedded systems • Developed using Java and truly free software (GPL) • Special features: – Actor Orientation + Domain – Hierarchically Heterogeneous Model [1] Eker, J. , Janneck, J. , Lee, E. , Liu, J. , Liu, X. , Ludvig, J. , Nuendorffer, S. , Sachs, S. , Xiong, Y. : Taming Heterogeneity – The Ptolemy Approach. Proceedings of the IEEE 91(1) (Jan 2003) 127 -144. 30 th April 2008 3
Actor Orientation • Actors are concurrent components that communicate through ports by passing messages actor name data (state) parameters Input data ports Output data What flows through an object is streams of data • Actor-oriented view of a system decouples the transmission of data from the transfer of control. 30 th April 2008 4
Domains • Domains provide semantic models for component interactions. Domain is realized by: – Director: governs the execution of a composite entity – Receiver: implements the communication semantics Director D 1 Controls the execution order of actors A 1 and A 2 Director D 2 controls the execution of A 3 and A 4 whenever A 2 is executed. 30 th April 2008 5
Actor Execution Initialization Execution Finalization Iterate() prefire() postfire() Despite computation occurs during the fire() phase, the state of the actor is not updated until postfire() • The domain of a composite actor determines how the iteration of one actor is related to the iterations of other actors in the same composite 30 th April 2008 6
Hierarchical Heterogeneous Composition CT • Divide a complex model into a tree of nested submodels FSM SDF 30 th April 2008 • Each level is composed of a network of interacting components • Network at each level is locally homogenous, while allowing different interaction mechanisms to be specified at different levels in the hierarchy 7
What is Missing? Meta-Modeling! The Ultimate Test Meta Model Transformation Intermediate Representation Code Generation Implementation 30 th April 2008 8
The Project • Using external tool for Meta-modeling formalisms and automatically synthesize the codes for Ptolemy Specifically: • Specify operational semantics using rules and compile these rules into Ptolemy’s code (Java) • Tools: ATo. M 3 and Motif • Target Formalism: Finite State Automata / Machine 30 th April 2008 9
Finite State Automata (Example) Alternate Mark Inversion (AMI) Coder 1/-1 Positive Negative 1/1 0/0 30 th April 2008 0/0 Input Output 0 0 1 1 1 -1 1 1 0 0 1 -1 10
Specifying and Compiling Operational Semantics Rules in ATo. M 3 Meta-model of domain specific notation Specify operational semantics as graph transformation rule Compiled rule-based operational semantics Finite State Automata Meta. Model Graph Grammar Rule defining FSM execution transformation Compiled GGRule in Java 30 th April 2008 11
Finite State Automata Meta Model * This can be transformed to UML class diagram which eventually can be used to generate the code 30 th April 2008 12
Initialization Rule 30 th April 2008 13
Update Rule 30 th April 2008 14
Motif [2] GG Compiler • Used Motif GG compiler to extract and compile rule defined in ATo. M 3 • Modified to produce Java code suitable for Ptolemy • Logic is mainly based on ATo. M 3 graph representation – Ptolemy data structure is modified to support this Rule + check. Condition() + execute. Action() + execute. LHS(ASG) + execute. RHS() [2] Eugène Syriani and Hans Vangheluwe. Programmed Graph Rewriting with DEVS. In Manfred Nagl and Andy Schür, editors, Applications of Graph Transformations with Industrial Relevance (AGTIVE 2007), Lecture Notes in Computer Science (LNCS). Springer-Verlag, October 2007. Kassel, Germany. 30 th April 2008 15
Modifications in Ptolemy (1) ASGNode <<interface>> ASG + get. Node. Types() + get. List. Nodes() State Legend : 30 th April 2008 + get. In. Connection() + get. Out. Connection() Transition New Classes Current Points_To Existing Ptolemy Classes 16
Modifications in Ptolemy (2) FSM Actor Initialization Execution prefire() Computation 30 th April 2008 Finalization postfire() Update State 17
Modifications in Ptolemy (2) FSM Actor Initialization Execution prefire() execute. LHS() execute. RHS() fire() Finalization postfire() execute. LHS() • • execute. RHS() Init. Rule Update. Rule + execute. LHS(ASG) + execute. RHS() fire() corresponds to the left hand side matching, and postfire() corresponds to transforming the matched sub-graph to right hand side of the transformation rule 30 th April 2008 18
Testing – AMI Coder 30 th April 2008 19
Testing – AMI Coder 30 th April 2008 20
Testing – AMI Coder Expected Result 30 th April 2008 Input Output 0 0 1 1 1 -1 1 1 0 0 1 -1 21
Thank You 30 th April 2008 22
- Slides: 22