159
1 Modeling Embedded Systems Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

1

Modeling Embedded Systems

Tajana Simunic Rosing

Department of Computer Science and Engineering

University of California, San Diego.

Page 2: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

2 Tajana Simunic Rosing

ES Design

Verification and Validation

Hardware Hardware components

Page 3: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

3 Tajana Simunic Rosing

Models, Languages and Tools

Sequent.

program

State

machine

Data-

flow

Concurrent

processes

C/C++

Verilog

Java

VHDL

Implementation

A

Implementation

B

Implementation

C

Page 4: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

4 Tajana 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

5 Tajana Simunic Rosing

Modes of Communication

Page 6: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

6 Tajana Simunic Rosing

Communication

Blocking

send ()

receive ()

send ()

receive ()

send ()

receive ()

ack

… process a {

..

P(S) //obtain lock

.. // critical section

V(S) //release lock

}

process b {

..

P(S) //obtain lock

.. // critical section

V(S) //release lock

}

Message Passing

Non-blocking

Shared memory

Extended

rendezvous

Page 7: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

7 Tajana Simunic Rosing

Implantable Cardioverter Defibrillator

Function: 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

8 Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, CFSM, StateCharts , SDL

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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

9 Tajana Simunic Rosing

Classical automata

• Moore-automata:

O = H(S); S+ = f(I, S)

• Mealy-automata

O = H(I, S); S+ = f(I, S)

• Moore-automata:

O = H(S); S+ = f(I, S)

• Mealy-automata

O = H(I, S); S+ = f(I, S)

Internal state S input I output O

S0 S1

S2 S3

e=1

e=1

e=1

e=1

0 1

2 3

clock

Page 10: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

10 Tajana 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 11: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

11 Tajana Simunic Rosing

Example CFSM Specification

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

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 12: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

12 Tajana Simunic Rosing

Network of CFSMs

CFSM2

CFSM3

C=>G

CFSM1

C=>F B=>C

F^(G==1)

(A==0)=>B

C=>A CFSM1

CFSM2

C=>B

F

G

C

C

B A

C=>G

C=>B

GALS model, no hierarchy

Page 13: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

13 Tajana 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

buttons

inside

elevator

Unit

Control

b1

down

open

floor

...

Request

Resolver

...

up/down

buttons on

each

floor

b2

bN

up1

up2

dn2

dnN

req

up

System interface

up3

dn3

Page 14: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

14 Tajana Simunic Rosing

Elevator controller using a

sequential program model

buttons

inside

elevator

Unit

Control

b1

down

open

floor

...

Request

Resolver

...

up/down

buttons on

each

floor

b2

bN

up1

up2

dn2

dnN

req

up

System interface

up3

dn3

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

RequestResolver()

}

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 15: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

15 Tajana 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 16: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

16 Tajana 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

fire

fire

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 17: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

17 Tajana Simunic Rosing

StateCharts: Hierarchy

Page 18: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

18 Tajana 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 19: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

19 Tajana Simunic Rosing

StateCharts: Default state

Page 20: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

20 Tajana Simunic Rosing

StateCharts: History

Page 21: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

21 Tajana Simunic Rosing

History & default state

same meaning

Page 22: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

22 Tajana Simunic Rosing

StateCharts: Concurrency

Page 23: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

23 Tajana Simunic Rosing

Conditional Transitions

Page 24: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

24 Tajana Simunic Rosing

StateCharts: Timers

Page 25: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

25 Tajana Simunic Rosing

Example: Answering machine

Page 26: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

26 Tajana Simunic Rosing

Propagations and Broadcasts

Source: B. P. Douglass & iLogix

Page 27: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

27 Tajana Simunic Rosing

StateCharts: Simulation

Status= values of all variables + set of events + current time

Step = execution of the three phases

Status= values of all variables + set of events + current time

Step = execution of the three phases

Status phase 2

Page 28: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

28 Tajana Simunic Rosing

StateCharts: edge labels

event [condition] / reaction

Page 29: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

29 Tajana Simunic Rosing

