CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf ·...

168
1 CSE 237A Modeling Embedded Systems Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

Transcript of CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf ·...

Page 1: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

1

CSE 237A Modeling Embedded Systems

Tajana Simunic RosingDepartment of Computer Science and EngineeringUniversity of California, San Diego.

Page 2: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

2Tajana Simunic Rosing

ES Design

Verification and Validation

HardwareHardware components

Page 3: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

3Tajana Simunic Rosing

Models, Languages and ToolsSequent.program

Statemachine

Data-flow

Concurrent processes

C/C++Pascal Java VHDL

ImplementationA

Implementation B

Implementation C

Page 4: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

4Tajana Simunic Rosing

Elements of model of computation

Language: Synchronous vs. asynchronous languages

State Decidability Can a property be determined in a finite

amount of time?

Page 5: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

5Tajana Simunic Rosing

Modes of Communication

Page 6: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

6Tajana Simunic Rosing

Communication

Blocking

…send ()…

…receive ()…

…send ()…

…receive ()…

…send ()…

…receive ()…ack…process a {

..P(S) //obtain lock.. // critical sectionV(S) //release lock

}

process b {..P(S) //obtain lock.. // critical sectionV(S) //release lock

}

Message PassingNon-blocking

Shared memory

Extended rendezvous

Page 7: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

7Tajana Simunic Rosing

Implantable Cardioverter DefibrillatorFunction:

helps stop dangerously fast heart rhythms in the heart's lower chambers

treats sudden cardiac arrest and restores a normal heartbeat.

Guarantee device works 100% of the time for at least 7-10yrs

By Guidant CRM

Page 8: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

8Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri nets Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Discrete Event Systems

VHDL, Verilog, SystemC, SpecC Synchronous languages

Cycle based models, Esterel, Lustre

Page 9: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

9Tajana Simunic Rosing

Elevator controller

“Move the elevator either up or down to reach the requested floor. Once at the requested floor, open the door for at least 10 seconds, and keep it open until the requested floor changes. Ensure the door is never open while moving. Don’t change directions unless there are no higher requests when moving up or no lower requests when moving down…”

Partial English description

buttonsinside

elevator

UnitControl

b1

down

open

floor

...

RequestResolver

...

up/downbuttons on

eachfloor

b2bN

up1up2dn2

dnN

req

up

System interface

up3dn3

Page 10: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

10Tajana Simunic Rosing

Elevator controller using a sequential program model

buttonsinside

elevator

UnitControl

b1

down

open

floor

...

RequestResolver

...

up/downbuttons on

eachfloor

b2bN

up1up2dn2

dnN

req

up

System interface

up3dn3

Sequential program model

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

}}

void RequestResolver() {

while (1) ...

req = ......

}void main() {

Call concurrently:UnitControl() andRequestResolver()

}

Inputs: int floor; bit b1..bN; up1..upN-1; dn2..dnN;Outputs: bit up, down, open;Global variables: int req;

You might have come up with something having even more if statements.

Page 11: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

11Tajana Simunic Rosing

Classical automata

• Moore-automata:O = H(S); S+ = f(I, S)

• Mealy-automataO = H(I, S); S+ = f(I, S)

Internal state Sinput I output O

S0 S1

S2S3

e=1

e=1

e=1

e=10 1

23

clock

Page 12: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

12Tajana Simunic Rosing

Finite-state machine (FSM) model

Idle

GoingUp

req > floor

req < floor

!(req > floor)

!(timer < 10)

req < floor

DoorOpen

GoingDn

req > floor

u,d,o, t = 1,0,0,0

u,d,o,t = 0,0,1,0

u,d,o,t = 0,1,0,0

u,d,o,t = 0,0,1,1

u is up, d is down, o is open

req == floor

!(req<floor)

timer < 10

t is timer_start

UnitControl process using a state machine

Page 13: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

13Tajana Simunic Rosing

Template for FSM implementation in sequential programming

#define S0 0#define S1 1...#define SN Nvoid StateMachine() {

int state = S0; // or whatever is the initial state.while (1) {

switch (state) {S0:

// Insert S0’s actions here & Insert transitions Ti leaving S0:if( T0’s condition is true ) {state = T0’s next state; /*actions*/ }if( T1’s condition is true ) {state = T1’s next state; /*actions*/ }...if( Tm’s condition is true ) {state = Tm’s next state; /*actions*/ }break;

S1:// Insert S1’s actions here// Insert transitions Ti leaving S1break;

...SN:

// Insert SN’s actions here// Insert transitions Ti leaving SNbreak;

}}

}

