You are on page 1of 93

CS684 Embedded Systems (Software)

Embedded Applications Kavi Arya CSE/ IIT Bombay


Krithi Ramamritham / Kavi Arya IIT Bombay

Examples of Embedded Systems

We will look at details o


! "irebird # robot a$d sim%le &i'ital Camera
IIT Bombay Krithi Ramamritham / Kavi Arya

Embedded Applications They are everywhere! ! ! ! ! ! ! wristwatches, washing machines, microwave ovens, elevators, mobile telephones, printers, FAX machines, telephone exchanges, automobiles, aircrafts
IIT Bombay

Krithi Ramamritham / Kavi Arya

Common Design Metrics


! N E !Non"recurring engineering# cost ! $nit cost ! %i&e !bytes, gates# ! 'erformance !execution time# ! 'ower !more power() more heat * less battery time# ! Flexibility !ability to change functionality# ! Time to prototype ! Time to mar+et ! ,aintainability ! -orrectness ! %afety !probability that system won.t cause harm#
Krithi Ramamritham / Kavi Arya IIT Bombay

Embedded Apps
! A modern home + has o$e 'e$eral %,r%ose deskto% -C + b,t has a do.e$ o embedded systems/

! ,ore prevalent in industrial sectors


+ hal a do.e$ embedded 0om%,ters i$ moder$ a,tomobiles + 0hemi0al a$d $,0lear %ower %la$ts

Krithi Ramamritham / Kavi Arya

IIT Bombay

Embedded Applications
A$ embedded system ty%i0ally has a di'ital si'$al %ro0essor a$d a variety o I/2 devi0es 0o$$e0ted to se$sors a$d a0t,ators/
Com%,ter 30o$troller4 is s,rro,$ded by other s,bsystems5 se$sors a$d a0t,ators

Com%,ter 66 Co$troller7s ,$0tio$ is 8 ! to mo$itor %arameters o %hysi0al %ro0esses o its s,rro,$di$' system ! to 0o$trol these %ro0esses whe$ever $eeded /
Krithi Ramamritham / Kavi Arya IIT Bombay

Simple Examples
A simple thermostat controller ! periodically reads temperature of chamber ! switches on or off the cooling system/ A pacema+er ! constantly monitors the heart ! paces the heart when heart beats are missed

Krithi Ramamritham / Kavi Arya

IIT Bombay

Example: Elevator Controller

Krithi Ramamritham / Kavi Arya

IIT Bombay

1. Digital Camera: An Embedded System


Source: Embedded System Design: Fran !a"id# $ony !argis %&o"n 'iley ( Sons) *nc.+,,-.

! 0ntroduction to a simple digital camera ! e1uirements specification ! 2esigner.s perspective ! 2esign

Krithi Ramamritham / Kavi Arya

IIT Bombay

/e0uirements Specification ! %ystem.s re1uirements 3 what system should do


+ =o$ ,$0tio$al re>,ireme$ts

! Co$strai$ts o$ desi'$ metri0s 3e/'/5 ?sho,ld ,se </<<1 watt or less@4


+ ",$0tio$al re>,ireme$ts

! SystemAs behavior 3e/'/5 ?o,t%,t B sho,ld be i$%,t C times 2@4 + D/


Krithi Ramamritham / Kavi Arya IIT Bombay

/e0uirements Specification1 0nitial specification may be very general and come from mar+eting dept/
! E/'/5 short do0,me$t detaili$' market $eed or a low6 e$d di'ital 0amera that8
+ + + + + + captures and stores at least 45 low"res images and uploads to '-, costs around 6755 with single medium"si&e 0- costing less that 684, has long as possible battery life, has expected sales volume of 855,555 if mar+et entry 9 : months, 755,555 if between : and 78 months, insignificant sales beyond 78 months

Krithi Ramamritham / Kavi Arya

IIT Bombay

2onfunctional re0uirements ! 2esign metrics of importance based on initial specification


+ 'erformance8 time re>,ired to %ro0ess ima'e + %i&e8 $,mber o eleme$tary lo'i0 'ates 326i$%,t =A=& 'ate4 i$ IC + 'ower8 meas,re o av'/ ele0tri0al e$er'y 0o$s,med while %ro0essi$' + Energy8 battery li etime 3%ower E time4
Krithi Ramamritham / Kavi Arya IIT Bombay

2onfunctional re0uirements1 ! -onstrained metrics


+ #al,es must be below 3sometimes above4 0ertai$ threshold

! ;ptimi&ation metrics
+ Im%rove as m,0h as %ossible to im%rove %rod,0t

! ,etric can be both constrained and optimi&ation

Krithi Ramamritham / Kavi Arya

IIT Bombay

2onfunctional re0uirements1 ! 'ower


+ F,st o%erate below 0ertai$ tem%erat,re 30ooli$' a$ $ot %ossible4 + There ore5 0o$strai$ed metri0

! Energy
+ Red,0i$' %ower or time red,0es e$er'y + 2%timi.ed metri08 wa$t battery to last as lo$' as %ossible

Krithi Ramamritham / Kavi Arya

IIT Bombay

2onfunctional re0uirements1
! 'erformance
+ F,st %ro0ess ima'e ast e$o,'h to be ,se ,l + 1 se0 reaso$able 0o$strai$t
! Slower wo,ld be a$$oyi$' ! "aster $ot $e0essary or low6e$d o market

+ There ore5 0o$strai$ed metri0

! %i&e
+ F,st ,se IC that its i$ reaso$ably si.ed 0amera + Co$strai$ed a$d o%timi.atio$ metri0
! Co$strai$t may be 2<<5<<< 'ates5 b,t smaller wo,ld be 0hea%er
Krithi Ramamritham / Kavi Arya IIT Bombay

Example: 3anasonic 4umix DMC $56


6@55
! ! ! ! ! ! ! ! ! ! </7 effective ,egapixels 8="8=5mm e1uiv lens, 75x optical &oom * >x 2igital ?oom @/5"inch A-2 with >:5,555 dots resolution ;ptical 0mage %tabili&er 0%; sensitivity up to :>55 Face 2etection AF : shooting modes, 8@ scene modes inc/ 0ntelligent Auto mode Benus Engine 0B processor C2 output 0n"-amera Editing
IIT Bombay

Krithi Ramamritham / Kavi Arya

1. Digital Camera: An Embedded System

2esign
+ "o,r im%leme$tatio$s + Iss,es8

! Ge$eral6%,r%ose vs/ si$'le6 %,r%ose %ro0essorsH ! -artitio$i$' o ,$0tio$ality amo$' di ere$t %ro0essor ty%esH

Krithi Ramamritham / Kavi Arya

IIT Bombay