StateCharts: Application Examples

Power converter system for trams, metros & trains

System-level modeling and automated code generation

Guarantee 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 30: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

30 Tajana Simunic Rosing

StateCharts: Application Examples

Development of defibrillator and pacemaker

technology

Model 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 31: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

31 Tajana 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 32: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

32 Tajana 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 33: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

33 Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, CFSM, StateCharts , SDL

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 34: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Data modem design

What are the design goals?

What should the design process be like?

34 Tajana Simunic Rosing

Page 35: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

35 Tajana Simunic Rosing

SDL- Specification and Description Language representation of FSMs/processes

output

input

state

http://www.sdl-forum.org/sdl88tutorial/

Page 36: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

36 Tajana Simunic Rosing

SDL - Operations on data

Page 37: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

37 Tajana Simunic Rosing

SDL- Communication among FSMs

Message passing via FIFO

Page 38: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

38 Tajana Simunic Rosing

SDL - Process interaction diagrams

,

Page 39: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

39 Tajana Simunic Rosing

SDL - Designation of recipients

Counter

Via Sw1 Counter

TO OFFSPRING

Page 40: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

40 Tajana Simunic Rosing

SDL - Hierarchy

Page 41: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

41 Tajana Simunic Rosing

SDL - Timers

Page 42: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

42 Tajana Simunic Rosing

SDL Application:

Description of network protocols

Page 43: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

43 Tajana 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

44 Tajana Simunic Rosing

SDL Summary

SDL

Representation of processes

Communication & block diagrams Unbounded FIFO

Timers and other language elements

Great for network protocols

Page 45: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

45

Modeling Embedded Systems

Tajana Simunic Rosing

Department of Computer Science and Engineering

University of California, San Diego.

Page 46: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

46 Tajana 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 47: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Petri net definitions

H2OExample

47 Tajana Simunic Rosing Source: Murata’89

Page 48: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

48 Tajana Simunic Rosing

Petri net – Train tracks model

Page 49: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

49 Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 50: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

50 Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 51: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

51 Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 52: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

52 Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 53: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

53 Tajana Simunic Rosing

Concurrency, Causality, Choice

Page 54: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Petri nets: confusion

Concurrency & conflict lead

to confusion….

Symmetric

Asymmetric

54 Tajana Simunic Rosing Source: Murata’89

Page 55: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

55 Tajana Simunic Rosing

Conflict for resource „track“

Page 56: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

56 Tajana Simunic Rosing

Communication Protocol

Page 57: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

57 Tajana Simunic Rosing

Communication Protocol

Page 58: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

58 Tajana Simunic Rosing

Communication Protocol

Page 59: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

59 Tajana Simunic Rosing

Communication Protocol

Page 60: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

60 Tajana Simunic Rosing

Communication Protocol

Page 61: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

61 Tajana Simunic Rosing

Communication Protocol

Page 62: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

62 Tajana Simunic Rosing

Producer-Consumer Problem

Page 63: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

63 Tajana Simunic Rosing

Producer-Consumer Problem

Page 64: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

64 Tajana Simunic Rosing

Producer-Consumer Problem

Page 65: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

65 Tajana Simunic Rosing

Producer-Consumer Problem

Page 66: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

66 Tajana Simunic Rosing

Producer-Consumer Problem

Page 67: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

67 Tajana Simunic Rosing

Producer-Consumer Problem

Page 68: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

68 Tajana Simunic Rosing

Producer-Consumer Problem

Page 69: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

69 Tajana Simunic Rosing

Producer-Consumer Problem

Page 70: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

70 Tajana Simunic Rosing

Producer-Consumer Problem

Page 71: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

71 Tajana Simunic Rosing

Producer-Consumer Problem

Page 72: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

72 Tajana Simunic Rosing

Producer-Consumer Problem

Page 73: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

73 Tajana Simunic Rosing

Producer-Consumer Problem

Page 74: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

74 Tajana Simunic Rosing

Producer-Consumer Problem

Page 75: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

75 Tajana Simunic Rosing

Producer-Consumer Problem

