8/9/2019 Digital Camra Design
1/47
Embedded Systems Design: A Unified
Hardware/Software Introduction
1
Chapter Digita! Camera E"amp!e
8/9/2019 Digital Camra Design
2/47
Embedded Systems Design: A UnifiedHardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %
*ut!ine
Introduction to a simp!e digita! camera
Designer+s perspecti)e
,e-uirements specification
Design .our imp!ementations
8/9/2019 Digital Camra Design
3/47
Embedded Systems Design: A UnifiedHardware/Software Introduction,#c$ %&&& 'ahid/(i)argis
0utting it a!! together (enera!purpose processor
Sing!epurpose processor Custom
Standard
2emory
Interfacing
3now!edge app!ied to designing a simp!e digita!
camera (enera!purpose )s4 sing!epurpose processors
0artitioning of functiona!ity among different processor types
Introduction
8/9/2019 Digital Camra Design
4/47
Embedded Systems Design: A UnifiedHardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 5
Introduction to a simp!e digita! camera
Captures images
Stores images in digita! format 6o fi!m
2u!tip!e images stored in camera
6umber depends on amount of memory and bits used per image Down!oads images to 0C
*n!y recent!y possib!e Systemsonachip
2u!tip!e processors and memories on one IC
Highcapacity f!ash memory 'ery simp!e description used for e"amp!e
2any more features with rea! digita! camera 'ariab!e si7e images8 image de!etion8 digita! stretching8 7ooming in and out8 etc4
8/9/2019 Digital Camra Design
5/47
Embedded Systems Design: A UnifiedHardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 9
Designer+s perspecti)e
wo ;ey tas;s 0rocessing images and storing in memory
8/9/2019 Digital Camra Design
6/47
Embedded Systems Design: A UnifiedHardware/Software Introduction,#c$ %&&& 'ahid/(i)argis =
Chargecoup!ed de)ice #CCD$
Specia! sensor that captures an image
>ightsensiti)e si!icon so!idstate de)ice composed of many ce!!s
ens area
0i"e! co!umns
Co)ered co!umns
E!ectronic
circuitry
E!ectro
mechanica!
shutter
0i"e!rows
8/9/2019 Digital Camra Design
7/47
8/9/2019 Digital Camra Design
8/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis ?
Compression
Store more images
ransmit image to 0C in !ess time
0E( #oint 0hotographic E"perts (roup$ 0opu!ar standard format for representing digita! images in a compressed
form 0ro)ides for a number of different modes of operation
2ode used in this chapter pro)ides high compression ratios using DC#discrete cosine transform$
Image data di)ided into b!oc;s of ? " ? pi"e!s
steps performed on each b!oc; DC
uanti7ation
Huffman encoding
8/9/2019 Digital Camra Design
9/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis
DC step
ransforms origina! ? " ? b!oc; into a cosinefre-uencydomain Upper!eft corner )a!ues represent more of the essence of the image
>owerright corner )a!ues represent finer detai!s
Can reduce precision of these )a!ues and retain reasonab!e image -ua!ity
.DC #.orward DC$ formu!a C#h$ F if #h FF &$ then 1/s-rt#%$ e!se 14&
Au"i!iary function used in main function .#u8)$
.#u8)$ F G " C#u$ " C#)$ "F&44 yF&44 D"y " cos##%u J 1$u/1=$ " cos##%y J 1$)/1=$
(i)es encoded pi"e! at row u8 co!umn ) D"y is origina! pi"e! )a!ue at row "8 co!umn y
IDC #In)erse DC$ ,e)erses process to obtain origina! b!oc; #not needed for this design$
8/9/2019 Digital Camra Design
10/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1&
uanti7ation step
Achie)e high compression ratio by reducing image-ua!ity ,educe bit precision of encoded data
.ewer bits needed for encoding
*ne way is to di)ide a!! )a!ues by a factor of % Simp!e right shifts can do this
De-uanti7ation wou!d re)erse process for decompression
1150 39 -43 -10 26 -83 11 41
-81 -3 115 -73 -6 -2 22 -5
14 -11 1 -42 26 -3 17 -38
2 -61 -13 -12 36 -23 -18 5
44 13 37 -4 10 -21 7 -8
36 -11 -9 -4 20 -28 -21 14
-19 -7 21 -6 3 3 12 -21
-5 -13 -11 -17 -4 -1 7 -4
144 5 -5 -1 3 -10 1 5
-10 0 14 -9 -1 0 3 -1
2 -1 0 -5 3 0 2 -5
0 -8 -2 -2 5 -3 -2 1
6 2 5 -1 1 -3 1 -1
5 -1 -1 -1 3 -4 -3 2
-2 -1 3 -1 0 0 2 -3
-1 -2 -1 -2 -1 0 1 -1
After being decoded using DC After -uanti7ation
Di)ide each ce!!+s
)a!ue by ?
8/9/2019 Digital Camra Design
11/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 11
Seria!i7e ? " ? b!oc; of pi"e!s 'a!ues are con)erted into sing!e !ist using 7ig7ag pattern
0erform Huffman encoding 2ore fre-uent!y occurring pi"e!s assigned short binary code
>onger binary codes !eft for !ess fre-uent!y occurring pi"e!s Each pi"e! in seria! !ist con)erted to Huffman encoded )a!ues
2uch shorter !ist8 thus compression
Huffman encoding step
8/9/2019 Digital Camra Design
12/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1%
Huffman encoding e"amp!e
0i"e! fre-uencies on !eft 0i"e! )a!ue K1 occurs 19 times
0i"e! )a!ue 15 occurs 1 time
Bui!d Huffman tree from bottom up Create one !eaf node for each pi"e!
)a!ue and assign fre-uency as node+s)a!ue
Create an interna! node by @oining anytwo nodes whose sum is a minima!)a!ue
his sum is interna! nodes )a!ue
,epeat unti! comp!ete binary tree
ra)erse tree from root to !eaf toobtain binary code for !eaf+s pi"e!
)a!ue Append & for !eft tra)ersa!8 1 for right
tra)ersa!
Huffman encoding is re)ersib!e 6o code is a prefi" of another code
155
9 %
1 & %
1
1& 9
5 ? =151 1
%
1 1
%
1
%%
5
9
5
=9
9
1
&
9
1
19
1
5
=
1
?
1
?19
%
9
=
5
1
-1 15x
0 8x
-2 6x1 5x
2 5x
3 5x
5 5x
-3 4x
-5 3x
-10 2x
144 1x
-9 1x
-8 1x
-4 1x
6 1x
14 1x
-1 00
0 100
-2 110
1 010
2 1110
3 1010
5 0110
-3 11110
-5 10110
-10 01110
144 111111
-9 111110
-8 101111
-4 101110
6 011111
14 011110
0i"e!
fre-uenciesHuffman tree
Huffman
codes
8/9/2019 Digital Camra Design
13/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1
Archi)e step
,ecord starting address and image si7e Can use !in;ed !ist
*ne possib!e way to archi)e images If ma" number of images archi)ed is 6:
Set aside memory for 6 addresses and 6 imagesi7e )ariab!es 3eep a counter for !ocation of ne"t a)ai!ab!e address
Initia!i7e addresses and imagesi7e )ariab!es to &
Set g!oba! memory address to 6 " 5 Assuming addresses8 imagesi7e )ariab!es occupy 6 " 5 bytes
.irst image archi)ed starting at address 6 " 5
(!oba! memory address updated to 6 " 5 J #compressed image si7e$
2emory re-uirement based on 68 image si7e8 and a)eragecompression ratio
8/9/2019 Digital Camra Design
14/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 15
Up!oading to 0C
8/9/2019 Digital Camra Design
15/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 19
,e-uirements Specification
System+s re-uirements K what system shou!d do 6onfunctiona! re-uirements
Constraints on design metrics #e4g48 Lshou!d use &4&&1 watt or !essM$
.unctiona! re-uirements
System+s beha)ior #e4g48 Loutput N shou!d be input O times %M$ Initia! specification may be )ery genera! and come from mar;eting dept4
E4g48 short document detai!ing mar;et need for a !owend digita! camera that:
captures and stores at !east 9& !owres images and up!oads to 0C8
costs around P1&& with sing!e mediumsi7e IC costing !ess that P%98
has !ong as possib!e battery !ife8
has e"pected sa!es )o!ume of %&&8&&& if mar;et entry Q = months8
1&&8&&& if between = and 1% months8
insignificant sa!es beyond 1% months
8/9/2019 Digital Camra Design
16/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1=
6onfunctiona! re-uirements
Design metrics of importance based on initia! specification Performance: time re-uired to process image
Size: number of e!ementary !ogic gates #%input 6A6D gate$ in IC
Power: measure of a)g4 e!ectrica! energy consumed whi!e processing
Energy: battery !ifetime #power " time$
Constrained metrics 'a!ues mustbe be!ow #sometimes abo)e$ certain thresho!d
*ptimi7ation metrics
Impro)ed as much as possib!e to impro)e product 2etric can be both constrained and optimi7ation
8/9/2019 Digital Camra Design
17/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1
6onfunctiona! re-uirements #cont4$
0erformance 2ust process image fast enough to be usefu!
1 sec reasonab!e constraint S!ower wou!d be annoying
.aster not necessary for !owend of mar;et
herefore8 constrained metric
Si7e 2ust use IC that fits in reasonab!y si7ed camera
Constrained and optimi7ation metric Constraint may be %&&8&&& gates8 but sma!!er wou!d be cheaper
0ower 2ust operate be!ow certain temperature #coo!ing fan not possib!e$
herefore8 constrained metric
Energy ,educing power or time reduces energy
*ptimi7ed metric: want battery to !ast as !ong as possib!e
8/9/2019 Digital Camra Design
18/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1?
Informa! functiona! specification
.!owchart brea;s functiona!ity
down into simp!er functions
Each function+s detai!s cou!d then
be described in Eng!ish
Done ear!ier in chapter
>ow -ua!ity image has reso!ution
of =5 " =5
2apping functions to a particu!ar
processor type not done at this
stage
seria! output
e4g48 &11&1&444
yes no
CCD
input
erobias ad@ust
DC
uanti7e
Archi)e in
memory
2ore
?R?
b!oc;s
ransmit seria!!y
yes
no Done
8/9/2019 Digital Camra Design
19/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1
,efined functiona! specification
,efine informa! specification intoone that can actua!!y be e"ecuted
Can use C/CJJ code to describeeach function Ca!!ed system!e)e! mode!8
prototype8 or simp!y mode! A!so is first imp!ementation
Can pro)ide insight into operationsof system 0rofi!ing can find computationa!!y
intensi)e functions
Can obtain samp!e output used to)erify correctness of fina!imp!ementation
image fi!e
1&1&11&1&
11&1&1&1&
&1&1&11&14
44
CCD4C
C6,>4C
UA,4C
output fi!e
1&1&1&1&1
&1&1&1&1&
1&1&1&1&1
&444
C*DEC4CCCD004C
E"ecutab!e mode! of digita! camera
8/9/2019 Digital Camra Design
20/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %&
CCD modu!e
Simu!ates rea! CCD
CcdInitializeis passed name of image fi!e
CcdCaturereads LimageM from fi!e
Ccd!o!i"eloutputs pi"e!s one at a time
char CcdPopPixel(void) {
char pixel;
pixel = buffer[rowIndex][colIndex];
if( ++colIndex == SZC!" ) {
colIndex = #; if( ++rowIndex == SZ$!% ) {
colIndex = &';
rowIndex = &';
reurn pixel;
*include ,dio-h.
*define SZ$!% /0
*define SZC!" (/0 + 1)
,aic 2I"3 4i5a6e2ile7andle;
,aic char buffer[SZ$!%][SZC!"];
,aic un,i6ned rowIndex8 colIndex;
void CcdIniiali9e(con, char 4i5a6e2ile:a5e) {
i5a6e2ile7andle = fopen(i5a6e2ile:a5e8 r);
rowIndex = &';
colIndex = &';
void CcdCapure(void) { in pixel;
rewind(i5a6e2ile7andle);
for(rowIndex=#; rowIndexSZ$!%; rowIndex++) {
for(colIndex=#; colIndexSZC!"; colIndex++) {
if( f,canf(i5a6e2ile7andle8
8/9/2019 Digital Camra Design
21/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %1
CCD00 #CCD 0re0rocessing$ modu!e
0erforms 7erobias ad@ustment CcdCatureuses CcdCatureand Ccd!o!i"elto obtain
image
0erforms 7erobias ad@ustment after each row read in
*define SZ$!% /0
*define SZC!" /0
,aic char buffer[SZ$!%][SZC!"];
,aic un,i6ned rowIndex8 colIndex;
void CcdppIniiali9e() {
rowIndex = &';
colIndex = &';
void CcdppCapure(void) {
char bia,;
CcdCapure(); for(rowIndex=#; rowIndexSZ$!%; rowIndex++) {
for(colIndex=#; colIndexSZC!"; colIndex++) {
buffer[rowIndex][colIndex] = CcdPopPixel();
bia, = (CcdPopPixel() + CcdPopPixel()) > 1;
for(colIndex=#; colIndexSZC!"; colIndex++) {
buffer[rowIndex][colIndex] &= bia,;
rowIndex = #;
colIndex = #;
char CcdppPopPixel(void) {
char pixel;
pixel = buffer[rowIndex][colIndex];
if( ++colIndex == SZC!" ) {
colIndex = #;
if( ++rowIndex == SZ$!% ) {
colIndex = &';
rowIndex = &';
reurn pixel;
8/9/2019 Digital Camra Design
22/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %%
UA, modu!e
Actua!!y a ha!f UA, *n!y transmits8 does not recei)e
UartInitializeis passed name of fi!e to output to
UartSendtransmits #writes to output fi!e$ bytes at a time
*include ,dio-h.
,aic 2I"3 4oupu2ile7andle;
void ?arIniiali9e(con, char 4oupu2ile:a5e) {
oupu2ile7andle = fopen(oupu2ile:a5e8 w);
void ?arSend(char d) {
fprinf(oupu2ile7andle8
8/9/2019 Digital Camra Design
23/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %
C*DEC modu!e
2ode!s .DC encoding
ibufferho!ds origina! ? " ? b!oc;
obufferho!ds encoded ? " ? b!oc;
Codec!us#!i"el ca!!ed =5 times to fi!!
ibuffer with origina! b!oc;
CodecDo$dctca!!ed once to
transform ? " ? b!oc;
E"p!ained in ne"t s!ide
Codec!o!i"el ca!!ed =5 times to
retrie)e encoded b!oc; from obuffer
,aic ,hor ibuffer[A][A]8 obuffer[A][A]8 idx;
void CodecIniiali9e(void) { idx = #;
void CodecBo2dc(void) {
in x8 ;
for(x=#; xA; x++) {
for(=#; A; ++)
obuffer[x][] = 2BCD(x8 8 ibuffer);
idx = #;
void CodecPu,hPixel(,hor p) {
if( idx == /0 ) idx = #;
ibuffer[idx > A][idx < A] = p; idx++;
,hor CodecPopPixel(void) {
,hor p;
if( idx == /0 ) idx = #;
p = obuffer[idx > A][idx < A]; idx++;
reurn p;
8/9/2019 Digital Camra Design
24/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %5
C*DEC #cont4$
Imp!ementing .DC formu!a C#h$ F if #h FF &$ then 1/s-rt#%$ e!se 14&
.#u8)$ F G " C#u$ " C#)$ "F&44 yF&44 D"y "
cos##%u J 1$u/1=$ " cos##%y J 1$)/1=$
*n!y =5 possib!e inputs to C%S8 so tab!e canbe used to sa)e performance time
.!oatingpoint )a!ues mu!tip!ied by %8=? androunded to nearest integer
%8=? chosen in order to store each )a!ue in %
bytes of memory
.i"edpoint representation e"p!ained more !ater
$DC& unro!!s inner !oop of summation8imp!ements outer summation as twoconsecuti)e for !oops
,aic con, ,hor C!SDEF"3[A][A] = {
{ G1H/A8 G1'GA8 G#1HG8 1H108 1G'H#8 'A1#08 '1GJ8 /GJ1 8
{ G1H/A8 1H108 '1GJ8 &/GJ18 &1G'H#8 &G1'GA8 &G#1HG8 &'A1#0 8
{ G1H/A8 'A1#08 &'1GJ8 &G1'GA8 &1G'H#8 /GJ18 G#1HG8 1H10 8
{ G1H/A8 /GJ18 &G#1HG8 &'A1#08 1G'H#8 1H108 &'1GJ8 &G1'GA 8
{ G1H/A8 &/GJ18 &G#1HG8 'A1#08 1G'H#8 &1H108 &'1GJ8 G1'GA 8
{ G1H/A8 &'A1#08 &'1GJ8 G1'GA8 &1G'H#8 &/GJ18 G#1HG8 &1H10 8
{ G1H/A8 &1H108 '1GJ8 /GJ18 &1G'H#8 G1'GA8 &G#1HG8 'A1#0 8
{ G1H/A8 &G1'GA8 G#1HG8 &1H108 1G'H#8 &'A1#08 '1GJ8 &/GJ1
;
,aic in 2BCD(in u8 in v8 ,hor i56[A][A]) {
double ,[A]8 r = #; in x;
for(x=#; xA; x++) {
,[x] = i56[x][#] 4 C!S(#8 v) + i56[x]['] 4 C!S('8 v) +
i56[x][1] 4 C!S(18 v) + i56[x][G] 4 C!S(G8 v) +
i56[x][0] 4 C!S(08 v) + i56[x][] 4 C!S(8 v) +
i56[x][/] 4 C!S(/8 v) + i56[x][H] 4 C!S(H8 v);
for(x=#; xA; x++) r += ,[x] 4 C!S(x8 u);
reurn (,hor)(r 4 -1 4 C(u) 4 C(v));
,aic ,hor !:3!K3$SL$DD%! = 1G'H#;
,aic double C!S(in x8 in uv) {
reurn C!SDEF"3[x][uv] > G1H/A-#;
,aic double C(in h) {
reurn h M '-# N !:3!K3$SL$DD%! > G1H/A-#;
8/9/2019 Digital Camra Design
25/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %9
C6,> #contro!!er$ modu!e
Heart of the system CntrlInitializefor consistency with other modu!es on!y
CntrlCatureImageuses CCD00 modu!eto input
image and p!ace in buffer
CntrlComressImagebrea;s the =5 " =5 buffer into ? "
? b!oc;s and performs .DC on each b!oc; using the
C*DEC modu!e
A!so performs -uanti7ation on each b!oc;
CntrlSendImagetransmits encoded image seria!!y usingUA, modu!e
void CnrlSendI5a6e(void) { for(i=#; iSZ$!%; i++)
for(O=#; OSZC!"; O++) {
e5p = buffer[i][O]; ?arSend(((char4)e5p)[#]); >4 ,end upper be 4>
?arSend(((char4)e5p)[']); >4 ,end lower be 4>
*define SZ$!% /0
*define SZC!" /0
*define :?$!%F"!CQS (SZ$!% > A)
*define :?C!"F"!CQS (SZC!" > A)
,aic ,hor buffer[SZ$!%][SZC!"]8 i8 O8 R8 l8 e5p;
void CnrlIniiali9e(void) {
void CnrlCapureI5a6e(void) {
CcdppCapure();
for(i=#; iSZ$!%; i++)
for(O=#; OSZC!"; O++)
buffer[i][O] = CcdppPopPixel();
void CnrlCo5pre,,I5a6e(void) {
for(i=#; i:?$!%F"!CQS; i++) for(O=#; O:?C!"F"!CQS; O++) {
for(R=#; RA; R++)
for(l=#; lA; l++)
CodecPu,hPixel(
(char)buffer[i 4 A + R][O 4 A + l]);
CodecBo2dc();>4 par ' & 2BCD 4>
for(R=#; RA; R++)
for(l=#; lA; l++) {
buffer[i 4 A + R][O 4 A + l] = CodecPopPixel();
>4 par 1 & uani9aion 4>
buffer[i4A+R][O4A+l] ..= /;
8/9/2019 Digital Camra Design
26/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %=
0utting it a!! together
'ain initia!i7es a!! modu!es8 then uses C6,> modu!e to capture8
compress8 and transmit one image
his system!e)e! mode! can be used for e"tensi)e e"perimentation
Bugs much easier to correct here rather than in !ater mode!s
in 5ain(in ar6c8 char 4ar6v[]) {
char 4uar!upu2ile:a5e = ar6c . ' M ar6v['] N uarou-x; char 4i5a6e2ile:a5e = ar6c . 1 M ar6v[1] N i5a6e-x;
>4 iniiali9e he 5odule, 4>
?arIniiali9e(uar!upu2ile:a5e); CcdIniiali9e(i5a6e2ile:a5e);
CcdppIniiali9e();
CodecIniiali9e();
CnrlIniiali9e(); >4 ,i5ulae funcionali 4>
CnrlCapureI5a6e(); CnrlCo5pre,,I5a6e();
CnrlSendI5a6e();
8/9/2019 Digital Camra Design
27/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %
Design
Determine system+s architecture 0rocessors
Any combination of sing!epurpose #custom or standard$ or genera!purpose processors
2emories8 buses
2ap functiona!ity to that architecture 2u!tip!e functions on one processor
*ne function on one or more processors Imp!ementation
A particu!ar architecture and mapping
So!ution space is set of a!! imp!ementations
Starting point >owend genera!purpose processor connected to f!ash memory
A!! functiona!ity mapped to software running on processor Usua!!y satisfies power8 si7e8 and timetomar;et constraints
If timing constraint not satisfied then !ater imp!ementations cou!d:
use sing!epurpose processors for timecritica! functions
rewrite functiona! specification
8/9/2019 Digital Camra Design
28/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %?
Imp!ementation 1: 2icrocontro!!er a!one
>owend processor cou!d be Inte! ?&91 microcontro!!er ota! IC cost inc!uding 6,E about P9
8/9/2019 Digital Camra Design
29/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis %
Imp!ementation %:
2icrocontro!!er and CCD00
CCD00 function imp!emented on custom sing!epurpose processor
Impro)es performance K !ess microcontro!!er cyc!es
Increases 6,E cost and timetomar;et
Easy to imp!ement
Simp!e datapath
.ew states in contro!!er
Simp!e UA, easy to imp!ement as sing!epurpose processor a!so
EE0,*2 for program memory and ,A2 for data memory added as we!!
?&91
UA, CCD00
,A2EE0,*2
SOC
8/9/2019 Digital Camra Design
30/47
8/9/2019 Digital Camra Design
31/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 1
UA,
UA, in id!e mode unti! in)o;ed UA, in)o;ed when ?&91 e"ecutes store instruction
with UA,+s enab!e register as target address
2emorymapped communication between ?&91 and
a!! sing!epurpose processors
>ower ?bits of memory address for ,A2 Upper ?bits of memory address for memorymapped
I/* de)ices
Start state transmits & indicating start of byte
transmission then transitions to Data state
Data state sends ? bits seria!!y then transitions to
Stop state
Stop state transmits 1 indicating transmission done
then transitions bac; to id!e mode
in)o;ed
I F ?
I Q ?
Idle
:I F &
Start:ransmi
t >* descriptions and
functiona!!y simu!ates e"ecution of system ,eca!! program code trans!ated to 'HD>
description of ,*2
ests for correct functiona!ity
2easures c!oc; cyc!es to process oneimage #performance$
(ate!e)e! description obtained through
synthesis
Synthesis too! !i;e compi!er for S00s
Simu!ate gate!e)e! mode!s to obtain data
for power ana!ysis 6umber of times gates switch from 1 to &
or & to 1
Count number of gates for chip area
0ower
'HD>
simu!ator
'HD> 'HD> 'HD>
E"ecution time
Synthesis
too!
gates gates gates
Sum gates
(ate !e)e!
simu!ator
0ower
e-uation
Chip area
Obtaining design metrics of interest
8/9/2019 Digital Camra Design
36/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis =
Imp!ementation %:
2icrocontro!!er and CCD00
Ana!ysis of imp!ementation % ota! e"ecution time for processing one image:
41 seconds
0ower consumption: &4& watt
Energy consumption: &4& @ou!e #41 s " &4& watt$
ota! chip area: ?8&&& gates
8/9/2019 Digital Camra Design
37/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis
Imp!ementation : 2icrocontro!!er and
CCD00/.i"ed0oint DC
41 seconds sti!! doesn+t meet performance constraint
of 1 second
DC operation prime candidate for impro)ement
E"ecution of imp!ementation % shows microprocessorspends most cyc!es here
Cou!d design custom hardware !i;e we did for CCD00 2ore comp!e" so more design effort
Instead8 wi!! speed up DC functiona!ity by modifyingbeha)ior
8/9/2019 Digital Camra Design
38/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis ?
DC f!oatingpoint cost
.!oatingpoint cost DC uses T%=& f!oatingpoint operations per pi"e! transformation
5&= #=5 " =5$ pi"e!s per image
1 mi!!ion f!oatingpoint operations per image
6o f!oatingpoint support with Inte! ?&91 Compi!er must emu!ate
(enerates procedures for each f!oatingpoint operation
mu!t8 add
Each procedure uses tens of integer operations
hus8 W 1& mi!!ion integer operations per image
0rocedures increase code si7e
.i"edpoint arithmetic can impro)e on this
8/9/2019 Digital Camra Design
39/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis
.i"edpoint arithmetic
Integer used to represent a rea! number Constant number of integer+s bits represents fractiona! portion of rea! number
2ore bits8 more accurate the representation
,emaining bits represent portion of rea! number before decima! point
rans!ating a rea! constant to a fi"edpoint representation
2u!tip!y rea! )a!ue by % X #Y of bits used for fractiona! part$
,ound to nearest integer
E4g48 represent 415 as ?bit integer with 5 bits for fraction
%X5 F 1=
415 " 1= F 9&4%5 Z 9& F &&11&&1&
1= #%X5$ possib!e )a!ues for fraction8 each represents &4&=%9 #1/1=$ >ast 5 bits #&&1&$ F %
% " &4&=%9 F &41%9
#&&11$ J &41%9 F 41%9 Z 415 #more bits for fraction wou!d increase accuracy$
8/9/2019 Digital Camra Design
40/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 5&
.i"edpoint arithmetic operations
Addition Simp!y add integer representations
E4g48 415 J %41 F 94?9
415 [ 9& F &&11&&1&
%41 [ 5 F &&1&1&11
9& J 5 F F &1&111&1
9#&1&1$ J 1#11&1$ " &4&=%9 F 94?1%9 Z 94?9
2u!tip!y 2u!tip!y integer representations
Shift resu!t right by Y of bits in fractiona! part
E4g48 415 \ %41 F ?49&5
9& \ 5 F %19& F 1&&&&11&&11&
WW 5 F 1&&&&11&
?#1&&&$ J =#&11&$ " &4&=%9 F ?49 Z ?49&5
,ange of rea! )a!ues used !imited by bit widths of possib!e resu!ting )a!ues
8/9/2019 Digital Camra Design
41/47
I ! i 2i !! d
8/9/2019 Digital Camra Design
42/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 5%
Imp!ementation : 2icrocontro!!er and
CCD00/.i"ed0oint DC
Ana!ysis of imp!ementation Use same ana!ysis techni-ues as imp!ementation %
ota! e"ecution time for processing one image: 149 seconds
0ower consumption: &4& watt #same as %$
Energy consumption: &4&9& @ou!e #149 s " &4& watt$
Battery !ife =" !onger^^
ota! chip area: &8&&& gates
?8&&& !ess gates #!ess memory needed for code$
I ! i 5
8/9/2019 Digital Camra Design
43/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 5
Imp!ementation 5:
2icrocontro!!er and CCD00/DC
0erformance c!ose but not good enough
2ust resort to imp!ementing C*DEC in hardware
Sing!epurpose processor to perform DC on ? " ? b!oc;
?&91
UA, CCD0
0
,A2EE0,*2
SOCC*DEC
8/9/2019 Digital Camra Design
44/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 55
C*DEC design
5 memory mapped registers C*DA&AI*)E/C*DA&A%*)Eused to
push/pop ? " ? b!oc; into and out ofC*DEC
C*C'-D*)Eused to commandC*DEC
4 bu, wai 4>
"ewritten CODEC software
I ! t ti 5
8/9/2019 Digital Camra Design
45/47
Embedded Systems Design: A Unified
Hardware/Software Introduction,#c$ %&&& 'ahid/(i)argis 59
Imp!ementation 5:
2icrocontro!!er and CCD00/DC
Ana!ysis of imp!ementation 5 ota! e"ecution time for processing one image:
&4& seconds #we!! under 1 sec$
0ower consumption:
&4&5& watt Increase o)er % and because S*C has another processor
Energy consumption: &4&&&5& @ou!e #&4& s " &4&5& watt$
Battery !ife 1%" !onger than pre)ious imp!ementation^^
ota! chip area: 1%?8&&& gates
Significant increase o)er pre)ious imp!ementations
8/9/2019 Digital Camra Design
46/47
8/9/2019 Digital Camra Design
47/47
Top Related