320 likes | 548 Views
IT-606 Embedded Systems (Software). Krithi Ramamritham S. Ramesh Kavi Arya KReSIT/ IIT Bombay. Software Design for Embedded System. Computational Models . What are embedded systems? . Computer (programmable part) surrounded by other subsystems, sensors and actuators
E N D
IT-606Embedded Systems(Software) Krithi Ramamritham S. Ramesh Kavi Arya KReSIT/ IIT Bombay Software Design for Embedded System
What are embedded systems? • Computer (programmable part) surrounded by other subsystems, sensors and actuators • Computer a (small) part of a larger system. • The computer is called a micro-controller Controller's function is : • to monitor parameters of physical processes of its surrounding system • to control these processes whenever needed.
Design Challenges Embedded Systems are quite complex : 1. Correct functioning is crucial • safety-critical applications • damage to life, economy can result 2. Real-time systems • not only rt. outputs but at rt. time • imagine a delay of few minutes in pacemaker system 3. They are concurrent systems • System and environment run concurrently • multi-functional
Design Challenges 4. They are Reactive Systems • Once started run forever. • Termination is a bad behavior. • Compare conventional computing (transformational systems)
Design Challenges 5. Stringent resource constraints • compact systems • simple processors • limited memory • quick response • good throughput • low power
Embedded System Design • involves HW and SW Design • Software for • Hardware for speed • Co-design of Software and Hardware • nonstandard HW - ASIC • System Partitioning - difficult step • Choice of programmable parts and ASICs
Communication between ASIC and SW • Timing is crucial • Common languages for HW and SW • HardwareC, SpecC, SpecCharts, • Statecharts
Design of Embedded Software • Systems are Complex • Classical design methodologies: • Informal requirements • Informal design • Formal final code • Verification of the code by Testing
Totally inadequate for complex systems • Ambiguous, inconsistent • Thorough reviews required for early bug removal • Bugs often revealed late while testing • Several bugs remain undetected • Heavy redesign cost
Model-based Development • Designs captured through models • Models describe behaviours of objects • Models are abstract and high level descriptions • Focus on one aspect at a time • Precise and executable
Model-based Development • Models can be validated (Simulation, Formal Verification) • Models can be debugged and revised • Automatic generation of final code The paradigm Model - Simulate - Debug - Code - Generate Pardigm
Modeling Languages • Various languages exist • Squential programming languages (C, C++), • assembly languages • State Machines, Statecharts, Esterel • Data FLow Diagrams, Lustre, Signal • Hardware description languages (VHDL, Verilog) • Unified Modeling Languages (UML)
Modeling Languages Choice of languages depend upon the nature of computations Seq. programming models useful for standard computations But not suitable for embedded software
Reactive Systems • Standard Software is a transformational system • Embedded software is reactive I O T. S.
ES features • Reactive • Concurrency (at least system and environment) • Event driven • Events at unpredictable times • Timely response (hard and soft real time) • Criticality Conventional models inadequate
Finite State Machines Model • One of the well-known models • Intuitive and easy to understand • Pictorial appeal • Can be made rigorous • Standard models for Protocols, Controllers, HW
An Example Model • Elevator Controller
An Example Model • 3- floor elevator, Si– in floor i • ri - request from floor i • uj,dj - up/down by j floors • This machine is nondeterministic • In S 2 when requests r1 and r3 arrive. • Non-determinism due to abstraction • More than one behaviour for a given input
Features of FSMs • Finite number of states • Initial state • No final state (reactive system) • Non determinism (result of abstraction) • Edges labeled with events • Behavior defined by sequences of transitions • Rigorous semantics • Easy to simulate and debug • Code generation possible
C-implementation main() enum floors f1,f2,f3; enum State first,second,third; enum bool ff,tt; enum floors req, dest; enum bool up, down = ff; enum State cur_floor =first;
C-implementation req = read_req(); while (1) switch (cur_floor) Case first: if (req == f2) up = tt; dest = f2; else if (req == f3) up = tt; dest = f3; else up == ff; Down = ff;; break; case second: if (req == f3) up = tt; dest = f3; else if (req == f1) up = ff; down = ff;;
C-implementation dest = f1; else up == ff; down = ff;; break; case third: if (req == f2) up = ff; down = tt; dest = f2; else if (req == f1) up = ff; down = tt; dest = f1; else up == ff; down = ff;; break; ; req = read_req();
Suitability of C • C is not natural for such applications • events and states all modeled as variables • states are implicit (control point decide the states) • no abstract description possible • too low level and commitment to details etc. • avoided for high level designs and protoypes • Exercise: Find the problems in this design and improve
Statecharts • FSMs fine for small systems • FSMs are with no structure • Large descriptions difficult to understand • Statecharts (Harel) • Hierarchical States • Concurrent Machines • Communication among concurrent components • UML statecharts
Extensions to Statecharts • various possibilities explored • adding code to transitions • to states • complex data types and function calls • SpecCharts, SpecC, SynchCharts • State Simulink
Other Models • Synchronous Reactive Models • useful for expressing control dominated application • rich primitives for expressing complex controls • Esterel - Esterl Studio • More on this later
Other Models • Data Flow models • useful expressing numerical computations • Lustre, Signal • SCADE • Discrete Event Models • VHDL, Verilog
Red Summary • Various models reviewed • Sequential programming models • State Machines • Hierarchical and Concurrent State Machines • Each model suitable for particular applications • State Machines for event-oriented control systems • Sequential program model, data model for function computation
Hierarchical machines for complex control behaviours • Choice should be made based upon application • In general, mixture of models required • Ptolemy tool, U. Berkeley