Page 76: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

76 Tajana Simunic Rosing

Producer-Consumer with Priority

Modeling synchronization control when sharing resources Multiprocessor CPUs, distributed systems

Page 77: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Petri net definitions

H2OExample

77 Tajana Simunic Rosing Source: Murata’89

Page 78: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

78 Tajana 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 79: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

79 Tajana Simunic Rosing

PN Properties - Reachability

Page 80: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

80 Tajana Simunic Rosing

PN Properties - Liveness

Page 81: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

81 Tajana Simunic Rosing

PN Properties - Liveness

Page 82: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

82 Tajana Simunic Rosing

PN Properties - Liveness

Page 83: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

83 Tajana Simunic Rosing

PN Properties - Liveness

Page 84: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

84 Tajana Simunic Rosing

PN Properties - Boundedness

Page 85: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

85 Tajana Simunic Rosing

PN Properties - Boundedness

Page 86: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

86 Tajana Simunic Rosing

PN Properties - Boundedness

Page 87: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

87 Tajana Simunic Rosing

PN Properties - Boundedness

Page 88: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

88 Tajana Simunic Rosing

PN Properties - Boundedness

Page 89: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

89 Tajana Simunic Rosing

PN Properties - Conservation

Page 90: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

90 Tajana Simunic Rosing

PN Properties - Conservation

Page 91: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

91 Tajana Simunic Rosing

PN Properties - Conservation

Page 92: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

92 Tajana Simunic Rosing

Petri Nets - Analysis

Structural

Incidence matrix

T- and S- Invariants

State Space Analysis techniques

Coverability Tree

Reachability Graph

Page 93: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

93 Tajana Simunic Rosing

PN Properties – Analysis

Incident

Matrix

State

Equations

Page 94: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

94 Tajana Simunic Rosing

Petri Nets – Coverability Tree

Page 95: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

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?

95 Tajana Simunic Rosing

P1

P2

T1 T2

32

4 e

Page 96: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

96 Tajana 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 97: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Petri nets in

practice

Example apps:

TCP performance

Security system

design and automated

code geneeration

MAC design

….

97 Tajana Simunic Rosing

Page 98: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

98 Tajana 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 99: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

99 Tajana 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 100: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

100 Tajana 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

buttons

inside

elevator

Unit

Control

b1

down

open

floor

...

Request

Resolver

...

up/down

buttons on

each

floor

b2

bN

up1

up2

dn2

dnN

req

up

System interface

up3

dn3

Page 101: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

101

Tajana Simunic Rosing

Concurrent processes &

implementation Heartbeat Monitoring System

B[1..4]

Heart-beat

pulse

Task 1:

Read pulse

If pulse < Lo then

Activate Siren

If pulse > Hi then

Activate Siren

Sleep 1 second

Repeat

Task 2:

If B1/B2 pressed then

Lo = Lo +/– 1

If B3/B4 pressed then

Hi = Hi +/– 1

Sleep 500 ms

Repeat

Set-top Box

Input

Signal

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

Repeat

Task 3:

Wait on Task 1

Decode/output Video

Repeat

Video

Audio

Process1

Process2

Process3

Process4

Processor A

Processor B

Processor C

Processor D

Com

munic

atio

n B

us

(a)

(b)

Process1

Process2

Process3

Process4

General Purpose

Processor

Process1

Process2

Process3

Process4

Processor A

General

Purpose

Processor

Com

munic

atio

n B

us

(c)

Page 102: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

102 Tajana Simunic Rosing

ADA-rendez-vous

task screen_output is

entry call_ch(val:character; x, y: integer);

entry call_int(z, x, y: integer);

end screen_out;

task body screen_output is

...

select

accept call_ch ... do ..

end call_ch;

or

accept call_int ... do ..

end call_int;

end select;

Sending a message:

begin

screen_out.call_ch('Z',10,20);

exception

when tasking_error =>

(exception handling)

end;

Sending a message:

begin

screen_out.call_ch('Z',10,20);

exception

when tasking_error =>

(exception handling)

