Professional Documents
Culture Documents
Lab 10
Lab 10
Software Required:
Ptolemy
Introduction:
Finite State Machines (FSMs) represent a fundamental concept in computer science
and engineering, offering a formalism for modelling and understanding systems with
discrete states and transitions. FSMs find extensive applications in various fields,
including digital circuit design, control systems, protocol specifications, and software
engineering. At their core, FSMs consist of a finite number of states, transitions
between these states triggered by input events, and associated actions or outputs.
Ptolemy is a versatile simulation environment widely used for modelling and
analysing complex systems, including FSMs. Its graphical interface and extensive
library of modelling components make it a powerful tool for exploring the behaviour
of FSMs in a simulated environment. Ptolemy supports the creation of FSM models
through its intuitive graphical interface, allowing users to define states, transitions,
input events, and output actions in a visual manner.
In this experiment, we aim to leverage the capabilities of Ptolemy for the analysis of
FSMs by implementing and simulating three distinct FSM models: the Capricious
Thermostat, Extended FSM, and Hierarchical FSM. By utilizing Ptolemy, we can
observe and analyse the dynamic behaviour of these models under various input
conditions, gaining insights into their state transitions, system dynamics, and overall
functionality. This experiment serves to deepen our understanding of FSMs and their
practical applications while also exploring the effectiveness of Ptolemy as a
simulation tool for FSM modelling.
Procedure:
1.Launch Ptolemy Software: Begin by opening the Ptolemy software on your
computer system.
4.Load the Model: Load the Capricious Thermostat model into the Ptolemy
simulation environment by double-clicking on the model file or selecting it and
clicking "Open."
Flow Diagram:
Actor Diagram:
Sample code:
Director:
Output:
2. Extended FSM:
A simple example of an extended state machine. In this example, the FSM has a parameter
called count. The transition from the initial state init to the counting state initializes count to 0
in its set action. The counting state has two outgoing transitions, one that is a self-transition,
and the other that goes to the state called final. The self-transition is taken as long as count is
less than 5. That transition increments the value of count by one in its set actions. In the firing
after the value of count reaches 5, the transition to final is taken. At that firing, the output is
set equal to 5. In subsequent firings, the output will always be 5, as specified by the self-loop
on the final state. This model, therefore, outputs the sequence -1,-2,-3,-4,-5,-6,5,5,5,5.
Flow Diagram:
Actor Diagram:
Sample code:
Director Inference:
We have used a SDF Director for this FSM model with the parameters as under. It run
for 10 iterations which is very well justified by the output.
Output:
3. Hierarchical FSM:
Flow Diagram:
Actor Diagram:
Sample code:
Director:
Output:
Inference:
In conclusion, utilizing Ptolemy software for modelling and simulating Finite State Machines
(FSMs) provides valuable insights into system behaviour and dynamics. Through the analysis
of pre-built example models such as the Capricious Thermostat, Extended FSM, and
Hierarchical FSM, we gain a deeper understanding of FSM principles and their practical
applications. Ptolemy's intuitive interface and simulation capabilities enable efficient
exploration of FSM behaviour, allowing for the identification of patterns and differences
between models. This experience underscores the effectiveness of Ptolemy as a tool for FSM
analysis and highlights its potential for studying complex systems in various engineering
domains.