Skip to content

Case Study Digital Camera Embedded System

Presentation on theme: "1 6-Performance Analysis of Embedded System Designs: Digital Camera Case Study."— Presentation transcript:

1 1 6-Performance Analysis of Embedded System Designs: Digital Camera Case Study

2 2 Outline Introduction to a simple digital camera Designer’s perspective Requirements specification Design  Four implementations

3 3 Putting it all together  General-purpose processor  Single-purpose processor Custom Standard  Memory  Interfacing Knowledge applied to designing a simple digital camera  General-purpose vs. single-purpose processors  Partitioning of functionality among different processor types Introduction

4 4 Introduction to a simple digital camera Captures images Stores images in digital format  No film  Multiple images stored in camera Number depends on amount of memory and bits used per image Downloads images to PC Only recently possible  Systems-on-a-chip Multiple processors and memories on one IC  High-capacity flash memory Very simple description used for example  Many more features with real digital camera Variable size images, image deletion, digital stretching, zooming in and out, etc.

5 5 Designer’s perspective Two key tasks  Processing images and storing in memory When shutter pressed: Image captured Converted to digital form by charge-coupled device (CCD) Compressed and archived in internal memory  Uploading images to PC Digital camera attached to PC Special software commands camera to transmit archived images serially

6 6 Charge-coupled device (CCD) Special sensor that captures an image Light-sensitive silicon solid-state device composed of many cells

7 7 Zero-bias error Manufacturing errors cause cells to measure slightly above or below actual light intensity Error typically same across columns, but different across rows Some of left most columns blocked by black paint to detect zero-bias error  Reading of other than 0 in blocked cells is zero-bias error  Each row is corrected by subtracting the average error found in blocked cells for that row Covered cells Before zero-bias adjustment After zero-bias adjustment Zero-bias adjustment

8 8 Compression Store more images Transmit image to PC in less time JPEG (Joint Photographic Experts Group)  Popular standard format for representing digital images in a compressed form  Provides for a number of different modes of operation  Mode used in this chapter provides high compression ratios using DCT (discrete cosine transform)  Image data divided into blocks of 8 x 8 pixels  3 steps performed on each block DCT Quantization Huffman encoding

9 9 DCT step

10 10 Quantization step Achieve high compression ratio by reducing image quality  Reduce bit precision of encoded data Fewer bits needed for encoding One way is to divide all values by a factor of 2 Simple right shifts can do this  Dequantization would reverse process for decompression After being decoded using DCTAfter quantization Divide each cell’s value by 8

11 11 Serialize 8 x 8 block of pixels  Values are converted into single list using zigzag pattern Perform Huffman encoding  More frequently occurring pixels assigned short binary code  Longer binary codes left for less frequently occurring pixels Each pixel in serial list converted to Huffman encoded values  Much shorter list, thus compression Huffman encoding step

12 12 Huffman encoding example Pixel frequencies on left  Pixel value –1 occurs 15 times  Pixel value 14 occurs 1 time Build Huffman tree from bottom up  Create one leaf node for each pixel value and assign frequency as node’s value. Add node to priority queue.  While there is more than one node in the queue: Remove two nodes of highest priority from queue Create an internal node by joining these two nodes as children and with a parent node value equal to the sum of their frequencies Add the new parent node to the priority queue  Repeat until the remaining node has a value that equals total number of pixels Traverse tree from root to leaf to obtain binary code for leaf’s pixel value  Append 0 for left traversal, 1 for right traversal Huffman encoding is reversible  No code is a prefix of another code 144 5 3 2 1 0 -2 -10 -5 -3 -4 -8 -9 6 14 1 1 2 1 1 2 1 2 2 4 3 5 4 6 5 9 5 10 5 11 5 14 6 17 8 18 15 29 35 64 1 Pixel frequencies Huffman tree Huffman codes

13 Other example 13010-10 -10010-10 10-5 0-10 13 PF(p) -104 4 03 102 1301 11 -51 PF(p)Code -10400 410 03010 102111 1301110 110111 -510110 -10 0 -1 130 10 1 -5 1 1 2 1 2 3 3 5 4 7 4 9 16 Pixel frequenciesHuffman tree Huffman codes The following illustrates how the encoding works for a 4x4 quantized block.

14 14 Archive step Record starting address and image size  Can use linked list One possible way to archive images  If max number of images archived is N: Set aside memory for N addresses and N image-size variables Keep a counter for location of next available address Initialize addresses and image-size variables to 0 Set global memory address to N x 4 Assuming addresses, image-size variables occupy N x 4 bytes First image archived starting at address N x 4 Global memory address updated to N x 4 + (compressed image size) Memory requirement based on N, image size, and average compression ratio

15 15 Uploading to PC When connected to PC and upload command received  Read images from memory  Transmit serially using UART  While transmitting Reset pointers, image-size variables and global memory pointer accordingly

16 16 Requirements Specification System’s requirements – what system should do  Nonfunctional requirements Constraints on design metrics (e.g., “should use 0.001 watt or less”)  Functional requirements System’s behavior (e.g., “output X should be input Y times 2”)  Initial specification may be very general and come from marketing dept. E.g., short document detailing market need for a low-end digital camera that: captures and stores at least 50 low-res images and uploads to PC, costs around $100 with single medium-size IC costing less that $25, has long as possible battery life, has expected sales volume of 200,000 if market entry < 6 months, 100,000 if between 6 and 12 months, insignificant sales beyond 12 months

17 17 Nonfunctional requirements Design metrics of importance based on initial specification  Performance: time required to process image  Size: number of elementary logic gates (2-input NAND gate) in IC  Power: measure of avg. electrical energy consumed while processing  Energy: battery lifetime (power x time) Constrained metrics  Values must be below (sometimes above) certain threshold Optimization metrics  Improved as much as possible to improve product Metric can be both constrained and optimization

18 18 Nonfunctional requirements (cont.) Performance  Must process image fast enough to be useful  1 sec reasonable constraint Slower would be annoying Faster not necessary for low-end of market  Therefore, constrained metric Size  Must use IC that fits in reasonably sized camera  Constrained and optimization metric Constraint may be 200,000 gates, but smaller would be cheaper Power  Must operate below certain temperature (cooling fan not possible)  Therefore, constrained metric Energy  Reducing power or time reduces energy  Optimized metric: want battery to last as long as possible

19 19 Informal functional specification Flowchart breaks functionality down into simpler functions Each function’s details could then be described in English  Done earlier in chapter Low quality image has resolution of 64 x 64 Mapping functions to a particular processor type not done at this stage serial output e.g., 011010... yes no CCD input Zero-bias adjust DCT Quantize Archive in memory More 8×8 blocks? Transmit serially yes no Done?

20 20 Refined functional specification Refine informal specification into one that can actually be executed Can use C/C++ code to describe each function  Called system-level model, prototype, or simply model  Also is first implementation Can provide insight into operations of system  Profiling can find computationally intensive functions Can obtain sample output used to verify correctness of final implementation image file 101011010 110101010 010101101... CCD.C CNTRL.C UART.C output file 101010101 010101010 101010101 0... CODEC.C CCDPP.C Executable model of digital camera

- Стратмор приподнял брови.  - В них постоянно упоминается Цифровая крепость и его планы шантажа АНБ. Сьюзан отнеслась к словам Стратмора скептически. Ее удивило, что он так легко клюнул на эту приманку. - Коммандер, - возразила она, - Танкадо отлично понимал, что АНБ может найти его переписку в Интернете, он никогда не стал бы доверять секреты электронной почте.