Functional Design ( Mapping


F2

F1

F5 F4

Functional Design
Source: Source: Ian Phillips, ARM Ian Phillips, ARM

F3
(F2)

VSIA 2001 VSIA 2001

Architectural Design
(F3) (F4)

(F5)

HW1

HW2

HW3

HW4

RTOS/Drivers Hardware Interface

Krithi Ramamritham / Kavi Arya

IIT Bombay

Thread

*ntroduction to a simple digital camera ! -aptures images ! %tores images in digital format
+ =o ilm + F,lti%le ima'es stored i$ 0amera
! =,mber de%e$ds o$ memory a$d bits/ima'e

! 2ownloads images to '+ Serial 0omm 3ISB5 et0/4 + Wireless 3Bl,etooth5 :<2/115 D4

Krithi Ramamritham / Kavi Arya

IIT Bombay

*ntroduction to a simple digital camera1

! ;nly recently possible


+ Systems6o$6a60hi% ! F,lti%le %ro0essors a$d memories o$ o$e IC + Ji'h60a%a0ity lash memory

! Bery simple description used for example


+ Fa$y more eat,res with real di'ital 0amera ! #ariable si.e ima'es5 ima'e deletio$5 di'ital stret0hi$'5 .oomi$' i$ a$d o,t5 et0/
Krithi Ramamritham / Kavi Arya IIT Bombay

Designer7s perspective ! Two +ey tas+s


1/ -ro0essi$' ima'es a$d stori$' i$ memory ! Whe$ sh,tter %ressed8 + Ima'e 0a%t,red + Co$verted to di'ital orm by 0har'e60o,%led devi0e 3CC&4 + Com%ressed a$d ar0hived i$ i$ter$al memory 1/ I%loadi$' ima'es to -C ! &i'ital 0amera atta0hed to -C ! S%e0ial so tware 0omma$ds 0amera to tra$smit ar0hived ima'es serially
Krithi Ramamritham / Kavi Arya IIT Bombay

C"arge8coupled device %CCD.


! %pecial sensor that captures an image ! Aight"sensitive silicon solid"state device composed of many cells
Light charge 8-bit value 0 => no exposure 255=> intense light Some columns covered with black strip Light-intensit! here used "or #erobias ad$ustment
Krithi Ramamritham / Kavi Arya
Pixel ro#s

Lens area Covered columns


lectro" mechanical shutter

%lectromechanical shutter activates to expose cells to light &ircuitr! discharges cells' activates shutter' reads 8-bit value o" each cell (alues clocked out o" &&) b! external logic through std parallel bus inter"ace
lectronic circuitr!

Pixel columns

IIT Bombay

5ero8bias error
! ,anufacturing errors cause cells to measure slightly above or below actual light intensity ! Error typically same across columns, but different across rows ! %ome of left most columns bloc+ed by blac+ paint to detect &ero"bias error
+ Readi$' o $o$6.ero i$ blo0ked 0ells is .ero6bias error + Ea0h row is 0orre0ted by s,btra0ti$' the avera'e error o,$d i$ blo0ked 0ells or that row

Krithi Ramamritham / Kavi Arya

IIT Bombay

5ero8bias error1

&overed cells

*ero-bias ad$ustment

