© s. ramesh / kavi arya / krithi ramamritham 1 it-606 embedded systems (software ) s. ramesh kavi...

35
1 © S. Ramesh / Kavi Arya / Krithi Ramamritham IT-606 Embedded Systems (Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

Upload: jalynn-bickers

Post on 29-Mar-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

1© S. Ramesh / Kavi Arya / Krithi Ramamritham

IT-606Embedded Systems

(Software)

S. RameshKavi Arya

Krithi Ramamritham

KReSIT/ IIT Bombay

Page 2: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

2© S. Ramesh / Kavi Arya / Krithi Ramamritham

Overview of Polis

S. Ramesh

Page 3: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

3© S. Ramesh / Kavi Arya / Krithi Ramamritham

POLIS• Research effort from Univ. of Cal., Berkeley• Alberto Sangiovanni-Vincentelli and his

students• One of the earliest tools for embedded systems

design• Initial ideas in early 1990s• Main motivation from Magneti Marelli,

– 2nd largest European producer of automotive electronic subsystems

• World-wide clients: Fiat, Mercedes Benz, Volkswagen, Renault, Rover

Page 4: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

4© S. Ramesh / Kavi Arya / Krithi Ramamritham

Design Challenges• difficulty of implementing informal

specifications from clients – safety, drivability, efficient fuel consumption,

controlled emission • problem of chasing continuously changing

specification (car models evolve)• software design problem

– debugging assembly code, hand-written real-time kernel

– verification of timing properties, limited resources

Page 5: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

5© S. Ramesh / Kavi Arya / Krithi Ramamritham

Design Challenges (contd.)• Poor design methodology

– no simulation and extensive bread-boarding– hand-layout of HW– independent development of HW and SW and

integration at the last moment– new designs layered on top of old designs– lack of traceability

Page 6: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

6© S. Ramesh / Kavi Arya / Krithi Ramamritham

Model-Based approach• Polis is one of the earliest to suggest this• Polis Modeling Language: Codesign Finite

State Machine (CFSM) models• Focus on control dominated applications• Embedded System Architecture

– Micro-Processor/Micro controllers– DSP– Peripherals and Std. Components– SW and RTOS

Page 7: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

7© S. Ramesh / Kavi Arya / Krithi Ramamritham

Page 8: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

8© S. Ramesh / Kavi Arya / Krithi Ramamritham

Design Methodology: POLIS View

Page 9: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

9© S. Ramesh / Kavi Arya / Krithi Ramamritham

Functional Level• System behaviour

– precisely captured using high level models (CFSMs)

– Example: MPEG encoder algorithm, DCT algorithm

• Analysis– Simulation and Formal Verification

Page 10: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

10© S. Ramesh / Kavi Arya / Krithi Ramamritham

Architecture Selection• A class of physical components selected

– 32 bit or 16 bit microprocessor, RISC, CISC– DSP– Interconnection scheme

• May come from existing IP library or models to be custom-designed

Page 11: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

11© S. Ramesh / Kavi Arya / Krithi Ramamritham

Mapping• Critical step• mapping of behavior onto candidate

architecture• partitioning and performance analysis• Manual partitioning• Analysis using Ptolemy tool

Page 12: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

12© S. Ramesh / Kavi Arya / Krithi Ramamritham

Architectural Level• Automatic synthesis of HW and SW• Interface synthesis• RTOS function integration• Scheduling and communication• Fast prototyping and back annotation

Page 13: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

13© S. Ramesh / Kavi Arya / Krithi Ramamritham

POLIS Design Flow

Page 14: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

14© S. Ramesh / Kavi Arya / Krithi Ramamritham

Input Translation• Input to POLIS

– Esterel, Extended FSM (FSM with data)– Any language with underlying FSM model

• Input is translated to Co-design Finite State Machines (CFSMs)

• All later steps deal only with CFSMs

Page 15: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

15© S. Ramesh / Kavi Arya / Krithi Ramamritham

CFSMs• Collection of Extended Finite State Machines• Extended Finite State Machines• FSM + variables

– Variables have finite range– Transition labels: b, e / A

• b - boolean expression over variables and signal values

• e - boolean expression over input signals• A - Actions: assignment and signal emisson

• Signal presence detected and values read• Atomic transitions

Page 16: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

16© S. Ramesh / Kavi Arya / Krithi Ramamritham

VM

?coffee(x); x

>a

!Mk_coffee

?read

y

!chan

ge (x

-a);

! Pou

r_co

ffee

?Tea (x); x>b

!Mk_tea

?ready!change (x-b); ! Pour_Tea

Page 17: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

17© S. Ramesh / Kavi Arya / Krithi Ramamritham

User

? tired

! Coffee(z)

? Pou

r_coff

ee! c

ollec

t

? tired! Tea (z)

? Pour_Tea!Collect

Page 18: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

18© S. Ramesh / Kavi Arya / Krithi Ramamritham

Interacting Machines• The CFSMs interact with each other by

means of events• Many similarities with Esterel communication

– Sender generates an event (possibly with values)

– Receiver senses the presence of events– Single sender and multiple receivers– Sender generates irrespective of receiver

• Multiple sends erase the old value– one-place buffer

– Receiver consumes the event

Page 19: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

19© S. Ramesh / Kavi Arya / Krithi Ramamritham

CFSM Interaction• Many differences with Esterel

– CFSMs are asynchronous– The receiver and sender not synchronized– They have distinct clocks– Receiver and sender transitions take place at

different times– No assumption on the delay – One may be in HW and the other in SW

Page 20: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

20© S. Ramesh / Kavi Arya / Krithi Ramamritham

Interaction Example

tea

USER

coffeeTiredidle

pour - coffee

pour - tea

Change

VM

Page 21: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

21© S. Ramesh / Kavi Arya / Krithi Ramamritham

Precise Execution Semantics• CFSMs is the modeling language - has precise

semantics• Scheduler-based execution

– periodically read various inputs– determine runnable CFSMs (ones that can be

executed)– schedule them in some order (user specifiable)– input status does not change when a CFSM executed

• Atomic Transitions– control returns when no change in status– Time passes when control is with the scheduler

Page 22: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

22© S. Ramesh / Kavi Arya / Krithi Ramamritham

Verification of CFSMs• Precise semantics enable analysis• Functional Verification

– Simulation– Formal Verification

• Property verification• State-space analysis

• Timing Verification possible– mapping information and time estimates of various

transitions– easier to make as transitions are st.line code– System Co-simulation– use of Ptolemy tool

Page 23: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

23© S. Ramesh / Kavi Arya / Krithi Ramamritham

Next Step• Architecture Selection

– Choice of processors, DSP, ASIC,– Library of processors and architectures

available in POLIS• Partitioning of CFSMs• Manual Step

Page 24: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

24© S. Ramesh / Kavi Arya / Krithi Ramamritham

Synthesis• HW synthesis

– Translation of CFSMs to netlist– Standard synthesis tools– Synthesis to FPGAs possible

• SW synthesis– C - code from CFSMs– application specific RTOS

• scheduler, I/O driver

Page 25: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

25© S. Ramesh / Kavi Arya / Krithi Ramamritham

Synthesis (contd.)

• Interfacing Synthesis– external world– HW-SW, SW-HW interface

• All these steps are automatic with some user inputs

Page 26: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

26© S. Ramesh / Kavi Arya / Krithi Ramamritham

Interface Synthesis• Involves translating CFSM communication

across different implementation domains• Need to be done with care - signals may get

lost• Appropriate protocol required across

different domains• SW - SW communication

– RTOS handles this• HW - HW and HW - Env.

– Simple using a set of wires

Page 27: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

27© S. Ramesh / Kavi Arya / Krithi Ramamritham

Interface Synthesis• Envn. - SW and HW - SW:

– Request - Acknowledge protocol– Events received by the RTOS– Polling/Interrupt

• Envn. - HW, SW - Envn., SW - HW:– Uses an edge detector to translate a pulse

(lasting more than one cycle) to the one cycle per event HW protocol

Page 28: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

28© S. Ramesh / Kavi Arya / Krithi Ramamritham

SW to SW• For every event, RTOS maintains

– global value, local flags• Local flags indicate to each SW-CFSM, that

the event is present• Then the SW-CFSM fetches the value from

the global one• Flag reset once the value is accessed• Atomicity problem

– Use two copies of flags: active and frozen– During the reaction use frozen flags

Page 29: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

29© S. Ramesh / Kavi Arya / Krithi Ramamritham

HW to SW• Events can be polled or drive an interrupt• For polled event:

– allocate I/O port bits for status, value and acknowledge

– generate the polling task that acks and emits all the occurred events

• For events driving an interrupt– Allocate I/O port bits for value– Allocate an interrupt vector– Create a service routine that emits the event

Page 30: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

30© S. Ramesh / Kavi Arya / Krithi Ramamritham

HW-SW Interface

Page 31: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

31© S. Ramesh / Kavi Arya / Krithi Ramamritham

SW to HW

• Allocate I/O port bits for value and status• Write value to I/O port• Create a pulse on the status flag

Page 32: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

32© S. Ramesh / Kavi Arya / Krithi Ramamritham

SW-HW interface

Page 33: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

33© S. Ramesh / Kavi Arya / Krithi Ramamritham

RTOS• Event Handler: Between SW-CFSMs and

across different domains– Polling tasks, interrupt service routines, data

structures for each SW-CFSM port allocation etc.

• Scheduler: Schedule different SW-CFSMs– Different scheduling algorithms:

• Round-robin, priority-based, preemptive or not• RMA, EDF etc.

Page 34: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

34© S. Ramesh / Kavi Arya / Krithi Ramamritham

Systems Developed• Many systems• Automotive Applications

– Dashboard product– Engine management unit

Page 35: © S. Ramesh / Kavi Arya / Krithi Ramamritham 1 IT-606 Embedded Systems (Software ) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

35© S. Ramesh / Kavi Arya / Krithi Ramamritham

POLIS• Free and can be downloaded• Web-address:

– www-cad.eecs.berkeley.edu