Presentation is loading. Please wait.

Presentation is loading. Please wait.

STATE MACHINE AND CONCURRENT

Similar presentations


Presentation on theme: "STATE MACHINE AND CONCURRENT"— Presentation transcript:

1 STATE MACHINE AND CONCURRENT
PROCESS MODEL

2 INTRODUCTION MODELS vs LANGUAGES FINITE STATE MACHINE WITH DATA PATH MODEL USING STATE MACHINES PROGRAM STATE MACHINE MODEL CONCURRENT PROCESS MODEL CONCURRENT PROCESSES COMMUNICATION AMONG PROCESSES IMPLEMENTATION DATA FLOW MODEL REAL TIME SYSTEMS

3 Describing the processing behavior Assembly Language
Implementation Processor Describing the processing behavior Assembly Language High level languages Uses sequential computational model Increasing the complexity of ES Needs advanced computational models

4 Common method of describing the system
Uses English language computation model assists the designer understand and describe the behavior by providing means to compose the behavior from simpler objects.

5 1. Sequential program model
MODELS COMMONLY USED FOR DESCRIBING THE EMBEDDED SYSTEMS 1. Sequential program model It provides a set of statements, rules for putting statements one after other, semantics stating how statements are executed one at a time. 2. Communication process model it supports description of multiple sequential programs running concurrently 3. State machine model it is used commonly for control dominated systems. Control dominated system is the one whose behavior consists mostly of monitoring control inputs and reacting by setting control outputs.

6 Data flow model It is used for data dominated systems. The system behavior consists of transforming streams of input data into streams of output data Object oriented model which provides an elegant means for breaking complex software into simpler and well defined pieces State Machine Seq. Program Data Flow Poetry Recipe Story English Spanish Japanese C C++ JAVA Sequential program / c Model vs English

7 Models vs languages A computation model describes the desired system behavior while language captures models A model is a conceptual notion while a language captures that concept in the concrete form. A sequential program is a model, a conceptual notion consisting of a set of program instructions for computing something , and a notion of how to sequence among those instructions. Sequential program can be captured in any of the following languages like C, C++ or java . Particular language can capture many different models other than sequential programs such as state machines or data flow models. other languages such as C and assembly languages are more suited in some applications.

8 Recipes Vs English Poetry Recipe Story English Spanish Japanese

9 Sequential program vs C
State Machine Sequential Program Data flow C C ++ Java

10 TEXTUAL LANGUAGES vs. GRAPHICAL LANGUAGES
Methods to capture models Text and graphs State machine model Captured in textual language Captured in graphical language

11 TEXTUAL LANGUAGES vs. GRAPHICAL LANGUAGES
Languages may use variety of methods to capture models such as Text or Graphics. The choice of textual language vs. graphical language is entirely independent of the computational model used. Thee graphical language uses icons of objects, and icons for tasks. Graphical sequential languages were commonly proposed in 1980’s but have not become very popular. The state machine model is often captured in textual languages but it is also commonly captured in graphical languages

12 Button inside the elevator
Up Down Open Floor Unit control req Request resolver B2 B3 Bn Button inside the elevator Up1 Up2 Dn2 Up3 Dn3 Dn N Up, Down Buttons on each floor

13 Void unitcontrol () { up = down = 0; open = 1; while(1) while(req == floor) ; Open = 0; If( req > floor ) { up =1;} Else { down = 1; } While( req != floor) up = down =0; open = 1 ; delay (1); } Void response resolver () { While (1) Req = ; } Void main() Unitcontrol(); and Responseresolver();

14 A BASIC STATE MACHINE MODEL : FINITE STATE MACHINE
A finite state machine model: The system behavior can be described as a set of possible states. System can also be described possible transitions from one state to another state depending on the input values. Describe the actions that occur when in a state or transitioning between states.

15 THE FINITE STATE MACHINE CAN BE EXPRESSED AS 6 TUPLE
REQ > FLOOR !( REQ > FLOOR) GOING UP U, D, O, T = TIMER < 10 REQ > FLOOR !(TIMER < 10) IDLE DOOR OPEN U, D, O, T = REQ = FLOOR REQ < FLOOR U, D, O, T = GOING DN U, D, O, T = REQ < FLOOR THE FINITE STATE MACHINE CAN BE EXPRESSED AS 6 TUPLE F < ( S, I, O, F, H, so) S is the set of states, I is the set of inputs, O is the set of outputs, F is the next state function ( S x I -> S ), H is an output function S-> O maping current state to outputs. so is the initial state.

16 S is the set os states {so, s1, s2, ………}
I is the set of inputs { i0, i1, i2, …….,im} O is the set of out put states { o0,o1, o2, ………,on} Often FSM is used to describe the single purpose processor The hardware is synchronous reg. updates are synchronized to clock pulse. The FSM every transition condition and with clock.

17 Finite state machine with data path model
In an embedded system the inputs and outputs are Boolean type. This is sufficient for many control system applications.ne as set states For more complex data type the FSM is extended with data path model. The possible FSMD model is a F<S , I, O, V, F, H, So> Describe the machine behavior as a state machine and List all possible steps giving each descriptive name. Declare all variables For each state list the possible transitions, list the associated conditions. For each state or transition list the associated actions For each stat ensure that existing transition conditions are exclusive