1(1 1)* 1)) 191 1)) 122 121 19(

19< 1)1 1*( 1:( 1*1 1(1 1** 19*

1** 11: 11: 111 111 12: 11) 191

1)< 12( 119 111 1(( 1)9 1:* 1:(

1)) 12< 121 1:1 1;2 2<1 2*) 1::

11* 119 129 1(< 1*( 1*1 11* 1:)

112 11; 11: 1(2 1(: 1(1 1(: 119

2): 1)9 1(* 1(( 1(; 129 12; 12;

78 7> 78 75 < < 5 5 D D 8 5 > > 4 4

"7@ "77 "< 5 "D "7 "> "4

12( 1() 1(* 191 1(9 121 119 11:

1*9 1(* 1)) 1:( 1); 1(< 1*1 19<

1)2 1*9 1*; 111 1*) 129 11< 191

129 112 1<: 111 121 1)1 1:1 19:

1(1 1<; 112 1:1 1:* 2<* 2*< 1:(

1<2 1<1 11: 1(< 1)1 1*< 111 19;

;; 1<: 1<; 1(2 1(1 1(< 1() 112

2(* 1(1 121 1(( 1(2 121 12* 12)

$e%ore &ero"'ias ad(ustment

A%ter &ero"'ias ad(ustment

Krithi Ramamritham / Kavi Arya

IIT Bombay

Compression ! %tore more images ! Transmit image to '- in less time ! E'EF !Eoint 'hotographic Experts Froup#

Krithi Ramamritham / Kavi Arya

IIT Bombay

Compression1
E'EF !Eoint 'hotographic Experts Froup#
+ 'opular standard format for representing digital images in a compressed form + 'rovides for a number of different modes of operation + Sequential ,ode used in this lecture provides high compression ratios using 2-T !discrete cosine transform# (others are -- progressive, lossless, hierarchical) + 0mage data divided into bloc+s of = x = pixels + @ steps performed on each bloc+

2-T,Guanti&ation,Cuffman encoding
Krithi Ramamritham / Kavi Arya IIT Bombay

DC$ step ! Transforms original = x = bloc+ into a cosine"fre1uency domain


+ $pper"left corner values represent more of the essence of the image (Average for the image) + Aower"right corner values represent finer details ! -an reduce precision of these values and retain reasonable image 1uality ! Quantize many may become 0
Krithi Ramamritham / Kavi Arya IIT Bombay

DC$ step1 ! F2-T !Forward 2-T# formula


+ -!h# ( if !h (( 5# then 7Hs1rt!8# else 7/5 ! Auxiliary function used in main function F!u,v# + F!u,v# ( I x -!u# x -!v# Jx(5//D Jy(5//D 2xy x cos!K!8u L 7#uH7:# x cos!K!8y L 7#vH7:# ! Fives encoded pixel at row u, column v ! 2xy is original pixel value at row x, column y

! 02-T !0nverse 2-T#


+ everses process to obtain original bloc+ !not needed for this design#

Krithi Ramamritham / Kavi Arya

IIT Bombay

9uanti:ation step ! Achieve high compression ratio by reducing image 1uality


+ educe bit precision of encoded data ! "ewer bits $eeded or e$0odi$' ! 2$e way is divide all val,es by a0tor o 2 + %imple right shifts can do this + eneral! table "riven mapping + 2e1uanti&ation reverses process for decompression
Krithi Ramamritham / Kavi Arya IIT Bombay

9uanti:ation step1

11*< 6:1 1) 2 )) (1 61; 6*

(; 6( 611 611 1( 611 69 61(

6)( 11* 1 61( (9 6; 21 611

61< 69( 6)2 612 6) 6) 61 619

21 61 21 (1 1< 2< ( 6)

6:( 62 6( 62( 621 62: ( 61

11 22 19 61: 9 621 12 9

)1 6* 6(: )ivide * each cell+s value b! 6: 8 1) 621 6)

1)) 61< 2 < 1 * 62 61

* < 61 6: 2 61 61 62

6* 1) < 62 * 61 ( 61

61 6; 6* 62 61 61 61 62

( 61 ( * 1 ( < 61

61< < < 6( 6( 6) < <

1 ( 2 62 1 6( 2 1

* 61 6* 1 61 2 6( 61

A%ter 'eing decoded using DC) Krithi Ramamritham / Kavi Arya

A%ter *uanti&ation IIT Bombay

;uffman encoding step

#sually, first item of bloc$s are store" "ifferentially %igzag brings equal values together &' run-length enco"ing
Krithi Ramamritham / Kavi Arya IIT Bombay

;uffman encoding step1


! 'erform Cuffman encoding
+ ,ore fre1uently occurring pixels assigned short binary code + Aonger binary codes left for less fre1uently occurring pixels

! Each pixel in serial list converted to Cuffman encoded values


+ ,uch shorter list, thus compression

Krithi Ramamritham / Kavi Arya

IIT Bombay

;uffman encoding example1


! ! 'ixel fre1uencies on left
+ 'ixel value 37 occurs 74 times + 'ixel value 7> occurs 7 time

Muild Cuffman tree from bot up


+ -reate one leaf node for each pixel value and assign fre1uency as node.s value + -reate an internal node by Noining any two nodes whose sum is a minimal value/ This sum is internal nodes value + epeat until complete binary tree
Pixel %re*uencies
61 1*E < :E 62 1E 1 *E 2 *E ( *E * *E 6( )E 6* (E 61< 2E 1)) 1E 6; 1E 6: 1E 6) 1E 1 1E 1) 1E

5u%%man tree
3 ,
/2 . -

5u%%man codes
61 < 62 1 2 ( * 6( 6* 61< 1)) 6; 6: 6) 1 1)
<< 1<< 11< <1< 111< 1<1< <11< 1111< 1<11< <111< 111111 11111< 1<1111 1<111< <11111 <1111<

"+ +

+ -

+ ,

+ 1 2

+ 4 + 0

Traverse tree from root to leaf to obtain binary code for leaf.s pixel value
+ Append 5 for left traversal, 7 for right traversal

3 "/ / ". ,

+ +

0
,

"+0 / + +,

. /

. + ",

3 / + "2 + +,,

/ + "1

"+ 3

Cuffman encoding is reversible


+ No code is prefix of another code

Krithi Ramamritham / Kavi Arya

IIT Bombay

Arc"ive step
! ! ecord starting address and image si&e
+ -an use lin+ed list

;ne possible way to archive images + 0f max number of images archived is NO ! %et aside memory for N addresses and N image"si&e variables ! Peep counter for location of next available address ! 0nitiali&e addresses and image"si&e variables to 5 ! %et global memory address to N x >
+ Assuming addresses, image"si&e variables occupy N x > bytes

! First image archived starting at address N x > ! Flobal memory address updated to N x > L !compressed image si&e# ,emory re1uirement based on N, image si&e, and average compression ratio

Krithi Ramamritham / Kavi Arya

IIT Bombay

<ploading to 3C ! Qhen connected to '- and upload command received


+ Read ima'es rom memory + Tra$smit serially ,si$' IARTK + While tra$smitti$'

eset pointers, image"si&e variables and global memory pointer accordingly


KIART 3I$iversal Asy$0hro$o,s Re0eiver Tra$smitter4

Krithi Ramamritham / Kavi Arya

IIT Bombay

*nformal functional specification


! Flowchart brea+s functionality down into simpler functions ! Each function.s details described in English ! Aow 1uality image has resolution of :> x :> ! ,apping functions to a particular processor type not done at this stage
CCD input

7ero"'ias ad(ust

DC)

8uanti&e

!es no Done;

Archive in memor!

!es

More 191 'loc:s;

no

)ransmit seriall!

serial output e6g6, 0++0+0666

Krithi Ramamritham / Kavi Arya

IIT Bombay

*nformal functional specification


CCD input

7ero"'ias ad(ust DC) 8uanti&e


Archive in memor!
no !es

Done;

!es

More 191 'loc:s;

no

)ransmit seriall!

serial output e6g6, 0++0+0666

Krithi Ramamritham / Kavi Arya

IIT Bombay

/efined functional specification


! efine informal specification into one that can actually be executed ! -an use -"li+e code to describe each function
+ Called system6level model5 %rototy%e5 or sim%ly model + Also is irst im%leme$tatio$
xecuta'le model o% digital camera
CCD6C

+0+0++0+0 ++0+0+0+0 0+0+0++0+ 666

CCDPP6C image %ile C<)RL6C

C>D C6C

+0+0+0+0+ 0+0+0+0+0 +0+0+0+0+ 0666 =AR)6C output %ile

Krithi Ramamritham / Kavi Arya

IIT Bombay

Executable model of digital camera


+0+0++0+0++0+0+0+00+0+0++0+666

CCD6C

CCDPP6C
image %ile

C>D C6C

C<)RL6C

+0+0+0+0+0+0+0+0+0+0+0+0+0+06 66

=AR)6C
output %ile

Krithi Ramamritham / Kavi Arya

IIT Bombay

/efined functional specification1


! -an provide insight into operations of system
+ -ro ili$' 0a$ i$d 0om%,tatio$ally i$te$sive ,$0tio$s

! -an obtain sample output used to verify correctness of final implementation

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD module
! %imulates real --2 ! (c")nitialize is passed name of image file ! (c"(apture reads RimageS from file into buffer ! (c"*op*i+el outputs pixels one at a time from buffer

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD module
! ! ! ! %imulates real --2 (c")nitialize is passed name of image file (c"(apture reads RimageS from file (c"*op*i+el outputs pixels one at a time

#include <stdio.h> #define SZ_ROW #define SZ_COL 64 (64 + 2)

st tic !"L# $i% &e!ile' ndle( st tic ch ) *uffe)+SZ_ROW,+SZ_COL,( st tic unsi&ned )o-"nde./ col"nde.(

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD*nitiali:e module
0oid Ccd"niti li1e is passed name of image file (const ch ) $i% &e!ile2 %e) 3 i% &e!ile' ndle 4 fo5en(i% &e!ile2 %e/ 6)6)( )o-"nde. 4 78( col"nde. 4 78( 9

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCDCapture module
0oid CcdC 5tu)e(0oid) 3reads int 5i.el( )e-ind(i% &e!ile' ndle)( fo)()o-"nde.4:( )o-"nde.<SZ_ROW( )o-"nde.++) 3 fo)(col"nde.4:( col"nde.<SZ_COL( col"nde.++) 3 if( fsc nf(i% &e!ile' ndle/ 6;i6/ <5i.el) 44 8 ) 3 *uffe)+)o-"nde.,+col"nde., 4 (ch ))5i.el( 9 9 9 9 )o-"nde. 4 :( col"nde. 4 :(
IIT Bombay Krithi Ramamritham / Kavi Arya

RimageS from file into buffer

CCD3op3ixel module
! (c"*op*i+el outputs pixels one at a time from buffer

ch ) Ccd=o5=i.el(0oid) 3 ch ) 5i.el( 5i.el 4 *uffe)+)o-"nde.,+col"nde.,( if( ++col"nde. 44 SZ_COL ) 3 col"nde. 4 :( if( ++)o-"nde. 44 SZ_ROW ) 3 col"nde. 4 78( )o-"nde. 4 78( 9 9 )etu)n 5i.el( 9
Krithi Ramamritham / Kavi Arya IIT Bombay

CCD module
! ! ! ! %imulates real --2 (c")nitialize is passed name of image file (c"(apture reads RimageS from file (c"*op*i+el outputs pixels one at a time
#include <stdio.h> #define SZ_ROW #define SZ_COL 64 (64 + 2) 0oid Ccd"niti li1e(const ch ) $i% &e!ile2 %e) 3 i% &e!ile' ndle 4 fo5en(i% &e!ile2 %e/ 6)6)( )o-"nde. 4 78( col"nde. 4 78( 9 0oid CcdC 5tu)e(0oid) 3 int 5i.el( )e-ind(i% &e!ile' ndle)( fo)()o-"nde.4:( )o-"nde.<SZ_ROW( )o-"nde.++) 3 fo)(col"nde.4:( col"nde.<SZ_COL( col"nde.++) 3 if( fsc nf(i% &e!ile' ndle/ 6;i6/ <5i.el) 44 8 ) 3 *uffe)+)o-"nde.,+col"nde., 4 (ch ))5i.el( 9 9 9 )o-"nde. 4 :( col"nde. 4 :( 9

st tic !"L# $i% &e!ile' ndle( st tic ch ) *uffe)+SZ_ROW,+SZ_COL,( st tic unsi&ned )o-"nde./ col"nde.( ch ) Ccd=o5=i.el(0oid) 3 ch ) 5i.el( 5i.el 4 *uffe)+)o-"nde.,+col"nde.,( if( ++col"nde. 44 SZ_COL ) 3 col"nde. 4 :( if( ++)o-"nde. 44 SZ_ROW ) 3 col"nde. 4 78( )o-"nde. 4 78( 9 9 )etu)n 5i.el( 9

Krithi Ramamritham / Kavi Arya

IIT Bombay

Executable model of digital camera


+0+0++0+0++0+0+0+00+0+0++0+666

CCD6C

CCDPP6C
image %ile

C>D C6C

C<)RL6C

+0+0+0+0+0+0+0+0+0+0+0+0+0+06 66

=AR)6C
output %ile

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD33 %CCD 3re3rocessing. module


! 'erforms &ero"bias adNustment ! (c"pp(apture uses (c"(apture and (c"*op*i+el to obtain image ! 'erforms &ero"bias adNustment after each row read in

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD33 %CCD 3re3rocessing. module


! ! ! 'erforms &ero"bias adNustment (c"pp(apture uses (c"(apture and (c"*op*i+el to obtain image 'erforms &ero"bias adNustment after each row read in
0oid Ccd55C 5tu)e(0oid) 3 ch ) *i s( CcdC 5tu)e()( fo)()o-"nde.4:( )o-"nde.<SZ_ROW( )o-"nde.++) 3 fo)(col"nde.4:( col"nde.<SZ_COL( col"nde.++) 3 *uffe)+)o-"nde.,+col"nde., 4 Ccd=o5=i.el()( 9 *i s 4 (Ccd=o5=i.el() + Ccd=o5=i.el()) > 2( fo)(col"nde.4:( col"nde.<SZ_COL( col"nde.++) 3 *uffe)+)o-"nde.,+col"nde., 74 *i s( 9 9 )o-"nde. 4 :( col"nde. 4 :( 9 9 9 )etu)n 5i.el( 9 9 ch ) Ccd55=o5=i.el(0oid) 3 ch ) 5i.el( 5i.el 4 *uffe)+)o-"nde.,+col"nde.,( if( ++col"nde. 44 SZ_COL ) 3 col"nde. 4 :( if( ++)o-"nde. 44 SZ_ROW ) 3 col"nde. 4 78( )o-"nde. 4 78(
#define SZ_ROW

64 64

#define SZ_COL

st tic ch ) *uffe)+SZ_ROW,+SZ_COL,( st tic unsi&ned )o-"nde./ col"nde.( 0oid Ccd55"niti li1e() 3 )o-"nde. 4 78( col"nde. 4 78(

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD33Capture module
0oid Ccd55C 5tu)e(0oid) 3 ch ) *i s( CcdC 5tu)e()( fo)()o-"nde.4:( )o-"nde.<SZ_ROW( )o-"nde.++) 3 fo)(col"nde.4:( col"nde.<SZ_COL( col"nde.++) 3 *uffe)+)o-"nde.,+col"nde., 4 Ccd=o5=i.el()( 9 *i s 4 (Ccd=o5=i.el() + Ccd=o5=i.el()) > 2( fo)(col"nde.4:( col"nde.<SZ_COL( col"nde.++) 3 *uffe)+)o-"nde.,+col"nde., 74 *i s( 9 9 )o-"nde. 4 :( col"nde. 4 :(
IIT Bombay
9 Krithi Ramamritham / Kavi Arya

Executable model of digital camera


+0+0++0+0++0+0+0+00+0+0++0+666

CCD6C

CCDPP6C
image %ile

C>D C6C

C<)RL6C

+0+0+0+0+0+0+0+0+0+0+0+0+0+06 66

=AR)6C
output %ile

Krithi Ramamritham / Kavi Arya

IIT Bombay

<A/$ module
! Actually a half $A T + 2$ly tra$smits5 does $ot re0eive ! #art)nitialize is passed name of file to output to ! #artSen" transmits !writes to output file# bytes at a time

#include <stdio.h> st tic !"L# $out5ut!ile' ndle( 0oid ? )t"niti li1e(const ch ) $out5ut!ile2 %e) 3 out5ut!ile' ndle 4 fo5en(out5ut!ile2 %e/ 6-6)( 9 0oid ? )tSend(ch ) d) 3 f5)intf(out5ut!ile' ndle/ 6;i@n6/ (int)d)( 9

Krithi Ramamritham / Kavi Arya

IIT Bombay

Executable model of digital camera


+0+0++0+0++0+0+0+00+0+0++0+666

CCD6C

CCDPP6C
image %ile

C>D C6C

C<)RL6C

+0+0+0+0+0+0+0+0+0+0+0+0+0+06 66

=AR)6C
output %ile

Krithi Ramamritham / Kavi Arya

IIT Bombay

C=DEC module
! ! ! ! ,odels F2-TT encoding ibuffer holds original = x = bloc+ obuffer holds encoded = x = bloc+ (o"ec*ush*i+el called :> times to fill ibuffer with original bloc+ ! (o"ec,o-"ct called once to transform = x = bloc+ + EE%lai$ed i$ $eEt slide ! (o"ec*op*i+el called :> times to retrieve encoded bloc+ from obuffer

*Forward Discrete Cosine Transform Krithi Ramamritham / Kavi Arya IIT Bombay

C=DEC module
! ! ! ! ,odels F2-T encoding 0oid Codec"niti li1e(0oid) 3 id. 4 :( 9 ibuffer holds original = x = bloc+ 0oid Codec=ush=i.el(sho)t 5) 3 obuffer holds encoded = x = bloc+ if( id. 44 64 ) id. 4 :( i*uffe)+id. > A,+id. ; A, 4 5( id.++( (o"ec*ush*i+el called :> times to 9 fill ibuffer with original bloc+ 0oid CodecBo!dct(0oid) 3 int ./ C( ! (o"ec,o-"ct called once to fo)(.4:( .<A( .++) 3 fo)(C4:( C<A( C++) transform = x = bloc+ o*uffe)+.,+C, 4 !BCD(./ C/ i*uffe))( 9 + EE%lai$ed i$ $eEt slide id. 4 :( 9 ! (o"ec*op*i+el called :> times to sho)t Codec=o5=i.el(0oid) 3 retrieve encoded bloc+ from obuffer sho)t 5(
st tic sho)t i*uffe)+A,+A,/ o*uffe)+A,+A,/ id.( if( id. 44 64 ) id. 4 :( 5 4 o*uffe)+id. > A,+id. ; A,( id.++( )etu)n 5( 9

Krithi Ramamritham / Kavi Arya

IIT Bombay

FDC$ %For>ard DC$. formula


C3h4 L i 3h LL <4 the$ 1/s>rt324 else 1/< ! A,Eiliary ,$0tio$ ,sed i$ mai$ ,$0tio$ "3,5v4

"3,5v4 L M E C3,4 E C3v4 NEL<//9 NyL<//9 &Ey E 0os3O32E P 14,/114 E 0os3O32y P 14v/11 L M E C3,4 E C3v4 NEL<//9 0os3O32E P 14,/114 E NyL<//9 &Ey E 0os3O32y P 14v/11 ! Fives encoded pixel at row u, column v ! 2xy is original pixel value at row x, column y
Krithi Ramamritham / Kavi Arya IIT Bombay

C=DEC1
! 0mplementing F2-T formula ! ;nly :> possible inputs to (.S, so table can be used to save performance time
+ "loati$'6%oi$t val,es m,lti%lied by (2519: a$d ro,$ded to $earest i$te'er + (2519: 0hose$ i$ order to store ea0h val,e i$ 2 bytes o memory + "iEed6%oi$t re%rese$tatio$ eE%lai$ed more later

! -,(/ unrolls inner loop of summation, implements outer summation as two consecutive for loops
Krithi Ramamritham / Kavi Arya IIT Bombay

C=DEC1
! ! 0mplementing F2-T formula ;nly :> possible inputs to (.S, so table can be used to save performance time
+ + + Floating"point values multiplied by @8,:D= and rounded to nearest integer @8,:D= chosen in order to store each value in 8 bytes of memory Fixed"point representation explained more later
9( st tic int !BCD(int u/ int 0/ sho)t i%&+A,+A,) 3 dou*le s+A,/ ) 4 :( int .( fo)(.4:( .<A( .++) 3
static short ONE_OVER_SQRT_TWO = 23170; static double retur" 2 static double !i"t h' ( OS!i"t #$% i"t u&' ( OS_T)*+E,#$-,u&- . 327/010;

st tic const sho)t COS_DEFL#+A,+A, 4 3 3 G2H6A/ 3 G2H6A/ 3 G2H6A/ 3 G2H6A/ 3 G2H6A/ G28GA/ 2H24I/ G:2HG/ 82IGJ/ 2H24I/ 2G8H:/ 8A2:4/ 82IGJ/ 6GJ2 9/

76GJ2/ 72G8H:/ 7G28GA/ 7G:2HG/ 78A2:4 9/ 6GJ2/ G:2HG/ 2H24I 9/

8A2:4/ 782IGJ/ 7G28GA/ 72G8H:/ 6GJ2/ 7G:2HG/ 78A2:4/ 76GJ2/ 7G:2HG/ 8A2:4/ 2G8H:/

2H24I/ 782IGJ/ 7G28GA 9/ G28GA 9/

2G8H:/ 72H24I/ 782IGJ/ 76GJ2/

3 G2H6A/ 78A2:4/ 782IGJ/ 3 G2H6A/ 72H24I/ 3 G2H6A/ 7G28GA/ 82IGJ/

G28GA/ 72G8H:/ 6GJ2/ 72G8H:/

G:2HG/ 72H24I 9/ 8A2:4 9/ 76GJ2 9

G28GA/ 7G:2HG/ 82IGJ/

-,(/ unrolls inner loop of summation, implements outer summation as two consecutive for loops

G:2HG/ 72H24I/

2G8H:/ 78A2:4/

s+., 4 i%&+.,+:, $ COS(:/ 0) + i%&+.,+8, $ COS(8/ 0) + i%&+.,+2, $ COS(2/ 0) + i%&+.,+G, $ COS(G/ 0) + i%&+.,+4, $ COS(4/ 0) + i%&+.,+I, $ COS(I/ 0) + i%&+.,+6, $ COS(6/ 0) + i%&+.,+H, $ COS(H/ 0)( 9 fo)(.4:( .<A( .++) ) +4 s+., $ COS(./ u)( )etu)n (sho)t)() $ .2I $ C(u) $ C(0))( 9

retur" h 3 110 4 ONE_OVER_SQRT_TWO . 327/010; 2

Krithi Ramamritham / Kavi Arya

IIT Bombay

Executable model of digital camera


+0+0++0+0++0+0+0+00+0+0++0+666

CCD6C

CCDPP6C
image %ile

C>D C6C

C<)RL6C

+0+0+0+0+0+0+0+0+0+0+0+0+0+06 66

=AR)6C
output %ile

Krithi Ramamritham / Kavi Arya

IIT Bombay

C2$/4 %controller. module


! Ceart of the system ! (ntrl(apture)mage uses --2'' module to input image and place in buffer ! (ntrl(ompress)mage brea+s the :> x :> buffer into = x = bloc+s and performs F2-T on each bloc+ using the -;2E- module + Also %er orms >,a$ti.atio$ o$ ea0h blo0k ! (ntrlSen")mage transmits encoded image serially using $A T module

Krithi Ramamritham / Kavi Arya

IIT Bombay

C2$/4 %controller. module


! ! ! ! Ceart of the system (ntrl)nitialize for consistency with other modules only (ntrl(apture)mage uses --2'' module to input image and place in buffer (ntrl(ompress)mage brea+s the :> x :> buffer into = x = bloc+s and performs F2-T on each bloc+ using the -;2E- module + Also %er orms >,a$ti.atio$ o$ ea0h blo0k (ntrlSen")mage transmits encoded image serially using $A T module
0oid Cnt)lSend"% &e(0oid) 3 fo)(i4:( i<SZ_ROW( i++) fo)(K4:( K<SZ_COL( K++) 3 te%5 4 *uffe)+i,+K,( ? )tSend(((ch )$)<te%5)+:,)( ? )tSend(((ch )$)<te%5)+8,)( 9 9 9 0oid Cnt)lCo%5)ess"% &e(0oid) 3 fo)(i4:( i<2?L_ROW_FLOCMS( i++) fo)(K4:( K<2?L_COL_FLOCMS( K++) 3 fo)(N4:( N<A( N++) fo)(l4:( l<A( l++) Codec=ush=i.el( (ch ))*uffe)+i $ A + N,+K $ A + l,)( CodecBo!dct()(>$ 5 )t 8 7 !BCD $> fo)(N4:( N<A( N++) 64 64 (SZ_ROW > A) (SZ_COL > A) 9 9 9 fo)(l4:( l<A( l++) 3 *uffe)+i $ A + N,+K $ A + l, 4 Codec=o5=i.el()( >$ 5 )t 2 7 Ou nti1 tion $> *uffe)+i$A+N,+K$A+l, >>4 6( >$ send u55e) *Cte $> >$ send lo-e) *Cte $>

0oid Cnt)lC 5tu)e"% &e(0oid) 3 Ccd55C 5tu)e()( fo)(i4:( i<SZ_ROW( i++) fo)(K4:( K<SZ_COL( K++) *uffe)+i,+K, 4 Ccd55=o5=i.el()( 9 #define SZ_ROW #define SZ_COL #define 2?L_ROW_FLOCMS #define 2?L_COL_FLOCMS

st tic sho)t *uffe)+SZ_ROW,+SZ_COL,/ i/ K/ N/ l/ te%5( 0oid Cnt)l"niti li1e(0oid) 39

Krithi Ramamritham / Kavi Arya

IIT Bombay

C2$/4 %controller. module


&oid "trl o56ress75a8e!&oid' ( 9or!i=0; i:N;<_ROW_*+O =S; i>>' 9or!?=0; ?:N;<_ O+_*+O =S; ?>>' ( 9or!@=0; @:0; @>>' 9or!l=0; l:0; l>>' odecAushAi#el! !char'bu99er,i B 0 > @-,? B 0 > l-'; odecCoDdct!';.B 6art 1 E DC T B. 9or!@=0; @:0; @>>' 9or!l=0; l:0; l>>' ( bu99er,i B 0 > @-,? B 0 > l- = .B 6art 2 E Fua"tiGatio" B. bu99er,iB0>@-,?B0>l- HH= /; 2 2
Krithi Ramamritham / Kavi Arya

odecAo6Ai#el!';

IIT Bombay

3utting it all toget"er


! 0ain initiali&es all modules, then uses -NT A module to capture, compress, and transmit one image ! This system"level model can be used for extensive experimentation + B,'s m,0h easier to 0orre0t here rather tha$ i$ later models

int % in(int )&c/ ch ) $ )&0+,) 3 ch ) $u )tOut5ut!ile2 %e 4 )&c > 8 P )&0+8, Q 6u )t_out.t.t6( ch ) $i% &e!ile2 %e 4 )&c > 2 P )&0+2, Q 6i% &e.t.t6( >$ initi li1e the %odules $> ? )t"niti li1e(u )tOut5ut!ile2 %e)( Ccd"niti li1e(i% &e!ile2 %e)( Ccd55"niti li1e()( Codec"niti li1e()( Cnt)l"niti li1e()( >$ si%ul te function litC $> Cnt)lC 5tu)e"% &e()( Cnt)lCo%5)ess"% &e()( Cnt)lSend"% &e()( 9

Krithi Ramamritham / Kavi Arya

IIT Bombay

Design
! 2etermine system.s architecture
+ -ro0essors ! A$y 0ombi$atio$ o si$'le6%,r%ose 30,stom or sta$dard4 or 'e$eral6%,r%ose %ro0essors + Femories5 b,ses

! ,ap functionality to that architecture


+ F,lti%le ,$0tio$s o$ o$e %ro0essor + 2$e ,$0tio$ o$ o$e or more %ro0essors

Krithi Ramamritham / Kavi Arya

IIT Bombay

Design..
! 0mplementation + A %arti0,lar ar0hite0t,re a$d ma%%i$' + Sol,tio$ s%a0e is set o all im%leme$tatio$s ! %tarting point + Qow6e$d 'e$eral6%,r%ose %ro0essor 0o$$e0ted to lash memory ! All ,$0tio$ality ma%%ed to so tware r,$$i$' o$ %ro0essor ! Is,ally satis ies %ower5 si.e5 time6to6market 0o$strai$ts ! I timi$' 0o$strai$t $ot satis ied the$ try8 + ,se si$'le6%,r%ose %ro0essors or time60riti0al ,$0tio$s + rewrite ,$0tio$al s%e0i i0atio$
Krithi Ramamritham / Kavi Arya IIT Bombay

*mplementation 1: Microcontroller alone


! Aow"end processor could be 0ntel =547 microcontroller ! Total 0- cost including N E about 64 ! Qell below 855 mQ power ! Time"to"mar+et about @ months ! CoweverU

Krithi Ramamritham / Kavi Arya

IIT Bombay

*mplementation 1: Microcontroller alone1


! Cowever, one image per second not possible + 12 FJ.5 12 0y0les %er i$str,0tio$ ! EEe0,tes o$e millio$ i$str,0tio$s %er se0o$d + CcdppCapture has $ested loo%s LR )<;1 31)E1)4 iteratio$s ! S1<< assembly i$str,0tio$s ea0h iteratio$ ! )<;5<<< 3)<;1 E 1<<4 i$str,0tio$s %er ima'e ! Jal o b,d'et or readi$' ima'e alo$e + Wo,ld be over b,d'et a ter addi$' 0om%,te6i$te$sive &CT a$d J, ma$ e$0odi$'
Krithi Ramamritham / Kavi Arya IIT Bombay

*mplementation +: Microcontroller and CCD33


PR>M 10-+ RAM

S,&

=AR)

CCDPP

Krithi Ramamritham / Kavi Arya

IIT Bombay

*mplementation +: Microcontroller and CCD33


PR>M 10-+ RAM S,& =AR) CCDPP

! --2'' function on custom single"purpose processor + Im%roves %er orma$0e + less mi0ro0o$troller 0y0les + I$0reases =RE 0ost a$d time6to6market + Easy to im%leme$t8 Sim%le data%ath5 "ew states i$ 0o$troller ! %imple $A T easy to implement as single"purpose processor also ! EE' ;, for program memory and A, for data memory added as well

Krithi Ramamritham / Kavi Arya

IIT Bombay

Microcontroller
$loc: diagram o% Intel 10-+ processor core

Instruction Decoder

,? R>M Controller

AL=

+/1 RAM

-o %xternal .emor! /us

Krithi Ramamritham / Kavi Arya

IIT Bombay

$loc: diagram o% Intel 10-+ processor core


Instruction Decoder ,? R>M

Microcontroller

Controller AL=

+/1 RAM

)o xternal Memor! $us

! %ynthesi&able version of 0ntel =547 available + Writte$ i$ #J&Q + Ca%t,red at re'ister tra$s er level 3RTQ4 ! Fetches instruction from ;, ! 2ecodes using 0nstruction 2ecoder ! AA$ executes arithmetic operations + So,r0e a$d desti$atio$ re'isters reside i$ RAF ! %pecial data movement instructions used to load and store externally ! %pecial program generates BC2A description of ;, from output of - compilerHlin+er
Krithi Ramamritham / Kavi Arya IIT Bombay

<A/$

FSMD description o% =AR)


invo:ed

0dle
: I@0 IA1

Start: )ransmi t L>B

! $A T in idle mode until invo+ed )ata: Stop: )ransmit )ransmi + IART i$voked whe$ :<*1 eEe0,tes dataCID, t 5IF5 then IEE I@1 store i$str,0tio$ with IARTAs e$able re'ister as tar'et address ! Femory6ma%%ed 0omm,$i0atio$ ! Qower :6bits o memory address or RAF ! I%%er :6bits o memory address or memory6ma%%ed I/2 devi0es ! %tart state transmits 5 indicating start of byte transmission then transitions to 2ata state ! 2ata state sends = bits serially then transitions to %top state, %top state transmits 7 indicating transmission done then transitions bac+ to idle mode

Krithi Ramamritham / Kavi Arya

IIT Bombay

CCD33
! ! ! ! ! ! ! ! Cardware implementation of &ero"bias operations 0nteracts with external --2 chip
+ --2 chip resides external to our %;- mainly because combining --2 with ordinary logic not feasible

0nternal buffer, 1, memory"mapped to =547 Bariables 2, ( are buffer.s row, column indices Fet ow state reads in one row from --2 to 1
+ 11 bytes8 1) %iEels P 2 bla0ked6o,t %iEels

