EE382V:Embedded System Design and ModelingAndreas GerstlauerElectrical and Computer EngineeringUniversity of Texas at [email protected] 2 – Models of Computation, LanguagesEE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 2Lecture 2: Outline• Overview• Modeling, computational models, languages• Models of Computation (MoCs)• Process models• State machine models• System-Level Design Languages (SLDLs)• Goals, requirements• Communication and computationEE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 3Modeling• Design models as an abstraction of a design instance• Representation (model) of some aspect of reality– Virtual prototyping of what has been decided• Specification for further implementation/synthesis– Describe desired functionality of what still to build Usually a combination of both Different parts of the model or different use cases for the same model• Needed in every step of the design process Documentation and specification of outputs and inputs Capability to capture complex systems Precise, complete and unambiguous Observability and predictability to reason about properties Validation through simulation Analysis through formal methodsEE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 4Models of Computation (MoCs)• Define a class of models• Formal, abstract description of a system– Decomposition into pieces and their relationship– Well-defined objects and composition rules • Various degrees of– supported features– complexity– expressive power• Examples• Sequential, imperative program models– Sequence of statements that manipulate program state• Process models: networks, dataflow, calculi– Concurrency, data dependencies/causality• State machine models: evolution from FSM to PSM– Control flow and state enumerationEE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 5Models vs. Languages• Computation models describe system behavior• Conceptual notion, e.g., recipe, sequential program• Languages capture models• Concrete form, e.g., English, C• Variety of languages can capture one model• E.g., sequential program model C,C++, Java • One language can capture variety of models• E.g., C++ → sequential program model, object-oriented model, state machine model• Certain languages better at capturing certain modelsModelsLanguagesRecipeSpanishEnglish JapanesePoetry Story Sequent.programC++C JavaStatemachineData-flowRecipes vs. English Sequential programs vs. CSource: T. Givargis, F. Vahid. “Embedded System Design”, Wiley 2002.EE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 6Text vs. Graphics• Models versus languages not to be confused with text versus graphics• Text and graphics are just two types of languages– Text: letters, numbers– Graphics: circles, arrows (plus some letters, numbers)Source: T. Givargis, F. Vahid. “Embedded System Design”, Wiley 2002.…X = 1;if (N) Y = X + 1;…N?X =1Y = X + 1EE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 7Lecture 2: Outline Overview• Models of Computation (MoCs)• Process models– Process networks– Dataflow– Process calculi• State machine models: evolution from FSM to PSM– Finite State Machine (FSM)– FSM with Data (FSMD)– Super-state FSMD– ...– Program State Machine (PSM)• System-Level Design Languages (SLDLs)EE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 8Process Models• Set of processes• Processes execute in parallel– Concurrent composition• Each process is internally sequential– Imperative program• Inter-process communication?• Shared variables– Synchronization: critical section/mutex, monitor, …• Message passing– Synchronous, rendezvous (blocking send)– Asynchronous, queues (non-blocking send) Examples: MPI, Java Implementation: OS processes or threads Single or multiple processors/coresProducerConsumerProcess1 Process2EE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 9Deadlocks• Circular chain of 2 or more processes which each hold a shared resource that the next one is waiting for• Circular dependency through shared resources Prevent chain by using the same precedence Use timeouts (and retry), but: livelock Dependency can be created when resources are shared Side effects, e.g. when blocking on filled queues/buffersm2.lock();m1.lock();…m1.unlock();m2.unlock();m1.lock();m2.lock();…m2.unlock();m1.unlock();EE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 10Non-determinism• Deterministic: same inputs always produce same outputs• Random: probability of certain behavior• Non-deterministic: undefined behavior (for some inputs)• Undefined execution order – Statement evaluation in imperative languages: f(a++, a++)– Concurrent process race conditions: Can be desired or undesired How to ensure correctness? Simulator must typically pick one behavior But: over-specification? Leave freedom of implementation choicex = a;y = b;a = 1;b = 2;x = ?, y = ?EE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 11Kahn Process Network (KPN) [Kahn74]• C-like process description (Algol)• Unbounded (infinite), uni-directional, point-to-point FIFO queues (channels) for communication• Sender (send()) never blocks• Receiver (wait()) blocks until data available Deterministic• Process can’t peek into channels and can only wait on one channel at a time• Output data produced by a process does not depend on the order of its inputs Terminates on global deadlock: all process blocked on wait() Formal mathematical representation• Process = continuous function mapping input to output streamsEE382V: Embedded Sys Dsgn and Modeling, Lecture 2 © 2008 A. Gerstlauer 12Kahn Process Networks (KPN) (2)• Turing-complete, undecidable (in finite time)• Terminates?• Can run in bounded buffers (memory)?• Scheduling [Parks95]• Start with smallest bounded buffers• Schedule with blocking send() until (artificial) deadlock• Increase size of smallest blocked buffer and continue Behavior does not depend on scheduling strategy Focus on causality, not order (implementation issue) Difficult to schedule (Park’s algorithm) Dynamic memory allocation Memory usage depends on scheduling
View Full Document