Building Components From Functions
Building Components From Functions
Bernhard Schätz
Technische Universität München, Fakultät für Informatik, Boltzmannstr. 3,
D-85748 Garching bei München, Germany
schaetz@in.tum.de
Abstract
In the domain of embedded software systems the increasing complexity of the func-
tionality as well as the increase in variations caused by product lines requires a
modular design process, separating function-based and component-based design.
As a consequence, functional integration becomes a central task in the development
process, to avoid unforeseen interaction. While currently functional integration of-
ten is delayed to module integration, leading to a late detection of interactions, here
we suggest a methodical approach to the early integration of functions to construct
a logical component-oriented architecture.
1 Introduction
Substituting control hardware by software has led to a new level of customiz-
ability in the domain of embedded systems; especially in application domains
like automotive industry with customer-related areas like comfort electron-
ics, the possibility to offer variant combinations of functions (or features) like
power window, child protection, or blocking-detection, has become an impor-
tant market factor. To meet the demand for increasing numbers of variations
combined with a reduced time-to-market, a development process explicitly
supporting the combination of functionalities into components is necessary.
Therefore, domain-specific engineering approaches like [12] explicitly distin-
guish between a Functional Architecture and a Logical Architecture.
While a modular description of functionality enables a flexible combination
of functions, it requires an explicit integration of these functions to deployable
components to avoid unwanted interactions of functions. However, approaches
like [12] do not provide a clear distinctions between functions and components.
Currently, functions are often treated like components, requiring the manual
introductions of additional ‘coordinator’ components to ensure the compat-
2 Preliminaries
Since we are interested in supporting a constructive approach to build compo-
nents from modular pieces of behavior, in this section we introduce building
blocks called functions. To that end, we first informally contrast functions to
components from a methodical perspective; we then give a formal and com-
positional definition of functions based on [4].
2
[11]. However, as a result, the combinations of functions (e.g., manual control
function of a car window, switch-off function at final position of window) may
lead to conflicts (e.g., upward movement of window by manual control vs. stop
of movement by switch-off a highest position) resulting in undefined behavior.
To define a formal framework for the construction of functions, in the fol-
lowing subsection we introduce a basic model, and then supply some operators
for the construction of complex functions from basic ones.
2.2.1 Basics
The structural aspects of a function are defined by its input ports In, its
output ports Out – with In ∩ Out = ∅ –, its variables Var – with In ∪ Out ⊆
V ar as special monitored and controlled variables – as well as its control
locations Loc. To describe the behavior of a function, we use the notions
State: A state s ∈ S = Var → Val maps variables to their current values. 3
Observation: An observation is a either a triple (a, t, b) consisting of a
finite sequence t of states corresponding to an execution starting at location
a and ending at location b, changing variables according to t; or it is a
pair (a, t) consisting of an infinite sequence t of states, corresponding to a
non-terminating execution starting at location a.
Behavior: The behavior of a function is the set Obs its observations.
The most simple function is the trivial function nil with Var (nil ) = Loc(nil ) =
Obs(nil ) = ∅. For a state s : V ar → V al with V ar0 ⊆ V ar we use notation s ↑
V ar0 for restrictions (s ↑ V ar0 )(v) = s(v) for all v ∈ V ar0 . This restriction is
extended to sequences of states through point-wise application. For sequences
r and t we use the notation r ◦ t to describe the concatenation of r and t.
2
[5] defines the data interface via ports, the control interface via connectors.
3
For reasons of brevity, we assume that all ports and variables are of the same type.
3
But But
Stop TimeOut
int timer; int timer;
start end start exit
timer>0:But?Stp: timer=0: :
Mot!Zr:timer=0 Mot!Zr:
Mot Mot
4
pre and post are obtained from the corresponding terms by interpretation over V ar, and
(V ar, V ar0 ), resp.
4
But But
Halt Halt
int timer; int timer;
end
Stop timer>0:But?Stp: timer>0:But?Stp:
end
Mot!Zr:timer=0 Mot!Zr:timer=0
start start timer=0: :
TimeOut timer=0:: Mot!Zr:
Mot!Zr: exit exit
Mot
Mot
5
But But PosD
Stop Hold
int timer; timer>0:But?Stp: int timer;
start end
Mot!Zr:timer=0
Stop timer>0:But?Stp:
Mot Mot!Zr:timer=0
PosD start end
Abort :PosD?On
Abort :PosD?On:
end Mot!Zr:
start Mot!Zr:
Mot Mot
consists of input ports In = {But, PosD} of Stop and Abort as well as output
port Out = {Mot}; its locations Loc = {start, end} are the shared locations
of these functions; its variable V ar = {timer} is the corresponding variable
of Stop. Formally, the simultaneous combination of two functions A and B
results in a function described by A | B that
• use the input and output ports as well as variables of each function: In(A |
B) = In(A) ∪ In(B)\Out(A | B), Out(A | B) = Out(A) ∪ Out(B), V ar(A |
B) = V ar(A) ∪ V ar(B)
• accesses their shared control locations: Loc(A | B) = Loc(A) = Loc(B)
• exhibits the combined behavior of each function: (a, t, b) ∈ Obs(A | B)
if (a, t ↑ V ar(A), b) ∈ Obs(A) and (a, t ↑ V ar(B), b) ∈ Obs(B); (a, t) ∈
Obs(A | B) if (a, t ↑ V ar(A)) ∈ Obs(A) and (a, t ↑ V ar(B)) ∈ Obs(B)
Intuitively, the combined functions offers observations that can be offered
by both functions. To ensure a well-defined function, we require condition
Loc(A) = Loc(B) for functions A and B to be simultaneously composable.
Note that unless we require the standard interface constraint (V ar(A)\In(A))∩
(V ar(B)\In(B)) = ∅ imposed for the composition of components, simultane-
ous combination of functions may result in output or variable conflicts, leading
to the introduction of (additional) partiality in the behavior of the combined
functions. Obviously, A | B and B | A as well as A | A and A are each
equivalent in the sense of exhibiting the same interface and behavior.
6
• accesses the control locations of A excluding l: Loc(A\l) = Loc(A)\{l}
• exhibits the behavior of A if entered/exited through locations excluding l
and continuing execution at l: (a, t1 ◦ . . . ◦ tn , b) ∈ Obs(A\l) if (a, t1 , l),
(l, tn , b) ∈ Obs(A) as well as (l, ti , l) ∈ Obs(A) for i = 2, . . . , n − 1; (a, t1 ◦
t2 ◦ . . .) ∈ Obs(A\l) if (a, t1 , l)) ∈ Obs(A) and (l, ti , l) ∈ Obs(A) for i > 1.
Obviously, (S\a)\b) and (S\b)\a) are equivalent in the sense of exhibiting the
same interface and behavior. We write A\{a, b} for (A\a)\b.
7
sition. While this approach also carries over to functions using simultaneous
composition as structural element, for reasons of brevity here we focus on
alternative composition. To define such a structural constraint, we use the
concept of structural integration of one description of a function into another.
Definition 3.1 (Structural Integration) The description of a function A
is called structurally integrated within the description of a function C if a
mapping f : F un ∪ Loc → F un ∪ Loc exists with
• f (B + D) = f (B) + f (D) for all function terms B and D
• f (B\l) = f (B)\f (l) for all function terms B and all locations l
• f (B\v) = F (B)\v for all function terms B and all variables v
• f (a, pre, post, b) = (f (a), pre0 , post0 , f (b)) for basic functions (a, pre, post, b)
8
Intuitively, full integration ensures that the elements of C removed during
structural integration do not influence the behavior of A. Thus, e.g., ba-
sic functions leading from hi × up to stop × idle with labels (PosD?On ∧
But?Stp, Mot!Zr) as well as (PosD?Of ∧ But?Stp, Mot!Zr) of function Window
of Figure 6 are equivalent to the basic function leading from up to idle with la-
bel (But?Stp, Mot!Zr) in function Manual of Figure 4, since the corresponding
signal is either On or Of.
4 Integrating Functions
As functions describe modules of behavior, their combination is the essential
part of the design of a functional architecture; while alternative combination
is used to model the activation/deactivation of functions, simultaneous com-
bination is used to model concurrently active functions. As mentioned in
Section 2, the simultaneous combination of functions does not correspond to
the composition of components since
• functions may share variables including output ports, while components
may only share input ports,
• and as a result combined functions may exhibit undefined behavior where
their constituting sub-functions do not, e.g., due to output conflicts.
As introduced in [11], functions are consistent if no new partiality is introduced
by their (simultaneous) combination. In the semantic setting introduced in
Section 2, consistency can be defined as follows.
Definition 4.1 (Consistency) Functions A and B are called consistent if
{(a, t ↑ In(X), b) | (a, t, b) ∈ Obs(X)} ⊆ {(a, t ↑ In(X), b) | (a, t) ∈ Obs(A |
B)} and {(a, t ↑ In(X)) | (a, t) ∈ Obs(X)} ⊆ {(a, t ↑ In(X)) | (a, t) ∈
Obs(A | B)}, for X ∈ {A, B}. ◦
Due to the structural constraints imposed for the composition of components,
components are consistent by construction. Therefore, when moving from the
functional design phase to the architectural design phase
• the synchronous combinations of functions not corresponding to architec-
tural compositions must be substituted,
• undefined behavior introduced by conflicts in the combination must be iden-
tified.
In the following subsection, we introduce a constructive approach to resolve a
description constructed using synchronous combination while maintaining as
much structure and behavior as possible, basically using the product construc-
tion for automata. Furthermore, we show how to identify possible conflicts
that may cause additional undefined behavior.
9
idle
Manual idle
But?Stp: Idle ButStp: Dwn
Up
Mot!Zr Mot!Zr
up idle dwn
But up idle idle dwn Mot
But?Up: But?Dn:
But?Up:Mot!Hi Mot!Hi But?Stp:Mot!Zr Mot!Lo But?Dn:Mot!Lo
10
stop
Position stop
Hi PosU?On Stop PosD?On Low
PosU :Mot!Zr :Mot!Zr low
hi hi stop low
PosU?Of:Mot!Zr PosD?Of:Mot!Zr
Mot
PosD stop ::Mot!Lo
::Mot!Hi stop
PosU?Of:Mot!Hi ::Mot!Zr PosD?Of:Mot!Lo
11
stop×idle
Window stop×idle
Hi×Up PosU?On, Stop PosD?On, Low×Dwn
PosU
hi× But?Of:Mot!Zr ×Idle stop But?Stp:Mot!Zr low×
hi×up up dwn low×dwn
:PosU?Of,But?Stp: ×idle :PosD?Of,But?Stp:
But Mot
Mot!Zr Mot!Zr
PosD stop stop
:PosU?Of, ×idle ×idle :PosD?Of,
:PosU?Of, But?Up:Mot!Hi But?Stp But?Dn:Mot!Lo :PosD?Of,
But?Up:Mot!Hi :Mot!Zr But?Dn:Mot!Lo
the labels of basic functions that are added by the other function.
Thus, from a development point of view, by unfolding a simultaneous com-
bination we can adapt functional descriptions that do not respect the (struc-
tural) restrictions for component composition, without changing the overall
behavior. As a result, unfolding helps to simplify the transition from the
functional design to the component based design in the development process.
Obviously, the construction of F leads to a functional description that
can be considerably simplified: due to clause iv of Definition 4.2, the basic
sub-functions of F are obtained by conjunction of the corresponding basic
sub-functions of F1 and F2 . Thus, e.g., when combining the basic functions
(dwn, (But?Dn, Mot!Lo), dwn) of function Manual and (hi, (PosU?Of, Mot!Hi), hi)
of function Position, this results in (hi × dwn, (PosU?Of ∧ But?Dn, Mot!Lo ∧
Mot!Hi), hi × dwn). As Mot!Lo ∧ Mot!Hi requires that at port Mot simultane-
ously signals Hi and Lo are sent, the combined basic function is not satisfiable
since Hi 6= Lo. Therefore, this basic function does not contribute to the overall
behavior of Window. To simplify the description of the unfolded function, sub-
functions that do not contribute to the behavior of the system are removed
from the description. By iteratively removing basic functions with unsatisfi-
able pre∧post, unreachable functions, or empty functions, a simplified version
– as already shown in Figure 6 – is obtained without changing its behavior.
Note that here we only use a local criterion for the detection of conflicts:
we analyze the satisfiability of a transition without considering the actual state
space of the combined functions. Obviously, local satisfiability is a necessary
prerequisite of global satisfiability; as thus local unsatisfiability is a sufficient
criterion for global unsatisfiability, the strategy of simplification is safe, but
may miss unsatisfiable transitions.
12
hold
Window hold
Lift PosU?On Hold PosD?On Drop
:Mot!Zr
PosU
hi lift :Mot!Zr drop
hold drop
But :But?Stp:Mot!Zr :But?Stp:Mot!Zr
Mot
PosD :PosU?Of, hold
hold :PosD?Of,
:PosU?Of, But?Up:Mot!Hi But?Stp But?Dn:Mot!Lo :PosD?Of,
But?Up:Mot!Hi :Mot!Zr But?Dn:Mot!Lo
13
5 Conclusion and Related Work
The main contributions of the approach presented here target the constructive
transition from function-based to component-based descriptions of systems;
especially the presented approach
• illustrates a mechanism for an integration on the descriptional level
• introduces a corresponding mechanism to detect possible conflicts of simul-
taneously combined functions
with a focus on scalability.
14
like [9] focus on the support of non-simultaneous composition. Finally, those
approaches like [2] and [11] perform a precise analysis of the system under
development, leading to non-scalability; in contrast, here, we use a limited
technique ensuring correct development but supplying sufficient scalability in
practical applications.
References
[1] Barrett, C. and S. Berezin, CVC Lite: A New Implementation of the Cooperating
Validity Checker, in: Proceedings of the 16th International Conference on
Computer Aided Verification (CAV), 2004.
[4] Henzinger, T. A., Masaccio: A Formal Model for Embedded Components, in:
Proceeding of the First International IFIP Conference of Theoretical Computer
Science (2000), LNCS 1872.
[7] Mutz, M., M. Huhn, U. Goltz and C. Krömke, Model Based System Development
in Automotive, in: Proceedings of the SAE 2002 World Congress, Detroit, 2002.
15
[12] Thurner, T., J. Eisenmann, U. Freund, R. Geiger, M. Haneberg, U. Virnich and
S. Voget, The EAST-EEA Project - A Middleware Based Software Architecture
for Networked Electronic Control Units in Vehicles, VDI Berichte 1 (2003), (In
German).
16