Page 14: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

14Tajana Simunic Rosing

Co-design Finite State Machines (CFSMs)

CFSm is FSM extended with: Data handling Asynchronous communication

CFSM has FSM part Data computation part

Interacting CFSMs communicate through broadcast events

Page 15: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

15Tajana Simunic Rosing

Example CFSM Specification

State of a CFSM includes those events that are at the same time input and output for it

non-zero reaction time implies storage capability

Off

Wait

Alarm

*End=5 → *Alarm = On

*End=10 or*Belt = On or*Key = Off →*Alarm = Off

*Key = On → *Start

*Key = Off or*Belt = On →

Page 16: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

16Tajana Simunic Rosing

Network of CFSMs

CFSM2

CFSM3

C=>G

CFSM1

C=>FB=>C

F^(G==1)

(A==0)=>B

C=>ACFSM1 CFSM2

C=>B

F

G

CC

BA

C=>G

C=>B

GALS model, no hierarchy

Page 17: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

17Tajana Simunic Rosing

UnitControl with FireMode

FireMode When fire is true, move elevator to 1st floor and open door

Idle

GoingUp

req>floor

req<floor

!(req>floor)

timeout(10)

req<floor

DoorOpen

GoingDn

req>floor

u,d,o = 1,0,0

u,d,o = 0,0,1

u,d,o = 0,1,0

req==floor

!(req<floor)

fire

firefire

fire

FireGoingDn

floor>1

u,d,o = 0,1,0

u,d,o = 0,0,1

!fire

FireDrOpen

floor==1

fire

u,d,o = 0,0,1

UnitControl

Page 18: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

18Tajana Simunic Rosing

StateCharts: Hierarchy

Page 19: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

19Tajana Simunic Rosing

Back to Elevator Example

fire

!fire FireGoingDn

floor>1

u,d,o = 0,1,0

FireDrOpen

floor==1

fire

FireMode

u,d,o = 0,0,1

Idle

GoingUp

req>floor

req<floor

!(req>floor)

timeout(10)

req<floor

DoorOpen

GoingDn

req>floor

u,d,o = 1,0,0

u,d,o = 0,0,1

u,d,o = 0,1,0

req==floor!(req>floor)

u,d,o = 0,0,1

NormalMode

UnitControl

NormalMode

FireMode

fire!fire

UnitControl

ElevatorController

RequestResolver

...

UnitControl

Page 20: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

20Tajana Simunic Rosing

StateCharts: Default state

Page 21: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

21Tajana Simunic Rosing

StateCharts: History

Page 22: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

22Tajana Simunic Rosing

History & default state

same meaning

Page 23: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

23Tajana Simunic Rosing

StateCharts: Concurrency

Page 24: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

24Tajana Simunic Rosing

Conditional Transitions

Page 25: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

25Tajana Simunic Rosing

StateCharts: Timers

Page 26: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

26Tajana Simunic Rosing

Example: Answering machine

Page 27: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

27Tajana Simunic Rosing

StateCharts: edge labelsevent [condition] / reaction

Page 28: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

28Tajana Simunic Rosing

Propagations and BroadcastsSource: B. P. Douglass & iLogix

Page 29: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

29Tajana Simunic Rosing

StateCharts: Simulation

Status= values of all variables + set of events + current timeStep = execution of the three phases

Status phase 2

Page 30: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

30Tajana Simunic Rosing

StateCharts: Application Examples Power converter system for trams, metros & trains

System-level modeling and automated code generationGuarantee latencies less than 10 microseconds Cut development time by 50% Time from design completion to first prototype down to 1hr

from 3 months Defect free code automatically generated for a number of

RTOS implementations

By Alstom

Page 31: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

31Tajana Simunic Rosing

StateCharts: Application Examples Development of defibrillator and pacemaker

technologyModel system behavior before requirements are finalized Check that SW provides mathematically consistent

representation of the product’s system – correct and unambiguous representation of model behavior

More accurate and extensive verification – guarantee device works 100% of the time for at least 7-10yrs

Cut product verification costs by 20% 15-20% overall cost reduction per projects on future

development

By Guidant CRM

Page 32: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

32Tajana Simunic Rosing

