The present invention relates to a semantic translation approach for diagrams associated with graphical modeling and simulation environments or tools. The semantic translation generates a model which may be used for further analysis such as test generation and formal verification.
Graphical modeling and simulation environments or tools allow users to construct and analyze models of processes or systems using diagrams. There are various examples of such tools commercially available. One such example is Simulink from The MathWorks, Inc. A further example of a graphical modeling and simulation environments is Lab VIEW, available from National Instruments Corporation.
Typically, these diagrams describe computations or logic which can ultimately be implemented using application specific devices, computers, microcontrollers, FPGA, integrated circuits, or computing devices. The diagrams are built using elements or blocks which are interconnected. The diagrams are created within a graphical modeling environment which defines the semantics for executing the diagrams. Software systems or descriptions of hardware systems may then be produced which exhibit the behavior of the model or portions thereof.
The Simulink diagrams can be simulated to generate sample-runs (runs on sample times) which provide a means for their validation. Other means of validation include testing and verification. In order to be able to test a Simulink diagram or verify an implementation of a Simulink diagram, it is desirable to translate such diagrams into a form amenable to automated test generation or verification. Thus the corresponding techniques and tools for such translation are needed.
Therefore, it is a primary object, feature, or advantage of the present invention to improve over the state of the art.
It is a further object, feature, or advantage of the present invention to a semantic translation approach which is recursive.
It is a still further object, feature, or advantage of the present invention to provide a semantic translation approach which is amenable to automated test generation and verification.
It is a still further object, feature, or advantage of the present invention to provide a semantic translation approach which has no special restriction on the types of blocks.
It is a still further object, feature, or advantage of the present invention to provide a semantic translation approach which is sound and complete.
According to one aspect of the present invention, a method of semantic translation of a diagram associated with a graphical modeling environment into an input/output-extended finite automata (I/O-EFA) model is provided. The method includes receiving a representation of the diagram and processing the representation of the diagram with a computing device by (a) representing all atomic blocks in said diagram as a tuple, (b) representing the diagram using a connecting rule and a conditioning rule, (c) determining an order in which the blocks included inside the diagram are executed, (d) translating the atomic blocks into the I/O-EFA model using a first algorithm, and (e) translating for the connecting rule and the condition rule using a second algorithm and a third algorithm, respectively to thereby modify the I/O-EFA model.
According to another aspect of the present invention, a computer-readable storage medium storing computer-executable instructions that are executed on a processing device is provided. The computer-executable instructions include instructions for receiving a data representation of a diagram, said diagram comprising a plurality of blocks and said diagram being associated with a graphical modeling environment which defines semantics for executing the diagram, and instructions for processing the data representation of the diagram to translate the diagram into an input/output-extended finite automata model.
According to another aspect of the present invention, a method of semantic translation of a diagram into input/output-extended finite automata (I/O-EFA) model is provided. The method includes: representing atomic blocks in the diagram as a tuple; representing the diagram using a connecting-rule and a conditioning-rule; determining an order in which the atomic blocks of the diagram are executed; translating the atomic-blocks into an I/O-EFA model; and translating for the connecting-rule and the conditioning-rule to adjust the I/O-EFA model. The steps may be performed by a computing device.
According to another aspect of the present invention, a method of translating a class of diagrams as input/output-extended finite automata is provided. The method includes receiving a data representation of a diagram, said diagram including a plurality of blocks and said diagram being associated with a graphical modeling environment which defines semantics for executing the diagram. The method further includes processing, using a computing device, the data representation of the diagram to translate the diagram into an input/output-extended finite automata model.
Although the present invention may be used with diagrams from any number of graphical environments, Simulink/Stateflow (S/S) diagrams are used as representative examples of such diagrams. Simulink/Stateflow (S/S) [2] diagrams are graphical representations of dynamical systems, and can capture both time-driven as well as event-driven dynamics of hybrid systems. Stateflow diagrams are used for representing and simulating event-driven dynamics. The S/S diagrams can be simulated to generate sample-runs (runs on sample times) which provide a means for their validation. Other means of validation include testing and verification. In order to be able to test a S/S diagram or verify an implementation of a S/S diagram, a model-based approach is desirable, where a model can be used for automated test generation or as a formal specification.
Simulink blocks can be time-driven or non time-driven. A time-driven block, such as an Integrator block, represents the time-dependent mathematical relationships between its inputs and outputs. On the other hand, non time-driven block, such as a Stateflow block or a Discrete Event Subsystem block, may evolve upon the occurrence of events. Here, we focus on study the semantic translation of time-driven blocks, and for conciseness, we write “Simulink blocks” to mean only the “time-driven Simulink blocks”.
We propose an approach for translating the behaviors of a Simulink diagram at (discrete) sample times to input/output-extended finite automata (I/O-EFA) [9, 15]. Note that a Simulink diagram can represent a hybrid system that combines event-driven discrete and time-dependent continuous behaviors, whereas I/O-EFA is a model of a reactive untimed infinite state system. Yet, since we are only interested in capturing the behaviors of a Simulink diagram at sample times, an I/O-EFA model (which is untimed) suffices.
Simulink provides a library of blocks (such as transfer functions, discontinuities, math operations, logic and bit operations etc.), which can be interconnected in a hierarchical fashion to form an overall Simulink diagram. We consider the blocks in the Simulink library to be “atomic”, and formally define an atomic-block. Further we formulate two rules, namely connecting-rule and conditioning-rule, used in Simulink for building complex blocks by combining the simpler ones, and formally define a class of Simulink diagrams formed using these rules. This recursive view of defining the class of all Simulink diagrams leads to a recursive translation in form of I/O-EFA.
In order to obtain an I/O-EFA model recursively, we first present an algorithm for translating an atomic-block to an I/O-EFA. Next for each rule of combining simpler Simulink diagrams to construct a complex Simulink diagram, we develop a corresponding rule for combining the I/O-EFA models of simpler Simulink diagrams to build the I/O-EFA model of the more complex Simulink diagram.
We introduce the concept of a step of an I/O-EFA to emulate the computation of a Simulink diagram at a sample time. A sequence of steps, namely, a step-trajectory, generates outputs over a sequence of sample times. We show that the translation approach is sound and complete: The input-state-output behavior of the I/O-EFA, defined in terms of a step-trajectory, preserves the input-state-output behavior of the corresponding Simulink diagram at each sample time (assuming the same integration method for any of the continuous blocks with dynamics).
Various aspects of the present invention include:
We present the notion of an input-output extended finite automaton (I/O-EFA) as a formal model of representation for a Simulink diagram. I/O-EFA is a model of a reactive untimed infinite state system in form of an automaton, extended with discrete variables such as inputs, outputs, and data. Using I/O-EFA as a model, many value-passing processes can be represented as finite graphs. An I/O-EFA consists of locations (i.e., symbolic-state), data (i.e., numeric-state), numeric-inputs, numeric-outputs, symbolic-inputs, symbolic-outputs, transitions, an initial location, initial data values, and a final location. The locations (symbolic-states) together with the data (numeric-states) form the state-space of a I/O-EFA. The locations are finite and form the vertices of the automaton graph. The edges of the graph represent transitions between the locations and are guarded by constraints over the data and the inputs. The occurrence of a transition triggers a data update and an output assignment.
Definition 1 An input/output extended finite automaton (I/O-EFA) is a tuple
P=(L,D,U,Y,Σ,Δ,l0,D0,lm,E)
where
Initially, P starts from the initial location l0 and an initial data value doεD0. While at a certain state (l,d)εL×D, a transition eεE such that oe=l is enabled if the input σe arrives, and the data d and input u are such that the guard Ge(d,u) holds. Note when σe=ε, the transition is enabled when only the guard Ge(d,u) holds; on the other hand when Ge(D,U)=True, then the transition is enabled when only σe arrives. An enabled transition can be executed. The execution of an enabled transition e at the state (oe,d) causes P to transit to the location te, the data value is updated to ƒe(d,u), the output variable is assigned the value he(d,u), and a discrete output δe is emitted.
Simulink provides a library of blocks, which can be used as minimal systems, and the corresponding Simulink diagrams will then be minimal Simulink diagrams. We refer to such blocks as atomic blocks. The atomic-blocks can be composed in a recursive fashion to construct more complex Simulink diagrams, and we discuss the rules of composition in the next section.
An atomic-block can be stateful or stateless. A stateful block's output depends on the history of its inputs. An example of a stateful block is the Unit Delay block. On the other hand, the output of a stateless block depends only on its current inputs. An example of a stateless block is the Gain block, which simply outputs its input signal, multiplied with a constant called the gain.
An atomic-block can be classified as continuous-time versus discrete-time, and is associated with a sample-period. For a continuous-time block, sample-period is the time between the instants when it is numerically simulated. For a discrete-time block, sample-period is the time between the instants when the corresponding discrete-time system evolves.
An atomic-block can be defined as follows.
Definition 2 An atomic Simulink block ψ can be represented as a tuple
(Uψ,Yψ,Dψ,D0ψ,{(Giψ,ƒiψ,hiψ)}i=1q
where
Also note for a stateless atomic-block ψ, the set Dψ is empty (and accordingly, there are no initial data conditions or data-update functions).
The following example illustrates the Definition 2.
The Integrator block provides a continuous-time integration of the input signal. It models the relations, {dot over (d)}(t)=u(t) with d(0)=d0, and y(t)=d(t), where u is its input, d is its data, y is its output, t is the continuous-time variable, and d0 is the initial data condition. Using Euler's Method the discretization is d(k+1)=d(k)+Tψu(k). Thus, the Integrator block can be represented as:
(u,y,d,d0,{(−,d(k+1)=d(k)+Tψu(k),y(k)=d(k))},(Tψ,T0ψ)),
where Tψ is the sample-period and T0ψ is an offset.
Note that the Integrator block can be configured further by setting certain parameters to have a more complex behavior. An example is the Integrator block ψ5 in
We introduce the following concepts for the computation of an atomic block over sample times.
Definition 3 Given an atomic-block ψ and an input uεUψ, we call the computation of the corresponding output yεYψ a step of ψ over u. y is called the output of a step of ψ over u. Given an input sequence {u(k)}k=0K, a step-trajectory of ψ over {u(k)}k=0K is a sequence of steps of ψ, where the kth step (0≦k≦K) in the sequence is over the input u(k). Letting y(k) (0≦k≦K) denote the output of ψ over u(k), {y(k)}k=0K is called the output of step-trajectory of ψ over {uk}k=0K.
A Simulink diagram, also called a system-block, can be constructed by recursively composing atomic-blocks and other simpler system-blocks according to certain rules. The following two rules are the among the rules that Simulink uses for the construction of complex Simulink diagrams from the simpler ones:
θ:=(Uθ,Gθ,ƒθ,hθ,(Tθ,Toθ)),
where
Next we formally define the class of Simulink diagrams (also referred to as system-blocks) formed using the above rules.
Definition 4 A certain class of Simulink diagrams (also referred to as system-blocks) is recursively defined as follows.
Note by the Simulink grammar, for a system-block
Consider the Simulink diagram ψ of a counter shown in
ψ={ψ1,ψ2}/C1,
where
Consider the multirate Simulink diagram ψ shown in
ψ belongs to the class of Simulink diagrams defined in Definition 4: ψ=Ψ/C, where Ψ={ψ1, ψ2, ψ3, ψ4, ψ5, ψ6, ψ7, ψ8} and C is omitted. U=, D=D3×D5×D6×D7 with D0={(0, 0, 0, 0)}. Note the sink block Scope for displaying the outputs is not considered as part of the Simulink diagram being translated, and hence not included in ψ.
Consider the Simulink diagram ψ of a bouncing ball shown in
where Ψ={ψ1, ψ2, ψ3, ψ4, ψ5, ψ6, ψ7} and C is omitted. U=, D=D1×D2 with D0={(15, 10)}.
When system-blocks are composed using the connecting-rule to form a more complex system-block, the input of one system-block becomes the output of another system-block. To respect the interdependency of the inputs/outputs, Simulink defines and uses the notion of an execution-order (which it refers as sorted-order) to determine the order in which the system-blocks included inside a connected system-block are executed. Note that the conditioning-rule does not require defining a sorted-order since it is applied to a single system-block.
Given a system-block Ψ/C formed using the connecting-rule, the sorted-order of the system-blocks {ψεΨ} is given as an ordering function Ord: Ψ→N, where N is the set of natural numbers. The sorted-order induces a total-order over Ψ, i.e., for ψ, ψ′εΨ, Ord(ψ)=Ord(ψ′) if and only if ψ=ψ′. Accordingly ψεΨ is executed before ψ′εΨ if Ord(ψ)<Ord(ψ′). The sorted-order value Ord(ψ) can be displayed, as part of a label ascribed to a system-block ψεΨ, by selecting the option Sorted Order from Simulink Block Displays menu. Assuming, without loss of generality of correctness of translation, that the Optimization on Conditional Execution Behaviors is turned off, the label ascribed to ψ has the format: Id(Ψ/C): Ord(ψ): {Id(ψ)}, where Id is a function that associates a certain identifier number to a system-block. The {Id(ψ)} part may be missing if ψ an atomic-block. Whenever we need to indicate the label ascribed to ψεΨ, we write it in the form: ψ [Id(Ψ/C): Ord(ψ){Id(ψ)}].
The notion of sorted-order is essential in defining the step of a system-block.
Definition 5 Given a system-block ψ and an input uεUψ, the step of ψ over u is recursively defined as follows:
Note in the 2nd item of Definition 5, when kTψ+T0ψ=kψ
Consider the Simulink diagram of ψ the counter shown in
ψ=Ψ1/C1={ψ1[0:1{1}],ψ2[0:2]}/C1,
ψ1=(Ψ2/C2)θ=({ψ3[1:0],ψ4[1:2],ψ5[1:1]}/C2)θ.
Then according to Definition 5 we have:
Consider the multirate Simulink diagram ψ of
ψ=ψ1[0:2],ψ2[0:6],ψ3[0:7],ψ4[0:8],ψ5[0:3],ψ6[0:4],ψ7[0:0],ψ8[0:5]}/C.
It then follows that a step of ψ is the sequence of steps of ψ7, ψ1, ψ5, ψ6, ψ8, ψ2, ψ3 and ψ4. Note for j=1, . . . , 8, a step of ψj is computed whenever kTψ=kψ
Consider the Simulink diagram ψ of the bouncing ball of
ψ={ψ1[0:7],ψ2[0:3],ψ3[0:2],ψ4[0:1],ψ5[0:5],ψ6[0:4],ψ7[0:0]}/C.
It then follows that a step of ψ is the sequence of steps of ψ7, ψ4, ψ3, ψ2, ψ6, ψ5 and ψ1.
We describe how a Simulink diagram can be semantically translated to an I/O-EFA.
For any system-block ψ, its I/O-EFA model is obtained by connecting two I/O-EFA models, one for output-assignments and other for state-updates. We use l0−ψ, lm−ψ to denote the initial/final location for first I/O-EFA, and l0+ψ, lm+ψ to denote the initial/final location for second I/O-EFA. The two I/O-EFA's are connected using two edges:
The 1st I/O-EFA of ψ is
P
−
ψ=(L−ψ,−,Uψ,Yψ,−,−,l0−ψ,−,lm−ψ,E−ψ),
where
The 2nd I/O-EFA of ψ is
P
+
ψ=(L+ψ,DP
where
The combined I/O-EFA model of ψ is
P
ψ=(Lψ,DP
where
Without loss of generality, we assume that if ((ψ, i),(ψ, j))εC, then yiψ=ujψ, i.e., the same variable has been used to denote the two signals.
Algorithm 2 For a connected system-block
The 1st I/O-EFA of
P
−
=(L−
where
The 2nd I/O-EFA of
P
+
=(L+
where
The combined I/O-EFA of
P
=(L
where
E
−
=∪ψE−ψ∪{(lm−ψ,l0−ψ′,−,−,−,−,−)|Ord(Ψ′)=Ord(Ψ)+1≦|Ψ|, and ψ,ψ′εΨ}, and
E
+
=∪ψE+ψ∪{(lm+ψ,l0+ψ′,−,−,−,−,−)|Ord(Ψ′)=Ord(Ψ)+1≦|Ψ|, and ψ,ψ′εΨ}.
Consider Ψ2/C2={ψ3, ψ4, ψ5}/C2 of Example 2, where Ord(ψ3)<Ord(ψ5)<Ord(ψ4). The I/O-EFA model for Ψ2/C2, obtained using Algorithm 2 for the connecting-rule and Remark 3, is shown in
Consider the multirate Simulink diagram of
Translating for Conditioning-rule. In the translation of a conditioned system-block
Algorithm 3 For a conditioned system-block
The 1st I/O-EFA model of
P
−
=(L−
where
The 2nd I/O-EFA model of
P
+
=(L+
where
The combined I/O-EFA model of
P
=(L
where
{(lm+ψ,l0−
(lm+ψ,l0−
Consider ψ1=(Ψ2/C2)θ of Example 2. The I/O-EFA model of Ψ2/C2 was obtained in Example 8, and the I/O-EFA model of ψ1, obtained using Algorithm 3 for the conditioning-rule, is shown in
Consider the Simulink diagram ψ={ψ1, ψ2}/C of the counter shown in
Consider the Simulink diagram ψ of the bouncing ball of
In order to show that the translating approach is sound and complete, we introduce the concept of a step and of a step-trajectory of an I/O-EFA model of a system-block. In the I/O-EFA model Pψ of a system-block ψ, each increment of k corresponds to an execution of a path π=(l0ψ, . . . , lmψ, l0ψ). A computation along the kth execution of such a path gives an output value y(k) for an input u(k).
Definition 6 Given an I/O-EFA model Pψ of a system-block ψ and input uε∪ψ, a step of Pψ over u is the computation of a sequence of edges starting from l0ψ and ending at lmψ, followed by the time-advancement edge. Given an input sequence {u(k)}k=0K, a step-trajectory of Pψ over {u(k)}k=0K is a sequence of steps, where the kth step (0≦k≦K) in the sequence is over the input u(k). Letting y(k) (0≦k≦K) denote the output of ψ over u(k), {y(k)}k=0K is called the output of step-trajectory of Pψ over {uk}k=0K.
Next we show that the input-output behavior of an I/O-EFA model at a sampling time, defined in terms of a step, preserves the input-output behavior of the corresponding Simulink diagram at the same sampling time, defined in terms of a step.
Lemma 1 Given a system-block ψ and an input u(k) and at the kth sampling time, let yψ(k) and yP
Proof: If ψ is an atomic-block, then from Algorithm 1 and Definitions 5 and 6, a step of both ψ and Pψ at the kth sampling time k compute: yψ(k)=hiψ(d(k),u(k)), where
if Giψ(d(k),u(k)) holds, and
i≦qψ.
If ψ=Ψ/C, then from Algorithms 2 and Definitions 5 and 6, a step of both ψ and Pψ over u(k) at the kth sampling time compute (yψ
(i) If kTψ+Toψ=kψ
if Giψ
i≦qψ
urψ
(ii) If kTψ+Toψ≠kψ
If
The following proposition shows that the input-output behavior of an I/O-EFA model over a sequence of sampling times, defined in terms of a step-trajectory, preserves the input-output behavior of the corresponding Simulink diagram over the same sequence of sampling times, defined in terms of a step-trajectory.
Proposition 1 Given a system-block ψ and an input sequence {u(k)}k=0K, let {y
Proof: The proof follows from Lemma 1 and Definitions 5 and 6.
To validate our model, a simulation for a certain input sequence (pulse with period 1.2 second and pulse width 25%) was obtained for the Simulink diagram ψ of
A simulation was obtained for the multirate Simulink diagram ψ of
A simulation was obtained for the Simulink diagram ψ of
We briefly introduce the works related to ours, discussing succinctly their features. [4] presented a translation algorithm for converting a restricted subclass of S/S diagrams into a semantically equivalent hybrid automaton. For the subclass of S/S diagrams considered there exists a clear separation between the discrete and the continuous dynamics: All mode changes are made through switches, and whose controlling variables are restricted to be the outputs of the Stateflow modules. In general, however, the discrete modes do not have to be determined by the output variables of the Stateflow modules, and switches do not have to be used to switch continuous dynamics. Our approach does not require a clear separation between discrete and continuous dynamics for modeling hybrid systems. Also our translation approach has no special restriction on the types of Simulink blocks. The approach supports virtually all blocks in Simulink Library (in this work we only consider time-driven blocks) provided that the block can be mathematically written as input-state-output functions over time. [5] described a translation scheme for deriving hybrid automata models from S/S models. However, no formal algorithms are provided. We presented formal algorithms for the translation. [3, 6, 13] describes a technique for translating discrete-time Simulink diagrams into Lustre programs. Lustre is a synchronous language and the translation is a mapping between elements of Simulink diagrams (for example, signals and atomic blocks) and Lustre programs (for example, flows and operators/nodes). The execution sequence of Simulink blocks in the Lustre programs is determined by Lustre compiler. Also only the discrete-time blocks are translated. In our approach, the execution sequence of Simulink blocks is directly captured in the I/O-EFA models. Also, our approach supports virtually all time-driven blocks in Simulink Library. [7] mentioned a translation of S/S diagrams into the language of “SAL [1] for the purposes of test generation. However, the details of the translation were not given. [8] reported translation of Simulink diagrams to a model of concurrent processes communicating with FIFO queues or registers, called SPI model, in contrast to I/O-EFA model in our approach. There has also been work on code-generation for simulink diagrams [12, 11]. One emphasis is in intellectual property reuse (i.e., code reuse for a group of atomic blocks) and so their approach is modular. In contrast we focus on formal modeling of Simulink diagrams with the goal of providing models that are readily amenable for further analysis (verification, test-generation, etc.).
We presented a recursive approach for translating a class of Simulink diagrams as input/output-extended finite automata (I/O-EFA), which is amenable to automated test generation or verification. We treat the blocks in the Simulink library to be “atomic” and formulate two rules used in Simulink for building complex blocks by combining the simpler ones. We provided a recursive and formal definition for the class of Simulink diagrams formed using these rules.
We presented algorithms for (i) translating an atomic-block as an I/O-EFA, (ii) combining the I/O-EFA models of simpler Simulink diagrams to build the I/O-EFA model of a more complex Simulink diagram, constructed using certain rules of composition. We introduced the concept of a step (resp., step-trajectory) of an I/O-EFA to emulate the computation of a Simulink diagram at a sample time (resp., over a sequence of sample times). We showed that the translating approach is sound and complete: The input-output behavior of an I/O-EFA model, as defined in terms of a step-trajectory preserves the input-output behavior of the corresponding Simulink diagram at each sample time (assuming the same integration method for any of the continuous blocks with dynamics). Finally, the translation approach has no specific restriction on the types of Simulink blocks or the structure of Simulink diagrams supported and can handle multirate Simulink diagrams, sample times with initial offsets and variable-step simulation etc.
Although various embodiments have been shown and described in detail, the present invention is not to be limited to the specific embodiments shown as the present invention contemplates numerous variations, options, and alternatives in its implementation as may be appropriate in various situations. For example, the present invention contemplates that different types of diagrams may be used. The methodology may be implemented in various types of computing devices using any number of types of software to provide instruction sets for performing the logic of the methodologies described herein.
References below are incorporated by reference in their entireties.
This application claims priority under 35 U.S.C. §119 of a provisional application Ser. No. 61/357,568 filed Jun. 23, 2010, and which application is hereby incorporated by reference in its entirety.
This invention was made with government support under Grant No. NSF-CCF-0811541 awarded by the National Science Foundation. The government has certain rights in the invention.
Number | Date | Country | |
---|---|---|---|
61357568 | Jun 2010 | US |