【正文】
curs 1 time ? Build Huffman tree from bottom up – Create one leaf node for each pixel value and assign frequency as node’s value – Create an internal node by joining any two nodes whose sum is a minimal value ? This sum is internal nodes value – Repeat until plete binary tree ? 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 1 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 1 15x 0 8x2 6x1 5x2 5x3 5x5 5x3 4x5 3x10 2x144 1x9 1x8 1x4 1x6 1x14 1x1 000 1002 1101 0102 11103 10105 01103 111105 1011010 01110144 1111119 1111108 1011114 1011106 01111114 011110Pixel frequencies Huffman tree Huffman codes 12 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis 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 imagesize variables ? Keep a counter for location of next available address ? Initialize addresses and imagesize variables to 0 ? Set global memory address to N x 4 – Assuming addresses, imagesize variables occupy N x 4 bytes ? First image archived starting at address N x 4 ? Global memory address updated to N x 4 + (pressed image size) ? Memory requirement based on N, image size, and average pression ratio 13 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis Uploading to PC ? When connected to PC and upload mand received – Read images from memory – Transmit serially using UART – While transmitting ? Reset pointers, imagesize variables and global memory pointer accordingly 14 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis Requirements Specification ? System’s requirements – what system should do – Nonfunctional requirements ? Constraints on design metrics (., “should use watt or less”) – Functional requirements ? System’s behavior (., “output X should be input Y times 2”) – Initial specification may be very general and e from marketing dept. ? ., short document detailing market need for a lowend digital camera that: – captures and stores at least 50 lowres images and uploads to PC, – costs around $100 with single mediumsize 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 15 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis Nonfunctional requirements ? Design metrics of importance based on initial specification – Performance: time required to process image – Size: number of elementary logic gates (2input 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 16 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis Nonfunctional requirements (cont.) ? Performance – Must process image fast enough to be useful – 1 sec reasonable constraint ? Slower would be annoying ? Faster not necessary for lowend 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 17 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis 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 ., 011010... yes no CCD input Zerobias adjust DCT Quantize Archive in memory More 8 8 blocks? Transmit serially yes no Done? 18 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis Refined functional specification ? Refine informal specification into one that can actually be executed ? Can use C/C++ code to describe each function – Called systemlevel model, prototype, or simply model – Also is first implementation ? Can provide insight into operations of system – Profiling can find putationally intensive functions ? Can obtain sample output used to verify correctness of final implementation image file 101011010110101010010101101... output file 1010101010101010101010101010... Executable model of digital camera 19 Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2023 Vahid/Givargis CCD module ? Simulates real CCD ? CcdInitialize is passed name of image file ? CcdCapture reads “image” from file ? CcdPopPixel outputs pixels one at a time char CcdPopPixel(void) { char pixel。 if( ++colIndex == SZ_COL ) {