StateCharts: Application Examples Jet engine electronic controller design

System level specification and consistency check Construction of on-screen simulation of the cockpit display Evaluate correctness in normal and faulty operation

modes Project so successful that now StateCharts are used for:

Independent overspeed protection system Thrust reverse control system Engine fuel control system

By BMW

Page 33: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

33Tajana Simunic Rosing

StateCharts: Summary Hierarchy

AND- and OR-super states Default state History

Timing behavior State oriented behavior Edge labels Concurrency Synchronization & communication

Broadcast, shared memory Simulation Cross compiling

Page 34: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Data modem design

What are the design goals? What should the design process be like?

34Tajana Simunic Rosing

Page 35: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

35Tajana Simunic Rosing

SDL- Specification and Description Language representation of FSMs/processes

output

input

state

Page 36: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

36Tajana Simunic Rosing

SDL - Operations on data

Page 37: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

37Tajana Simunic Rosing

SDL- Communication among FSMs

Message passing via FIFO

Page 38: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

38Tajana Simunic Rosing

SDL - Process interaction diagrams

,

Page 39: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

39Tajana Simunic Rosing

SDL - Designation of recipients

CounterVia Sw1

CounterTO OFFSPRING

Page 40: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

40Tajana Simunic Rosing

SDL - Hierarchy

Page 41: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

41Tajana Simunic Rosing

SDL - Timers

Page 42: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

42Tajana Simunic Rosing

SDL Application: Description of network protocols

Page 43: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

43Tajana Simunic Rosing

SDL: Application Example ADSL design

Ideal language for telecom design; communication between components and their different states of operation can be easily modeled with SDL

Object orientation and automatic code generation significantly simplified system design verification

Early testing done on SDL – significant savings in the cost of expensive test equiptment

By Siemens

Page 44: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

44Tajana Simunic Rosing

SDL Summary

SDLRepresentation of processesCommunication & block diagrams

Unbounded FIFOTimers and other language elementsGreat for network protocols

Page 45: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

45Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri nets Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Discrete Event Systems

VHDL, Verilog, SystemC, SpecC Synchronous languages

Cycle based models, Esterel, Lustre

Page 46: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

46Tajana Simunic Rosing

Petri net – Train tracks model

Page 47: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Petri net definitions

H2OExample

47Tajana Simunic Rosing Source: Murata’89

Page 48: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

48Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 49: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

49Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 50: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

50Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 51: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

51Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 52: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

52Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 53: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Petri nets: confusion Concurrency & conflict lead

to confusion….SymmetricAsymmetric

53Tajana Simunic Rosing Source: Murata’89

Page 54: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

54Tajana Simunic Rosing

Conflict for resource „track“

Page 55: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

55Tajana Simunic Rosing

Communication Protocol

Page 56: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

56Tajana Simunic Rosing

Communication Protocol

Page 57: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

57Tajana Simunic Rosing

Communication Protocol

Page 58: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

58Tajana Simunic Rosing

Communication Protocol

Page 59: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

59Tajana Simunic Rosing

Communication Protocol

Page 60: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

60Tajana Simunic Rosing

Communication Protocol

Page 61: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

61Tajana Simunic Rosing

Producer-Consumer Problem

Page 62: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

62Tajana Simunic Rosing

Producer-Consumer Problem

Page 63: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

63Tajana Simunic Rosing

Producer-Consumer Problem

Page 64: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

64Tajana Simunic Rosing

Producer-Consumer Problem

Page 65: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

65Tajana Simunic Rosing

Producer-Consumer Problem

Page 66: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

66Tajana Simunic Rosing

Producer-Consumer Problem

Page 67: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

67Tajana Simunic Rosing

Producer-Consumer Problem

Page 68: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

68Tajana Simunic Rosing

Producer-Consumer Problem

Page 69: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

69Tajana Simunic Rosing

Producer-Consumer Problem

Page 70: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

70Tajana Simunic Rosing

Producer-Consumer Problem

Page 71: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

71Tajana Simunic Rosing

Producer-Consumer Problem

Page 72: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

72Tajana Simunic Rosing

Producer-Consumer Problem

Page 73: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

73Tajana Simunic Rosing

Producer-Consumer Problem

Page 74: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

74Tajana Simunic Rosing

Producer-Consumer Problem

Page 75: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

75Tajana Simunic Rosing

Producer-Consumer with Priority