FSMD description o% CCDPP


0dle:
R@0 C@0 R @ 3, R A 3, C A 3, invo:ed

1et2ow:
$GRHGCH@Pxl C@CE+

C A 33

C @ 33

-omputeMias state computes bias for that row 3ext2ow: and stores in variable 1ias REE C@0 FixMias state iterates over same row subtracting 1ias from each element C @ 3, Next ow transitions to Fet ow for repeat of process on next row or to 0dle state when all :> rows completed

&ompute/ias:
$ias@C$GRHG++H E $GRHG+0HD I / C@0

4ix/ias: $GRHGCH@$GRHGCH"$ias

Krithi Ramamritham / Kavi Arya

IIT Bombay

Connecting S=C components


! ,emory"mapped + All si$'le6%,r%ose %ro0essors a$d RAF are 0o$$e0ted to :<*1As memory b,s ! ead + -ro0essor %la0es address o$ 116bit address b,s + Asserts read 0o$trol si'$al or 1 0y0le + Reads data rom :6bit data b,s 1 0y0le later + &evi0e 3RAF or S--4 dete0ts asserted read 0o$trol si'$al + Che0ks address + -la0es a$d holds re>,ested data o$ data b,s or 1 0y0le
Krithi Ramamritham / Kavi Arya IIT Bombay