end;

Page 103: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

103 Tajana Simunic Rosing

Task graphs

Nodes are a „program“

described in some

programming language

Nodes are a „program“

described in some

programming language

Sequence

constraint

Page 104: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

104 Tajana Simunic Rosing

Task graphs - Timing

]

Arrival time deadline

Page 105: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

105 Tajana Simunic Rosing

Task graphs - I/O

Page 106: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

106 Tajana Simunic Rosing

Task graphs - Shared resources

Page 107: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

107 Tajana Simunic Rosing

Task graphs - Periodic schedules

.. infinite task graphs

Page 108: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

108 Tajana Simunic Rosing

Task graphs - Hierarchy

Page 109: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

109 Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM

Petri nets

Communicating Processes Communicating Sequential Processes, Ada

Dataflow models Kahn processes

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 110: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

110

Tajana Simunic Rosing

Kahn process network

process channel

KPN - executable task graphs

Communication is via infinitely large FIFOs

Nonblocking write, blocking read => DETERMINATE

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

Monotonic Output depends on input but doesn’t change previous output

Continuous monotonic processes => ITERATIVE

Page 111: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

111 Tajana Simunic Rosing

Petri net model of a Kahn process

KPNs are deterministic:

Output determined by

Process, network, initial tokens

Page 112: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

112 Tajana Simunic Rosing

Dataflow Process Networks A

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 tokens

Outputs function of current inputs No need to keep state on

suspend/resume

Scheduling for resource sharing

Page 113: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

113 Tajana Simunic Rosing

Dataflow process examples

HW resource scheduling

Constraints: 2 mult, 2 ALU

List scheduler used

Additional 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

114 Tajana Simunic Rosing

Synchronous dataflow

Page 115: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

115 Tajana 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

5 0

Page 116: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

116 Tajana 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

D2 Longest Path for T S

Longest Path for T L

Page 117: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

117 Tajana Simunic Rosing

SDFG can be Transformed to

Affect TL & TS

+ +

+ +

x y

Longest Path for T S

Longest Path for T L

S1

S2 S4

S3

Page 118: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Tajana Simunic Rosing

SDF examples

n1

n2

1 1

n3 2 1

2 1

n1 1

n3

1

1

n2

1 2D

D

Page 119: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

119 Tajana Simunic Rosing

SDF Scheduling

By building a set of “flow and

conservation” equations 3a – 2b = 0

4b – 3d = 0

b – 3c = 0

2c – a = 0

d – 2a = 0

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

Possible schedules:

BBBCDDDDAA

BDBDBCADDA

BBDDBDDCAA

Page 120: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

120 Tajana 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

121 Tajana 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

Lustre example

123 Tajana Simunic Rosing

Page 124: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

124 Tajana 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

Suspend p when S

Sustain S = (loop emit S; pause end)

Page 125: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

125 Tajana Simunic Rosing

Abort Statement

Page 126: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

126 Tajana Simunic Rosing

Esterel Examples

Page 127: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

127 Tajana Simunic Rosing

Esterel Examples

Page 128: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

128 Tajana Simunic Rosing

Time in Esterel Global clock with precise control over

when events appear

At every tick: read inputs, compute, output

Statements

A bounded number in one cycle

Emit, present, loop

Take multiple cycles:

Pause, await, sustain

Causality analysis

Deterministic & non-contradictory

Page 129: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

129 Tajana 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: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

130 Tajana Simunic Rosing

Esterel Summary

Reactive synchronous language

Control flow oriented

Imperative syntax

Synchrony assumption useful for safety

critical embedded systems

Convert timing relations to causal ordering

Used in verification

e.g. TI, Airbus

Page 131: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

131 Tajana 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 132: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

132 Tajana 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 133: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

133 Tajana Simunic Rosing

Simultaneous Events in the

Discrete Event Model

A B C t

t

A B C

t

A B C

t

t

B has 0 delay B has delta delay

t+

Page 134: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

134 Tajana Simunic Rosing

VHDL: Entities

entity full_adder is