Modeling synchronization control when sharing resources Multiprocessor CPUs, distributed systems

Page 76: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Petri net definitions

H2OExample

76Tajana Simunic Rosing Source: Murata’89

Page 77: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

77Tajana Simunic Rosing

Petri Net Properties Behavioral

Reachability Marking M reachable from marking Mo

k - Boundedness Number of tokens in each place does not exceed finite number k Safe if 1-bounded

Liveness Can fire any transition of the net – related to absence of deadlocks

Structural Controlability

Any marking can be reached from any other marking Structural boundednes Conservativeness – weighted sum of tokens constant

Page 78: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

78Tajana Simunic Rosing

PN Properties - Reachability

Page 79: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

79Tajana Simunic Rosing

PN Properties - Liveness

Page 80: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

80Tajana Simunic Rosing

PN Properties - Liveness

Page 81: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

81Tajana Simunic Rosing

PN Properties - Liveness

Page 82: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

82Tajana Simunic Rosing

PN Properties - Liveness

Page 83: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

83Tajana Simunic Rosing

PN Properties - Boundedness

Page 84: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

84Tajana Simunic Rosing

PN Properties - Boundedness

Page 85: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

85Tajana Simunic Rosing

PN Properties - Boundedness

Page 86: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

86Tajana Simunic Rosing

PN Properties - Boundedness

Page 87: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

87Tajana Simunic Rosing

PN Properties - Boundedness

Page 88: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

88Tajana Simunic Rosing

PN Properties - Conservation

Page 89: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

89Tajana Simunic Rosing

PN Properties - Conservation

Page 90: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

90Tajana Simunic Rosing

PN Properties - Conservation

Page 91: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

91Tajana Simunic Rosing

Petri Nets - Analysis

Structural Incidence matrixT- and S- Invariants

State Space Analysis techniquesCoverability TreeReachability Graph

Page 92: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

92Tajana Simunic Rosing

PN Properties – Analysis

Incident Matrix

StateEquations

Page 93: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

93Tajana Simunic Rosing

Petri Nets – Coverability Tree

Page 94: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Example Assume

e=6 Mo=[0 12]

Can we reach M=[6 0] from Mo? Can it be statically scheduled? What size buffers are needed at

P1 & P2?

94Tajana Simunic Rosing

P1

P2T1 T2

32

4 e

Page 95: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

95Tajana Simunic Rosing

Petri nets: Applications Model, simulate and analyze networking

protocols (e.g. TCP, Ethernet, etc) Model, simulate and analyze complex network

elements (e.g. router, switch, optical mux); check their logical behavior

Design and analyze network performance and AoS with logical models of traffic generators, protocols and network elements

Study network behavior characteristics (e.g. throughput, blocking probability etc)

By Siemens

Page 96: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Petri nets in practice

Example apps: TCP performance Security system

design and automated code geneeration

MAC design….

96Tajana Simunic Rosing

Page 97: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

97Tajana Simunic Rosing

Petri Nets - Summary PN Graph

places (buffers), transitions (action), tokens (data) Firing rule

Transition enabled if enough tokens in a place Properties

Structural (consistency, structural boundedness) Behavioral (reachability, boundedness, etc.)

Analysis techniques Applications

Modeling of resources, mutual exclusion, synchronization

Page 98: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

98Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri nets Communicating Processes

Communicating Sequential Processes, Ada, Kahn processes Dataflow models

DFG, SDFG Discrete Event Systems

VHDL, Verilog, SystemC, SpecC Synchronous languages

Cycle based models, Esterel, Lustre HW Models Unified Modeling Language (UML)

Page 99: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

99Tajana Simunic Rosing

Process A sequential program

Executes concurrently with other processes

Basic operations on processes Create & terminate, suspend &

resume, join Process communication

Shared memory (and mutexes)Message passing Rendezvous

buttonsinside

elevator

UnitControl

b1

down

open

floor

...

RequestResolver

...

up/downbuttons on

eachfloor

b2bN

up1up2dn2

dnN

req

up

System interface

up3dn3

Page 100: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

100Tajana Simunic Rosing

Concurrent processes & implementation

Heartbeat Monitoring System

B[1..4]

Heart-beat pulse

Task 1:Read pulseIf pulse < Lo then

Activate SirenIf pulse > Hi then

Activate SirenSleep 1 secondRepeat

Task 2:If B1/B2 pressed then