Connecting S=C components1


! Qrite
+ + + + + -ro0essor %la0es address/data o$ address/data b,s Asserts write 0o$trol si'$al or 1 0lo0k 0y0le &evi0e 3RAF or S--4 dete0ts asserted write 0o$trol si'$al Che0ks address b,s Reads a$d stores data rom data b,s

Krithi Ramamritham / Kavi Arya

IIT Bombay

Soft>are
! %ystem"level model provides maNority of code + Fod,le hierar0hy5 %ro0ed,re $ames5 a$d mai$ %ro'ram ,$0ha$'ed ! -ode for $A T and --2'' modules must be redesigned + Sim%ly re%la0e with memory assi'$me$ts ! xdata ,sed to load/store variables over eEter$al memory b,s ! _at_ s%e0i ies memory address to store these variables ! Byte se$t to U_TX_RE by %ro0essor will i$voke IART ! U_!TAT_RE ,sed by IART to i$di0ate its ready or $eEt byte + IART may be m,0h slower tha$ %ro0essor + Similar modi i0atio$ or CC&-- 0ode ! All other modules untouched

Krithi Ramamritham / Kavi Arya

IIT Bombay

Soft>are1

2ewritten 562- module ,riginal code "rom s!stem-level model

Krithi Ramamritham / Kavi Arya