port(a, b, carry_in: in Bit; -- input ports

sum,carry_out: out Bit); --output ports

end full_adder;

Page 135: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

135 Tajana Simunic Rosing

VHDL: Architectures

architecture structure of full_adder is

component half_adder

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

end component;

component or_gate

port (in1, in2:in Bit; o:out Bit);

end component;

signal x, y, z: Bit; -- local signals

begin -- 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 is

begin

sum <= (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 136: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

136 Tajana Simunic Rosing

VHDL: signal strengths

Page 137: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

137 Tajana Simunic Rosing

VHDL processes & waits

Processes model HW parallelism process begin a <= b after 10 ns end

process

begin

prod <= x and y ;

wait on x,y;

end process;

process (x, y)

begin

prod <= 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 indefinitely

wait on = sensitivity list

Page 138: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

138 Tajana Simunic Rosing

VHDL Simulation

Page 139: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

139 Tajana Simunic Rosing

VHDL Simulation of an RS FF architecture one

of RS_Flipflop is

begin

process: (R,S,Q,nQ)

begin

Q <= 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

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?

cycles reflect the fact that no

real gate comes with zero delay.

should delay-less signal

assignments be allowed at all?

Page 140: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

140 Tajana Simunic Rosing

VHDL Summary

Entities and architectures

Multiple-valued logic

Modeling hardware parallelism by processes

Wait statements and sensivity lists

VHDL simulation cycle

cycles, deterministic simulation

Page 141: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

141 Tajana Simunic Rosing

SystemC: Motivation

Page 142: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

142 Tajana Simunic Rosing

SystemC: Methodology

Page 143: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

143 Tajana 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 144: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

144 Tajana Simunic Rosing

Levels of hardware modeling

1. System level

2. Algorithmic level

3. Instruction set level

4. Register-transfer level (RTL)

5. Gate-level models

6. Switch-level models

7. Circuit-level models

8. Device-level models

9. Layout models

10. Process and device models

Page 145: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

145 Tajana Simunic Rosing

Instruction level

Assembler (MIPS) Simulated semantics

and $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 146: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

146 Tajana Simunic Rosing

Register transfer level: MIPS Controller

B

PC

Instr

uc

tio

n r

eg

iste

r IR

Mem

ory

Sp

eic

he

r

T

sign_

extend

4

*

AL

U

Re

g

0

0

0

0

0

0 1

1

1

1

1

1

2

2

3

§

31:26

25:21

20:16

25:0

15:0

15:11

i2 a

2 a

1

i3

a

3

a

2

a1

PC

Sourc

e

Targ

etW

rite

ALU

Op

ALU

SelA

ALU

SelB

RegW

rite

RegD

est

IRW

rite

Mem

Read

Mem

Write

PC

Wri

te

* §

31: 28

"00“

Page 147: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

147 Tajana Simunic Rosing

Gate-level model

Page 148: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

148 Tajana Simunic Rosing

Switch level model

Page 149: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

149 Tajana Simunic Rosing

Circuit level model

Page 150: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

150 Tajana Simunic Rosing

Device level

Measured and simulated currents

Page 151: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

151 Tajana Simunic Rosing

Layout model

din

powlo

powhi

dout

Page 152: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

152 Tajana Simunic Rosing

Process model

Simulated

Measured

Page 153: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

153 Tajana Simunic Rosing

Models of Computation State Machine Models

FSM, StateCharts , SDL, CFSM

Petri nets

Ada

Communicating Processes Kahn processes, Communicating Sequential Processes

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 154: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

154 Tajana Simunic Rosing

UML (Unified modeling language)

Page 155: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

155 Tajana Simunic Rosing

UML - StateCharts

Page 156: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

156 Tajana Simunic Rosing

UML – Extended Petri Nets

„swimlane“

Page 157: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

157 Tajana 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 158: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

158 Tajana 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 159: Modeling Embedded Systems€¦ · Construction of on-screen simulation of the cockpit display ... Petri Net Properties Behavioral Reachability Marking M reachable from marking Mo

159 Tajana 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