Lo = Lo +/– 1If B3/B4 pressed then

Hi = Hi +/– 1Sleep 500 msRepeat

Set-top Box

Input Signal

Task 1:Read SignalSeparate Audio/VideoSend Audio to Task 2Send Video to Task 3Repeat

Task 2:Wait on Task 1Decode/output AudioRepeat

Task 3:Wait on Task 1Decode/output VideoRepeat

Video

Audio

Process1

Process2

Process3

Process4

Processor A

Processor B

Processor C

Processor D

Com

mun

icat

ion

Bus

(a)

(b)

Process1

Process2

Process3

Process4

General Purpose Processor

Process1

Process2

Process3

Process4

Processor A

General Purpose

Processor

Com

mun

icat

ion

Bus

(c)

Page 101: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

101Tajana Simunic Rosing

ADA-rendez-vous

task screen_output isentry call_ch(val:character; x, y: integer);entry call_int(z, x, y: integer);end screen_out;task body screen_output is...selectaccept call_ch ... do ..end call_ch;

oraccept call_int ... do ..end call_int;

end select;

Sending a message:beginscreen_out.call_ch('Z',10,20);exceptionwhen tasking_error =>

(exception handling)end;

Page 102: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

102Tajana Simunic Rosing

Task graphs

Nodes are a „program“ described in some programming language

Sequence constraint

Page 103: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

103Tajana Simunic Rosing

Task graphs - Timing

]

Arrival time deadline

Page 104: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

104Tajana Simunic Rosing

Task graphs - I/O

Page 105: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

105Tajana Simunic Rosing

Task graphs - Shared resources

Page 106: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

106Tajana Simunic Rosing

Task graphs - Periodic schedules

.. infinite task graphs

Page 107: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

107Tajana Simunic Rosing

Task graphs - Hierarchy

Page 108: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

108Tajana Simunic Rosing

Kahn process network

processchannel

KPN - executable task graphs

Communication is via infinitely large FIFOs

Nonblocking write, blocking read => DETERMINATE

Important properties of KPN:Continuous

Output signals can be gradually produced; never have to consume all input to produce some output

MonotonicOutput depends on input but doesn’t change previous output

Continuous monotonic processes => ITTERATIVE

Page 109: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

109Tajana Simunic Rosing

Petri net model of a Kahn process

KPNs are deterministic:Output determined by

Process, network, initial tokens

Page 110: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

110

CSE 237A Modeling Embedded Systems

Tajana Simunic RosingDepartment of Computer Science and EngineeringUniversity of California, San Diego.

Page 111: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

111Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri nets Communicating Processes

Communicating Sequential Processes, Ada, Kahn processes Dataflow models

DFG, SDFG Discrete Event Systems

VHDL, Verilog, SystemC, SpecC Synchronous languages

Cycle based models, Esterel, Lustre Petri nets HW Models Unified Modeling Language (UML)

Page 112: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

112Tajana Simunic Rosing

Dataflow Process NetworksA

B

C D

modulate convolve

transform

A B C D

Z

Nodes with more complex transformations

t1 t2

+ –

*

A B C D

Z

Nodes with arithmetic transformations

t1 t2

Z = (A + B) * (C - D)

Dataflow: Maps input tokens to output tokensOutputs function of current inputs

No need to keep state on suspend/resume

Scheduling for resource sharing

Page 113: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

113Tajana Simunic Rosing

Dataflow process examples HW resource schedulingConstraints: 2 mult, 2 ALUList scheduler usedAdditional constraints

Performance Power Area etc.

*

NOP

*

*

<

*

*

+

NOP

1 2

3

4

5

6

7*

8

+9

10

11

0

n

T1

T2

T3

T4

Page 114: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

114Tajana Simunic Rosing

Synchronous dataflow

Page 115: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

115Tajana Simunic Rosing

SDF notation Nodes have rates of data production or

consumption. Edges have delays.Delays do not change rates, only the amount

of data stored in the system at startup.

+ -1 2

50

Page 116: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

116Tajana Simunic Rosing

What Latency & Sample Period can a SDFG achieve?

TL = max(I-O path, D-O path) TS = max(D-D path, I-D path)

++

D1

++

x y

D2Longest Path for TS

Longest Path for TL

Page 117: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

117Tajana Simunic Rosing

SDFG can be Transformed to Affect TL & TS

++

++

x y

Longest Path for TS

