STATE MACHINE AND CONCURRENT

Slides:



Advertisements
Similar presentations
Embedded System, A Brief Introduction
Advertisements

2-Hardware Design of Embedded Processors (cont.) Advanced Approaches.
Give qualifications of instructors: DAP
Introduction to Data Flow Graphs and their Scheduling Sources: Gang Quan.
5-High-Performance Embedded Systems using Concurrent Process
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
Why Behavioral Wait statement Signal Timing Examples of Behavioral Descriptions –ROM.
CS533 - Concepts of Operating Systems
Introduction to Data Flow Graphs and their Scheduling Sources: Gang Quan.
SE-565 Software System Requirements More UML Diagrams.
What is Concurrent Programming? Maram Bani Younes.
High-Level Programming Languages: C++
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 8: State Machine and Concurrent Process Model.
© 2009 Matthew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen 1 Concurrency in Programming Languages Matthew J. Sottile Timothy G. Mattson Craig.
1 5-High-Performance Embedded Systems using Concurrent Process (cont.)
IAY 0600 Digitaalsüsteemide disain Event-Driven Simulation Alexander Sudnitson Tallinn University of Technology.
1 Real Time Systems Part 1. 2 Fadi’s HW 11 Solution line level source 1 #pragma CODE 2 #include // SFR declarations 3 extern unsigned char rd_buttons(void);
- 1 - Embedded Systems - SDL Some general properties of languages 1. Synchronous vs. asynchronous languages Description of several processes in many languages.
Java Software Solutions Lewis and Loftus Chapter 14 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Advanced Flow of Control --
C o n f i d e n t i a l 1 Course: BCA Semester: III Subject Code : BC 0042 Subject Name: Operating Systems Unit number : 1 Unit Title: Overview of Operating.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
13-1 Chapter 13 Concurrency Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads C# Threads.
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
IAY 0600 Digital Systems Design Event-Driven Simulation VHDL Discussion Alexander Sudnitson Tallinn University of Technology.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Chapter 4 Software. Introduction Program: is a set of sequence instructions that tell the computer what to do. Software: is a collection of programs,
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
1 5-High-Performance Embedded Systems using Concurrent Process (cont.)
Agenda  Quick Review  Finish Introduction  Java Threads.
2-Hardware Design of Embedded Processors (cont.) Advanced Approaches.
1 5-High-Performance Embedded Systems using Concurrent Process (cont.)
Software Development Environment
DDC 2223 SYSTEM SOFTWARE DDC2223 SYSTEM SOFTWARE.
Unit 2 Technology Systems
Visit for more Learning Resources
Programming & Scratch.
IAY 0600 Digitaalsüsteemide disain
Object-Oriented Analysis and Design
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
2-Hardware Design of Embedded Processors (cont.)
5-High-Performance Embedded Systems using Concurrent Process
Timing Model Start Simulation Delay Update Signals Execute Processes
CS101 Introduction to Computing Lecture 19 Programming Languages
Course: Introduction to Computers
Introduction to Operating System (OS)
Chapter 8: State Machine and Concurrent Process Model
IAY 0600 Digital Systems Design
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
5-High-Performance Embedded Systems using Concurrent Process (cont.)
Computer Programming.
Chapter 8: Introduction to High-Level Language Programming
Introduction to cosynthesis Rabi Mahapatra CSCE617
Shanna-Shaye Forbes Ben Lickly Man-Kit Leung
ECE 434 Advanced Digital System L08
“White box” or “glass box” tests
Programming Languages
VHDL Discussion Subprograms
Spring CS 599. Instructor: Jyo Deshmukh
What is Concurrent Programming?
Introduction to Sequential Circuits
Chapter 6: Programming Languages
VHDL Discussion Subprograms
What is Concurrent Programming?
Multithreading in java.
CS510 Operating System Foundations
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
Basic Concepts of Algorithm
Essential Issues in Codesign: Models
STATE MACHINE AND CONCURRENT PROCESS MODEL
Parallel execution Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Presentation transcript:

STATE MACHINE AND CONCURRENT PROCESS MODEL

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

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

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.

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.

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

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.

Recipes Vs English Poetry Recipe Story English Spanish Japanese

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

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

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

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

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();

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.

THE FINITE STATE MACHINE CAN BE EXPRESSED AS 6 TUPLE REQ > FLOOR !( REQ > FLOOR) GOING UP U, D, O, T = 1 0 0 0 TIMER < 10 REQ > FLOOR !(TIMER < 10) IDLE DOOR OPEN U, D, O, T = 0 0 1 0 REQ = FLOOR REQ < FLOOR U, D, O, T = 0 0 1 1 GOING DN U, D, O, T = 0 1 0 0 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.

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.

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

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.

#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;} }

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

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

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

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

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.

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

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.

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

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.

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

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

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

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.