added to an output place. The arc expressions on input
arcs of a transition together with the tokens residing
in the input places determine whether the transition
is color enabled. For a transition to be color enabled
it must be possible to find a binding of the variables
appearing on each input arc of the transition such that
it evaluates to at least one token color present in the
corresponding place. When the transition fires with
a given binding, it removes from each input place a
colored token to which the corresponding input arc
expression evaluates. Firing a transition adds to each
output place a token whose color is obtained by eval-
uating the expression (defined over variables of input
arcs) on the corresponding output arc. In our exam-
ple, the variables d1 and d2 are bound to the value
of the token (value 5) in place counter. When one of
the transitions, say add fires, it produces a token with
value d1 + 1 = 6 in the place counter. Furthermore,
transitions are also allowed to have a guard, which is a
Boolean expression. When a guard is present it serves
as an additional constraint that must evaluate to true
for the transition to be color enabled. In our example,
the guard d1 < 10 ensures transition add can fire if
the value of the token in place counter is less than 10.
In addition, tokens also have a timestamp that
specifies the earliest possible consumption time, i.e.
tokens in a place are available or unavailable. The
CPN model has a global clock representing the cur-
rent model time. The distribution of tokens over
places together with their time stamps is called a
timed marking. The execution of a timed CPN model
is determined by the timed marking and controlled by
the global clock, starting with an initial value of zero.
In a timed CPN model, a transition is enabled if it is
both color enabled and the tokens that determine this
enabling are available for consumption. The time at
which a transition becomes enabled is called its en-
abling time. The firing time of a timed marking is the
earliest enabling time of all color enabled transitions.
When the global clock is equal to the firing time of a
timed marking, one of the transitions with an enabling
time equal to the firing time of the timed marking is
chosen non-deterministically for firing. The global
clock is not advanced as long as transitions can fire
(eager semantics). When there is no longer an en-
abled transition at the current model time, the clock is
advanced to the earliest model time at which the next
transition is enabled (if no such transition then it is
a deadlock), i.e. the firing time of the current timed
marking. The time stamp of tokens are written af-
ter the @ symbol in the following form x‘y@z, inter-
preted as x tokens having token color y carry a times-
tamp z. When an enabled transition fires, the pro-
duced tokens are assigned a color and a timestamp by
evaluating the time delay interval, inscribed on out-
going arcs of a transition (see time interval @[a,b]).
The time stamp given to each newly produced token
along an output arc is the sum of the value of the cur-
rent global clock and a value chosen from the delay
interval associated with that arc. Note that the firing
of a transition is instantaneous, i.e., takes no time.
3 EXPRESSING SIMULINK
MODELS USING PETRI NETS
In this section, we describe the basic concepts under-
lying a Simulink model, namely signals, blocks and
system. For these concepts, we give a formal seman-
tics using the CPN formalism. First, we show how a
Simulink block can be modeled as a CPN, which we
will call a P-block. A few simple rules describe how
a set of P-blocks can be connected to construct a sys-
tem, which we will call a P-system. The blocks of a
Simulink system are executed in a certain order called
the block execution order. We show how the block ex-
ecution order of a Simulink system can be modeled as
a CPN, on top of an existing P-system. The resulting
system describes fully the behavior of a simulation in
Simulink and we call it a C-system.
3.1 Signals, Blocks and System
Signals and Blocks are the two basic concepts of a
Simulink model. A signal is a step function in time,
representing the behavior of a variable. So only at
discrete points in time, the value of a variable may
change. Furthermore, a signal in Simulink can have
one of the following types: integer, real, complex or
its multi-dimensional variants.
A block defines a relationship between a set of
signals and possibly a variable representing its state
(state variable). If a block has a state variable then
it is a stateful block, otherwise it is a stateless block.
The set of signals belonging to a block are either of
type: input or output. A block can have zero or more
inputs and at most one output and one state variable.
A stateless block defines an output function f :
I
n
→ O, where I is the set of inputs, O is the set of
outputs and n is the number of inputs of the block. A
stateful block defines an output function f : I
n
× S →
O and an update function g : I
n
×S → S, where I is the
set of inputs, O is the set of outputs, S is the set of state
variables and n is the number of inputs of the block.
The output function of a stateful block must be evalu-
ated before its update function is evaluated. The result
of evaluating the update function of a stateful block
(say unit delay block as in the Fig. 2), updates its state
SIMULTECH2014-4thInternationalConferenceonSimulationandModelingMethodologies,Technologiesand
Applications
14