#include <stdio.h> st tic !"L# $out5ut!ile' ndle( 0oid ? )t"niti li1e(const ch ) $out5ut!ile2 %e) 3 out5ut!ile' ndle 4 fo5en(out5ut!ile2 %e/ 6-6)( 9 0oid ? )tSend(ch ) d) 3 f5)intf(out5ut!ile' ndle/ 6;i@n6/ (int)d)( 9

IIT Bombay

st tic unsi&ned ch ) .d t ?_DR_R#S _ t_ 6IIGI( st tic unsi&ned ch ) .d t ?_SDED_R#S _ t_ 6IIG4( 0oid ?ERD"niti li1e(0oid) 39 0oid ?ERDSend(unsi&ned ch ) d) 3 -hile( ?_SDED_R#S 44 8 ) 3 >$ *usC - it $> 9 ?_DR_R#S 4 d( 9

Analysis
! Entire %;- tested on BC2A simulator
+ I$ter%rets #J&Q des0ri%tio$s a$d ,$0tio$ally sim,lates eEe0,tio$ o system ! Re0all %ro'ram 0ode tra$slated to #J&Q des0ri%tio$ o R2F + Tests or 0orre0t ,$0tio$ality + Feas,res 0lo0k 0y0les to %ro0ess o$e ima'e 3%er orma$0e4
,btaining design metrics o" interest
J5DL J5DL J5DL Po#er e*uation S!nthesis tool Fate level simulator gates gates gates