Longest Path for TL

S1

S2 S4

S3

Page 118: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Tajana Simunic Rosing

SDF examples

n1

n2

11

n32 1

21

n11

n3

1

1

n2

12D

D

Page 119: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

119Tajana Simunic Rosing

SDF Scheduling By building a set of “flow and

conservation” equations3a – 2b = 04b – 3d = 0b – 3c = 02c – a = 0d – 2a = 0

Solution: a = 2c; b = 3c; d = 4c

Possible schedules: BBBCDDDDAABDBDBCADDABBDDBDDCAA…

Page 120: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

120Tajana Simunic Rosing

Dataflow process examples Design of a first 802.11b WLAN card

New product – combines RF, MAC and PHY; lots of DSP Implemented on an ASIC Previous design hand coded VHDL

System level design with COSSAP by Synopsys Explore architectural trade-offs – what in gates, what on DSP Scheduling trade-offs: latency, area, propagation delay between

clocks, and vendor library Results:

Reduced time to market by a factor of TWO! Architectural exploration within 10% of actual measurements in

terms of timing and area

By Symbol Tech.

Page 121: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

121Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri nets Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Synchronous reactive languages

Cycle based models, Esterel, Lustre Discrete Event Systems

VHDL, Verilog, SystemC, SpecC HW Models Unified Modeling Language (UML)

Page 122: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Tajana Simunic Rosing

Reactive Synchronous Languages Assumptions

Instantaneous reactions Discrete event Static

Cycle based models Excellent for (single) clocked synchronous circuits

Control flow oriented (imperative) languages Esterel

Data flow languages Lustre, Signal

Deterministic behavior Simulation, software and hardware synthesis,

verification

Page 123: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

Lustre example

123Tajana Simunic Rosing

Page 124: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

124Tajana Simunic Rosing

Reactive Synchronous Models: Esterel Statements

Emit S Present S then p else q end Pause P; Q, P||Q Loop p end Await S Abort p when S Suspect p when S Sustain S = (loop emit S; pause end)

Page 125: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

125Tajana Simunic Rosing

Abort Statement

Page 126: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

126Tajana Simunic Rosing

Esterel Examples

Page 127: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

127Tajana Simunic Rosing

Esterel Examples

Page 128: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

128Tajana Simunic Rosing

Time in Esterel Global clock with precise control over

when events appearAt every tick: read inputs, compute, output

StatementsA bounded number in one cycle

Emit, present, loopTake multiple cycles:

Pause, await, sustain

Causality analysisDeterministic & non-contradictory

Page 129: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

129Tajana Simunic Rosing

Esterel Application Examples TI used Esterel to automatically synthesize full

coverage tests for a safety-critical design Showed functional coverage covered only 30% of the

design, with Esterl 100% covered Airbus

Significant decrease in errors due to increase in automated code generation (40-70%) e.g fly by wire controls & automatic flight control 70%, display

computer 50%, warning & maintenance computer 40% Major increase in productivity

Page 130: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

130Tajana Simunic Rosing

Esterel Summary Reactive synchronous language Control flow oriented Imperative syntax Synchrony assumption useful for safety

critical embedded systemsConvert timing relations to causal orderingUsed in verification

e.g. TI, Airbus

Page 131: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

131Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Discrete Event Systems

VHDL, Verilog, SystemC, SpecC Synchronous languages

Cycle based models, Esterel, Lustre Petri nets HW Models Unified Modeling Language (UML)

Page 132: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

132Tajana Simunic Rosing

UML (Unified modeling language)

Page 133: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

133Tajana Simunic Rosing

UML - StateCharts

Page 134: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

134Tajana Simunic Rosing

UML – Extended Petri Nets

„swimlane“

Page 135: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

135Tajana Simunic Rosing

UML Summary UML

- State machine diagram (StateChart-like)- Activity diagram (extended Petri nets)- Deployment diagram (exec. arch.)- Use case diagram- Package diagram (hierarchy)- Class diagrams- Timing diagrams (UML 2.0), UML for real-time

Page 136: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

136Tajana Simunic Rosing

Going Across MOC: Ptolemy Inter-domain simulations through domain encapsulation

Define semantics of every such encapsulation carefully, conservatively (and yet with some efficiency)

Event horizon: Couple timed & untimed domains

Page 137: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

137Tajana Simunic Rosing

Models and Languages Summary Multiple models and languages are essential for high-