18 COMPARING THE STATE MACHINE AND PROGRAMMING LANGUAGE
The state machine model is appropriative over sequential program model for describing control based system. It encourages the designer to think of all possible states of the system and to think of all possible transition among the states based on the possible input conditions. It provides the more natural means of computing for each case. In the sequential program model the system is designed to transform the data through a series of instructions that may be initiated or conditionally executed. It encourages a different way of thinking the behavior of the system.

19 #define IDLE 0 #define UP 1 #define DN 2 #define OPEN 3 void unitcontrol() { int stae=IDLE; While(1) { IDLE: up=0; down=0; open = 1;staRT =0; if(req==floor) { state = IDLE;} if(req > floor) { state = UP;} if(req < floor) {state = DN;} break; UP: up=1; down=0; open = 0; timerstart=0; if(!(req > floor)) {state = OPEN;} DN: up=1; down=0; open = 0; timerstart=0; if(req < floor) { state = DN;} if(!(req < floor)) {state = OPEN;} break; OPEN: up=0; down=0; open =1; timerstart=1; if(timer < 10) { state = OPEN;} if(!(timer < 10)) {state = IDLE;} }

20 HCFSM and the state charts language
Hierarchy extension in HCFSM allows to decompose the state machine into another state machine or a group of states into a new hierarchical states. Going up Idle Door open Hierarrc hy Going dn Fire Going dn Fire door open With out hierarchy

21 Going up Idle Door open Going dn Fire mode Fire Going dn
Fire door open

22 Using concurrency in HCFSM
! Fire Fire Unit control Request resolver Normal mode Fire Mode Using concurrency in HCFSM

23 If(req>floor){up=1;}
PROGRAM STATE MACHINE MODEL Elevator control It allows the programmer to use sequential code to define state actions, including extensions for the complex data types and variables. It includes hierarchy and concurrency. A SPM having only one state is called program state terminology. A PSM having many states whose actions are just assignment statements is equivalent to HCFSM. Unit control Normal mode Up=dn=0; open =1 While(1){ While(req==floor){ Open =0; If(req>floor){up=1;} Else {dn=1;} While(req !=floor) Open=1; Delay(10); Req. resolver req fire !fire Fire mode Up=0; dn=1; open=0 While(floor >1) ; Up=0;down=0; open =1

24 ROLE OF APPROPRIATE MODEL AND LANGUAGE
PSM INCLUDES TWO TYPES OF TRANSITIONS. Transition takes immediately if the condition is true. Transition immediately Transition on completion Transition takes ones the requested task is completed. ROLE OF APPROPRIATE MODEL AND LANGUAGE Model represent the system while the language captures the model. Language have constructs which captures the model.

25 CONCURRENT PROCESS MODEL
A systems functionality is described using multiple computation models It allows to describe the functionality of a system in terms of two or more concurrently executing sub tasks. It uses the multitasking scheme. State machine Seq. program Data flow Concurrent process Pascal C/C++ Java VHDL Implementation A implementation B Implementation C

26 The choice of the computation model is based on the designer to describe the system.
The choice of the language is to capture the computation model used by the designer The choice of implementation is based on whether it meets power and size and cost requirements.

27 Heart beat monitoring system
Task :1 Read pulse If pulse is lo then Activate siren If pulse > hi Sleep 1 sec repeat Task :2 If B1/B2 pressed then Lo = Lo+/- 1 If B3/B4 pressed then Hi = Hi+/- 1 Sleep 500 ms Set top box system Task :1 Read signal Separate audio/video Send audio to task :2 Send video to task :3 repeat Task :2 Wait on task 1 Decode/output audio Task :3 Wait on task 2 Decode/output video repeat

28 Process create and terminate. Process suspend and resume. Process join
BASIC OPERATIONS DEFINED BY THE CONCURRENT PROCESS MODEL Process create and terminate. Process suspend and resume. Process join COMMUNICATION AMONG PROCESSES Shared memory. Message passing.

29 SYNCHRONIZATION AMONG PROCESSES
One process must wait for another process to compute a value reach a point in execution, or signal some condition before it proceeds. Synchronization among concurrently executing processes is to use a construct : condition variables such as signal and wait.. One method to achieve synchronization is to monitor: It is nothing but collection of data and methods that operate on this data similar to an object in oop

30 X terminated and y is allowed Y waits and x is allowed
X waits and y is allowed X is allowed y waits Monitor Data Code Process - X Process - Y Waiting Monitor Data Code Process - X Process - Y Waiting X terminated and y is allowed Y waits and x is allowed

31 IMPLEMENTATION Process-1 Process-2 Process-3 Process-4 Process-1
Processor - A Processor - B Processor - C Processor - D General purpose processor Process-1 Process-2 Process-3 Process-4 Communication bus Process-1 Process-2 Process-3 Process-4 Communication bus Processor-A Process-1 Process-2 Process-3 Process-4 General purpose processor

32 Creating and terminating processes.
One way to implement multiple processors is to implement multitasking Often we encounter with multiple processes to be implemented with a single processor. To achieve the above is to share the processor to many processes . During the process of sharing the processor leads the concept of suspending and resuming the processes. In order to implement the above we need Operating System. The task of the OS is: Creating and terminating processes. Suspending and resuming the processes Joining processes. Scheduling the processes.

33


Download ppt "STATE MACHINE AND CONCURRENT"

Similar presentations


Ads by Google