J5DL simulator

Po#er Chip area

xecution time

Sum gates

Krithi Ramamritham / Kavi Arya

IIT Bombay

Analysis1
! Fate"level description obtained through synthesis + Sy$thesis tool like 0om%iler or S--s + Sim,late 'ate6level models to obtai$ data or %ower a$alysis ! =,mber o times 'ates swit0h rom 1 to < or < to 1 + Co,$t $,mber o 'ates or 0hi% area

,btaining design metrics o" interest


J5DL J5DL J5DL Po#er e*uation S!nthesis tool Fate level simulator gates gates gates

J5DL simulator

Po#er Chip area

xecution time

Sum gates

Krithi Ramamritham / Kavi Arya

IIT Bombay

*mplementation +: Microcontroller and CCD33


! Analysis of implementation 8
+ Total eEe0,tio$ time or %ro0essi$' o$e ima'e8 ! ;/1 se0o$ds + -ower 0o$s,m%tio$8 ! </<(( watt + E$er'y 0o$s,m%tio$8 ! </(< To,le 3;/1 s E </<(( watt4 + Total 0hi% area8 ! ;:5<<< 'ates
Krithi Ramamritham / Kavi Arya IIT Bombay

*mplementation ?: Microcontroller and CCD33#Fixed83oint DC$


! </7 seconds still doesn.t meet performance constraint of 7 second ! 2-T operation prime candidate for improvement
+ EEe0,tio$ o im%leme$tatio$ 2 shows mi0ro%ro0essor s%e$ds most 0y0les here + Co,ld desi'$ 0,stom hardware like we did or CC&-! Fore 0om%leE so more desi'$ e ort + I$stead5 will s%eed ,% &CT ,$0tio$ality by modi yi$' behavior

Krithi Ramamritham / Kavi Arya

IIT Bombay

DC$ floating8point cost


! Floating"point cost + &CT ,ses S21< loati$'6%oi$t o%eratio$s %er %iEel tra$s ormatio$ + )<;1 31) E 1)4 %iEels %er ima'e + 1 millio$ loati$'6%oi$t o%eratio$s %er ima'e + =o loati$'6%oi$t s,%%ort with I$tel :<*1
! Com%iler m,st em,late + Ge$erates %ro0ed,res or ea0h loati$'6%oi$t o%eratio$ U m,lt5 add + Ea0h %ro0ed,re ,ses te$s o i$te'er o%eratio$s

+ Th,s5 R 1< millio$ i$te'er o%eratio$s %er ima'e + -ro0ed,res i$0rease 0ode si.e ! Fixed"point arithmetic can improve on this
Krithi Ramamritham / Kavi Arya IIT Bombay

Fixed8point arit"metic ! 0nteger used to represent a real number + Co$sta$t $,mber o i$te'erAs bits re%rese$ts ra0tio$al %ortio$ o real $,mber ! Fore bits5 more a00,rate the re%rese$tatio$ + Remai$i$' bits re%rese$t %ortio$ o real $,mber be ore de0imal %oi$t
Krithi Ramamritham / Kavi Arya IIT Bombay

Fixed8point arit"metic1
Translating a real constant to a fixed"point representation
+ F,lti%ly real val,e by 2 V 3W o bits ,sed or ra0tio$al %art4 + Ro,$d to $earest i$te'er + E/'/5 re%rese$t (/1) as :6bit i$te'er with ) bits or ra0tio$ ! 2V) L 11 ! (/1) E 11 L *</2) X *< L <<11<<1< ! 11 32V)4 %ossible val,es or ra0tio$5 ea0h re%rese$ts </<12* 31/114 ! Qast ) bits 3<<1<4 L 2 ! 2 E </<12* L </12* ! (3<<114 P </12* L (/12* X (/1) 3more bits or ra0tio$ wo,ld i$0rease a00,ra0y4

Krithi Ramamritham / Kavi Arya

IIT Bombay

Fixed8point arit"metic operations


! Addition
+ Sim%ly add i$te'er re%rese$tatio$s + E/'/5 (/1) P 2/91 L */:*

! (/1) Y *< L <<11<<1< ! 2/91 Y )( L <<1<1<11 ! *< P )( L ;( L <1<111<1 ! *3<1<14 P 1(311<14 E </<12* L */:12* X */:* ,ultiply
+ F,lti%ly i$te'er re%rese$tatio$s + Shi t res,lt ri'ht by W o bits i$ ra0tio$al %art + E/'/5 (/1) K 2/91 L :/*<;)

! *< K )( L 21*< L 1<<<<11<<11< ! RR ) L 1<<<<11< ! :31<<<4 P 13<11<4 E </<12* L :/(9* X :/*<;) ange of real values used limited by bit widths of possible resulting values
IIT Bombay

Krithi Ramamritham / Kavi Arya

Fixed8point implementation of C=DEC


! -;%VTAMAE gives ="bit fixed" point representation of cosine values : bits used for fractional portion esult of multiplications shifted right by :
lon& s+A,/ ) 4 :( unsi&ned ch ) ./ K( fo)(.4:( .<A( .++) 3 s+., 4 :( fo)(K4:( K<A( K++) s+., +4 (i%&+.,+K, $ COS_DEFL#+K,+0, ) >> 6( 9 fo)(.4:( .<A( .++) ) +4 (s+., $ COS_DEFL#+.,+u,) >> 6( )etu)n (sho)t)(((() $ (((86$C(u)) >> 6) $C(0)) >> 6)) >> 6) >> 6)( 9 9 0oid CodecBo!dct(0oid) 3 unsi&ned sho)t ./ C( fo)(.4:( .<A( .++) fo)(C4:( C<A( C++) outFuffe)+.,+C, 4 !(./ C/ inFuffe))( id. 4 :( 9 9( st tic const ch ) O2#_OT#R_SURD_DWO 4 I( st tic sho)t .d t inFuffe)+A,+A,/ outFuffe)+A,+A,/ id.( st tic const ch ) code COS_DEFL#+A,+A, 4 3 3 3 3 3 3 3 3 3 64/ 64/ 64/ 64/ 64/ 64/ 64/ 64/ 62/ IG/ GI/ 82/ 782/ 7GI/ 7IG/ 762/ IJ/ 24/ 724/ 7IJ/ 7IJ/ 724/ 24/ IJ/ IG/ 782/ 762/ 7GI/ GI/ 62/ 82/ 7IG/ 4I/ 74I/ 74I/ 4I/ 4I/ 74I/ 74I/ 4I/ GI/ 762/ 82/ IG/ 7IG/ 782/ 62/ 7GI/ 24/ 7IJ/ IJ/ 724/ 724/ IJ/ 7IJ/ 24/ 82 9/ 7GI 9/ IG 9/ 762 9/ 62 9/ 7IG 9/ GI 9/ 782 9

! !

st tic unsi&ned ch ) C(int h) 3 )etu)n h P 64 Q O2#_OT#R_SURD_DWO(9 st tic int !(int u/ int 0/ sho)t i%&+A,+A,) 3

0oid Codec"niti li1e(0oid) 3 id. 4 :( 9 0oid Codec=ush=i.el(sho)t 5) 3 if( id. 44 64 ) id. 4 :( inFuffe)+id. > A,+id. ; A, 4 5 << 6( id.++(

Krithi Ramamritham / Kavi Arya

IIT Bombay

*mplementation ?: Microcontroller and CCD33#Fixed83oint DC$


! Analysis of implementation @
+ Ise same a$alysis te0h$i>,es as im%leme$tatio$ 2 + Total eEe0,tio$ time or %ro0essi$' o$e ima'e8 ! 1/* se0o$ds + -ower 0o$s,m%tio$8 ! </<(( watt 3same as 24 + E$er'y 0o$s,m%tio$8 ! </<*< To,le 31/* s E </<(( watt4 ! Battery li e 1E lo$'erZZ + Total 0hi% area8 ! ;<5<<< 'ates ! :5<<< less 'ates 3less memory $eeded or 0ode4
Krithi Ramamritham / Kavi Arya IIT Bombay

*mplementation @: Microcontroller and CCD33#DC$


PR>M 10-+ RAM

S,&

C>D C

=AR)

CCDPP

! 'erformance close but not good enough ! ,ust resort to implementing -;2E- in hardware
+ Si$'le6%,r%ose %ro0essor to %er orm &CT o$ : E : blo0k
Krithi Ramamritham / Kavi Arya IIT Bombay

2ewritten &,)%& so"tware


st tic unsi&ned ch ) .d t C_SDED_R#S _ t_ 6II2H( st tic unsi&ned ch ) .d t C_CL2B_R#S _ t_ 6II2A( st tic unsi&ned ch ) .d t C_BEDE"_R#S _ t_ 6II2J( st tic unsi&ned ch ) .d t C_BEDEO_R#S _ t_ 6IIG:( 0oid Codec"niti li1e(0oid) 39 0oid Codec=ush=i.el(sho)t 5) 3 C_BEDEO_R#S 4 (ch ))5( 9 sho)t Codec=o5=i.el(0oid) 3 )etu)n ((C_BEDE"_R#S << A) V C_BEDE"_R#S)( 9 0oid CodecBo!dct(0oid) 3 C_CL2B_R#S 4 8( -hile( C_SDED_R#S 44 8 ) 3 >$ *usC - it $> 9 9

C=DEC design

! > memory mapped registers + C_DATA"_RE /C_DATA#_RE ,sed to %,sh/%o% : E : blo0k i$to a$d o,t o C2&EC + C_C$%D_RE ,sed to 0omma$d C2&EC ! Writi$' 1 to this re'ister i$vokes C2&EC + C_!TAT_RE i$di0ates C2&EC do$e a$d ready or $eEt blo0k ! -olled i$ so tware ! 2irect translation of - code to BC2A for actual hardware implementation + "iEed6%oi$t versio$ ,sed ! -;2E- module in software changed similar to $A TH--2'' in implementation 8
Krithi Ramamritham / Kavi Arya IIT Bombay

! Analysis of implementation >

*mplementation @: Microcontroller and CCD33#DC$

+ Total eEe0,tio$ time or %ro0essi$' o$e ima'e8 ! </<;; se0o$ds 3well ,$der 1 se04 + -ower 0o$s,m%tio$8 ! </<)< watt ! I$0rease over 2 a$d ( be0a,se S2C has a$other %ro0essor + E$er'y 0o$s,m%tio$8 ! </<<<)< To,le 3</<;; s E </<)< watt4 ! Battery li e 12E lo$'er tha$ %revio,s im%leme$tatio$ZZ + Total 0hi% area8 ! 12:5<<< 'ates5 si'$i i0a$t i$0rease over %revio,s im%leme$tatio$s
Krithi Ramamritham / Kavi Arya IIT Bombay

Summary of implementations
0mplementation 8 0mplementation @ 0mplementation > ! 0mplementation @ ;/1 1/* </<;; + Close i$ %er orma$0e -er orma$0e 3se0o$d4 -ower 3watt4 </<(( </<(( </<)< + Chea%er Si.e 3'ate4 ;:5<<< ;<5<<< 12:5<<< + Qess time to b,ild E$er'y 3To,le4 </(< </<*< </<<)< ! 0mplementation > + Great %er orma$0e a$d e$er'y 0o$s,m%tio$ + Fore eE%e$sive a$d may miss time6to6market wi$dow ! I &CT desi'$ed o,rselves the$ i$0reased =RE 0ost a$d time6to6market ! I eEisti$' &CT %,r0hased the$ i$0reased IC 0ost ! Qhich is betterW
Krithi Ramamritham / Kavi Arya IIT Bombay

Digital Camera 88 Summary


! 2igital camera example
+ S%e0i i0atio$s i$ E$'lish a$d eEe0,table la$',a'e + &esi'$ metri0s8 %er orma$0e5 %ower a$d area

! %everal implementations
+ + + + Fi0ro0o$troller8 too slow Fi0ro0o$troller a$d 0o%ro0essor8 better5 b,t still too slow "iEed6%oi$t arithmeti08 almost ast e$o,'h Additio$al 0o%ro0essor or 0om%ressio$8 ast e$o,'h5 b,t eE%e$sive a$d hard to desi'$ + Tradeo s betwee$ hw/sw + the mai$ lesso$ o this 0o,rseZ

Krithi Ramamritham / Kavi Arya

IIT Bombay

Examples of Embedded Systems


We looked at details o ! A sim%le &i'ital Camera We will st,dy mi0ro0o$troller %ro'/ with ! "irebird # Robot
3to be st,died i$ mi0ro0o$troller worksho%4

The world 'ets eE0iti$'D ! A%%le i-ad5 i$telli'e$t tra$s%ortatio$ systems5 servi0e robots5 D
Krithi Ramamritham / Kavi Arya IIT Bombay