level design Managing complexity by abstraction Formality ensures refinement correctness Model choice depends on

Class of applications Required operations (synthesis, scheduling, ...)

Multiple MOCs can co-exist during all phases of design Specification Architectural mapping and simulation Synthesis, code generation, scheduling Detailed design and implementation Co-simulation

Page 138: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

138Tajana Simunic Rosing

Sources and References

Peter Marwedel, “Embedded Systems Design,” 2004. Frank Vahid, Tony Givargis, “Embedded System

Design,” Wiley, 2002. Wayne Wolf, “Computers as Components,” Morgan

Kaufmann, 2001. Axel Jantsch, “Modeling Embedded Systems and

SOCs,” Morgan Kaufmann, 2004. Alberto Sangiovanni-Vincentelli @ UCB Mani Srivastava @ UCLA Rajesh Gupta @ UCSD Nikil Dutt @ UCI

Page 139: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

139Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri Nets Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Synchronous languages

Cycle based models, Esterel, Lustre Discrete Event Systems

VHDL, Verilog, SystemC, SpecC HW Models Unified Modeling Language (UML)

Page 140: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

140Tajana Simunic Rosing

Discrete Events Notion of time is fundamental: global order

events are objects which carry ordered time info there is a casual relationship between events

DE simulator maintains global event queue Verilog, VHDL

Expensive - ordering tame stamps can be time consuming

Large state & Low Activity => Effective simulation Simultaneous events lead to non-determinacy

require complex conflict resolution schemes e.g. delta delays

Page 141: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

141Tajana Simunic Rosing

Simultaneous Events in the Discrete Event Model

A B Ct

t

A B C

t

A B C

t

t

B has 0 delay B has delta delay

t+

Page 142: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

142Tajana Simunic Rosing

VHDL: Entitiesentity full_adder isport(a, b, carry_in: in Bit; -- input ports

sum,carry_out: out Bit); --output portsend full_adder;

Page 143: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

143Tajana Simunic Rosing

VHDL: Architecturesarchitecture structure of full_adder is

component half_adderport (in1,in2:in Bit; carry, sum:out Bit);

end component;component or_gateport (in1, in2:in Bit; o:out Bit);

end component;signal x, y, z: Bit; -- local signalsbegin -- port map section

i1: half_adder port map (a, b, x, y);i2: half_adder port map (y, carry_in, z, sum);i3: or_gate port map (x, z, carry_out);

end structure;

architecture behavior of full_adder isbeginsum <= (a xor b) xor carry_in after 10

Ns;carry_out <= (a and b) or (a and carry_in) or

(b and carry_in) after 10 Ns;end behavior;

Page 144: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

144Tajana Simunic Rosing

VHDL: signal strengths

Page 145: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

145Tajana Simunic Rosing

VHDL processes & waitsProcesses model HW parallelism

processbegin

a <= b after 10 nsend process

beginprod <= x and y ;wait on x,y;

end process;

process (x, y)beginprod <= x and y ;

end process;

Waits:wait until signal list;

wait until a;wait until condition;

wait until c='1';wait for duration;

wait for 10 ns;wait; suspend indefinitelywait on = sensitivity list

Page 146: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

146Tajana Simunic Rosing

VHDL Simulation

Page 147: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

147Tajana Simunic Rosing

VHDL Simulation of an RS FFarchitecture one of RS_Flipflop isbeginprocess: (R,S,Q,nQ)

beginQ <= R nor nQ;nQ <= S nor Q;

end process;end one;

0ns 0ns+δ 0ns+2δ

R 1 1 1

S 0 0 0

Q 1 0 0

nQ 0 0 1

0001

1100

0000

0111

1st δ

2nd δ

δ cycles reflect the fact that no real gate comes with zero delay. should delay-less signal assignments be allowed at all?

Page 148: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

148Tajana Simunic Rosing

VHDL Summary Entities and architectures Multiple-valued logic Modeling hardware parallelism by processesWait statements and sensivity lists

VHDL simulation cycleδ cycles, deterministic simulation

Page 149: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

149Tajana Simunic Rosing

SystemC: Motivation

Page 150: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

150Tajana Simunic Rosing

SystemC: Methodology

Page 151: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

151Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Petri nets Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Synchronous languages

Cycle based models, Esterel, Lustre Discrete Event Systems

VHDL, Verilog, SystemC, SpecC HW Models Unified Modeling Language (UML)

Page 152: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

152Tajana Simunic Rosing

Levels of hardware modeling1. System level2. Algorithmic level3. Instruction set level4. Register-transfer level (RTL)5. Gate-level models6. Switch-level models7. Circuit-level models8. Device-level models9. Layout models10. Process and device models

Page 153: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

153Tajana Simunic Rosing

Instruction level

Assembler (MIPS) Simulated semanticsand $1,$2,$3 Reg[1]:=Reg[2] ∧ Reg[3]

or $1,$2,$3 Reg[1]:=Reg[2] ∨ Reg[3]

andi $1,$2,100 Reg[1]:=Reg[2] ∧ 100

sll $1,$2,10 Reg[1]:=Reg[2] << 10

srl $1,$2,10 Reg[1]:=Reg[2] >> 10

Page 154: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

154Tajana Simunic Rosing

Register transfer level: MIPSController

BP

C

Inst

ruct

ion

regi

ster

IR

Mem

ory

Spe

iche

r

T

sign_extend

4

*

ALU

Reg

0

0

0

0

0

01

1

1

1

1

1

2

2

3

§

31:26

25:21

20:16

25:015:0

15:11

i2

a2

a1

i3

a3

a

2

a1

PCSo

urce

Targ

etW

rite

ALU

Op

ALU

SelA

ALU

SelB

Reg

Writ

e

Reg

Des

t

IRW

rite

Mem

Rea

d

Mem

Writ

e

PCW

rite

*§31: 28

"00“

Page 155: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

155Tajana Simunic Rosing

Gate-level model

Page 156: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

156Tajana Simunic Rosing

Switch level model

Page 157: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

157Tajana Simunic Rosing

Circuit level model

Page 158: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

158Tajana Simunic Rosing

Device levelMeasured and simulated currents

Page 159: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

159Tajana Simunic Rosing

Layout model

din

powlo

powhi

dout

Page 160: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

160Tajana Simunic Rosing

Process model

Simulated

Measured

Page 161: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

161Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM Communicating Processes

Kahn processes, Communicating Sequential Processes Ada Dataflow models

DFG, SDFG Discrete Event Systems

VHDL, Verilog, SystemC, SpecC Synchronous languages

Cycle based models, Esterel, Lustre Petri nets HW Models Unified Modeling Language (UML)

Page 162: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

162Tajana Simunic Rosing

UML (Unified modeling language)

Page 163: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

163Tajana Simunic Rosing

UML - StateCharts

Page 164: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

164Tajana Simunic Rosing

UML – Extended Petri Nets

„swimlane“

Page 165: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

165Tajana Simunic Rosing

UML Summary UML

- State machine diagram (StateChart-like)- Activity diagram (extended Petri nets)- Deployment diagram (exec. arch.)- Use case diagram- Package diagram (hierarchy)- Class diagrams- Timing diagrams (UML 2.0), UML for real-time

Page 166: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

166Tajana Simunic Rosing

Going Across MOC: Ptolemy Inter-domain simulations through domain encapsulation

Define semantics of every such encapsulation carefully, conservatively (and yet with some efficiency)

Event horizon: Couple timed & untimed domains

Page 167: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

167Tajana Simunic Rosing

Models and Languages Summary Multiple models and languages are essential for high-

level design Managing complexity by abstraction Formality ensures refinement correctness Model choice depends on

Class of applications Required operations (synthesis, scheduling, ...)

Multiple MOCs can co-exist during all phases of design Specification Architectural mapping and simulation Synthesis, code generation, scheduling Detailed design and implementation Co-simulation

Page 168: CSE 237A Modeling Embedded Systemscseweb.ucsd.edu/classes/sp10/cse237a/handouts/models.pdf · Construction of on-screen simulation of the cockpit display ... Petri Net Properties

168Tajana Simunic Rosing

Sources and References

Peter Marwedel, “Embedded Systems Design,” 2004. Frank Vahid, Tony Givargis, “Embedded System

Design,” Wiley, 2002. Wayne Wolf, “Computers as Components,” Morgan

Kaufmann, 2001. Axel Jantsch, “Modeling Embedded Systems and

SOCs,” Morgan Kaufmann, 2004. Alberto Sangiovanni-Vincentelli @ UCB Mani Srivastava @ UCLA Rajesh Gupta @ UCSD Nikil Dutt @ UCI