教你辨别房屋出租骗子方法ppt课件_第1页
教你辨别房屋出租骗子方法ppt课件_第2页
教你辨别房屋出租骗子方法ppt课件_第3页
教你辨别房屋出租骗子方法ppt课件_第4页
教你辨别房屋出租骗子方法ppt课件_第5页
已阅读5页,还剩42页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Chapter 7 Digital Camera Example太原房产网 52youju1.OutlineIntroduction to a simple digital cameraDesigners perspectiveRequirements specificationDesign Four implementations2Putting it all togetherGeneral-purpose processorSingle-purpose processorCustomStandardMemoryInterfacingKnowledge applied to designin

2、g a simple digital cameraGeneral-purpose vs. single-purpose processorsPartitioning of functionality among different processor typesIntroduction3Introduction to a simple digital cameraCaptures imagesStores images in digital formatNo filmMultiple images stored in cameraNumber depends on amount of memo

3、ry and bits used per imageDownloads images to PCOnly recently possibleSystems-on-a-chipMultiple processors and memories on one ICHigh-capacity flash memoryVery simple description used for exampleMany more features with real digital cameraVariable size images, image deletion, digital stretching, zoom

4、ing in and out, etc.4Designers perspectiveTwo key tasksProcessing images and storing in memoryWhen shutter pressed:Image capturedConverted to digital form by charge-coupled device (CCD)Compressed and archived in internal memoryUploading images to PCDigital camera attached to PCSpecial software comma

5、nds camera to transmit archived images serially5Charge-coupled device (CCD)Special sensor that captures an imageLight-sensitive silicon solid-state device composed of many cellsWhen exposed to light, each cell becomes electrically charged. This charge can then be converted to a 8-bit value where 0 r

6、epresents no exposure while 255 represents very intense exposure of that cell to light.Some of the columns are covered with a black strip of paint. The light-intensity of these pixels is used for zero-bias adjustments of all the cells.The electromechanical shutter is activated to expose the cells to

7、 light for a brief moment.The electronic circuitry, when commanded, discharges the cells, activates the electromechanical shutter, and then reads the 8-bit charge value of each cell. These values can be clocked out of the CCD by external logic through a standard parallel bus interface.Lens areaPixel

8、 columnsCovered columnsElectronic circuitryElectro-mechanical shutterPixel rows6Zero-bias errorManufacturing errors cause cells to measure slightly above or below actual light intensityError typically same across columns, but different across rowsSome of left most columns blocked by black paint to d

9、etect zero-bias errorReading of other than 0 in blocked cells is zero-bias errorEach row is corrected by subtracting the average error found in blocked cells for that rowCovered cellsBefore zero-bias adjustmentAfter zero-bias adjustmentZero-bias adjustment7CompressionStore more imagesTransmit image

10、to PC in less timeJPEG (Joint Photographic Experts Group)Popular standard format for representing digital images in a compressed formProvides for a number of different modes of operationMode used in this chapter provides high compression ratios using DCT (discrete cosine transform)Image data divided

11、 into blocks of 8 x 8 pixels3 steps performed on each blockDCTQuantizationHuffman encoding8DCT stepTransforms original 8 x 8 block into a cosine-frequency domainUpper-left corner values represent more of the essence of the imageLower-right corner values represent finer detailsCan reduce precision of

12、 these values and retain reasonable image qualityFDCT (Forward DCT) formulaC(h) = if (h = 0) then 1/sqrt(2) else 1.0Auxiliary function used in main function F(u,v)F(u,v) = x C(u) x C(v) x=0.7 y=0.7 Dxy x cos(2u + 1)u/16) x cos(2y + 1)v/16)Gives encoded pixel at row u, column vDxy is original pixel v

13、alue at row x, column yIDCT (Inverse DCT)Reverses process to obtain original block (not needed for this design)9Quantization stepAchieve high compression ratio by reducing image qualityReduce bit precision of encoded dataFewer bits needed for encodingOne way is to divide all values by a factor of 2S

14、imple right shifts can do thisDequantization would reverse process for decompressionAfter being decoded using DCTAfter quantizationDivide each cells value by 810Serialize 8 x 8 block of pixelsValues are converted into single list using zigzag patternPerform Huffman encodingMore frequently occurring

15、pixels assigned short binary codeLonger binary codes left for less frequently occurring pixelsEach pixel in serial list converted to Huffman encoded valuesMuch shorter list, thus compressionHuffman encoding step11Huffman encoding examplePixel frequencies on leftPixel value 1 occurs 15 timesPixel val

16、ue 14 occurs 1 timeBuild Huffman tree from bottom upCreate one leaf node for each pixel value and assign frequency as nodes valueCreate an internal node by joining any two nodes whose sum is a minimal valueThis sum is internal nodes valueRepeat until complete binary treeTraverse tree from root to le

17、af to obtain binary code for leafs pixel valueAppend 0 for left traversal, 1 for right traversalHuffman encoding is reversibleNo code is a prefix of another code14453210-2-1-10-5-3-4-8-96141121121224354659510511514617818152935641Pixel frequenciesHuffman treeHuffman codes12Archive stepRecord starting

18、 address and image sizeCan use linked listOne possible way to archive imagesIf max number of images archived is N:Set aside memory for N addresses and N image-size variablesKeep a counter for location of next available addressInitialize addresses and image-size variables to 0Set global memory addres

19、s to N x 4Assuming addresses, image-size variables occupy N x 4 bytesFirst image archived starting at address N x 4Global memory address updated to N x 4 + (compressed image size)Memory requirement based on N, image size, and average compression ratio13Uploading to PCWhen connected to PC and upload

20、command receivedRead images from memoryTransmit serially using UARTWhile transmittingReset pointers, image-size variables and global memory pointer accordingly14Requirements SpecificationSystems requirements what system should doNonfunctional requirementsConstraints on design metrics (e.g., “should

21、use 0.001 watt or less)Functional requirementsSystems 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

22、 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 months15Nonfunctional requirementsDesign metrics of i

23、mportance based on initial specificationPerformance: time required to process imageSize: number of elementary logic gates (2-input NAND gate) in ICPower: measure of avg. electrical energy consumed while processingEnergy: battery lifetime (power x time)Constrained metricsValues must be below (sometim

24、es above) certain thresholdOptimization metricsImproved as much as possible to improve productMetric can be both constrained and optimization16Nonfunctional requirements (cont.)PerformanceMust process image fast enough to be useful1 sec reasonable constraintSlower would be annoyingFaster not necessa

25、ry for low-end of marketTherefore, constrained metricSizeMust use IC that fits in reasonably sized cameraConstrained and optimization metricConstraint may be 200,000 gates, but smaller would be cheaperPowerMust operate below certain temperature (cooling fan not possible)Therefore, constrained metric

26、EnergyReducing power or time reduces energyOptimized metric: want battery to last as long as possible17Informal functional specificationFlowchart breaks functionality down into simpler functionsEach functions details could then be described in EnglishDone earlier in chapterLow quality image has reso

27、lution of 64 x 64Mapping functions to a particular processor type not done at this stageserial outpute.g., 011010.yesnoCCDinputZero-bias adjustDCTQuantizeArchive in memoryMore 88 blocks?Transmit seriallyyesnoDone?18Refined functional specificationRefine informal specification into one that can actua

28、lly be executedCan use C/C+ code to describe each functionCalled system-level model, prototype, or simply modelAlso is first implementationCan provide insight into operations of systemProfiling can find computationally intensive functionsCan obtain sample output used to verify correctness of final i

29、mplementationimage file101011010110101010010101101.CCD.CCNTRL.CUART.Coutput file1010101010101010101010101010.CODEC.CCCDPP.CExecutable model of digital camera19CCD moduleSimulates real CCDCcdInitialize is passed name of image fileCcdCapture reads “image from fileCcdPopPixel outputs pixels one at a ti

30、mechar CcdPopPixel(void) char pixel; pixel = bufferrowIndexcolIndex; if( +colIndex = SZ_COL ) colIndex = 0; if( +rowIndex = SZ_ROW ) colIndex = -1; rowIndex = -1; return pixel;#include #define SZ_ROW 64#define SZ_COL (64 + 2)static FILE *imageFileHandle;static char bufferSZ_ROWSZ_COL;static unsigned

31、 rowIndex, colIndex;void CcdInitialize(const char *imageFileName) imageFileHandle = fopen(imageFileName, r); rowIndex = -1; colIndex = -1;void CcdCapture(void) int pixel; rewind(imageFileHandle); for(rowIndex=0; rowIndexSZ_ROW; rowIndex+) for(colIndex=0; colIndexSZ_COL; colIndex+) if( fscanf(imageFi

32、leHandle, %i, &pixel) = 1 ) bufferrowIndexcolIndex = (char)pixel; rowIndex = 0; colIndex = 0;20CCDPP (CCD PreProcessing) modulePerforms zero-bias adjustmentCcdppCapture uses CcdCapture and CcdPopPixel to obtain imagePerforms zero-bias adjustment after each row read in#define SZ_ROW 64#define SZ_COL

33、64static char bufferSZ_ROWSZ_COL;static unsigned rowIndex, colIndex;void CcdppInitialize() rowIndex = -1; colIndex = -1;void CcdppCapture(void) char bias; CcdCapture(); for(rowIndex=0; rowIndexSZ_ROW; rowIndex+) for(colIndex=0; colIndexSZ_COL; colIndex+) bufferrowIndexcolIndex = CcdPopPixel(); bias

34、= (CcdPopPixel() + CcdPopPixel() / 2; for(colIndex=0; colIndexSZ_COL; colIndex+) bufferrowIndexcolIndex -= bias; rowIndex = 0; colIndex = 0;char CcdppPopPixel(void) char pixel; pixel = bufferrowIndexcolIndex; if( +colIndex = SZ_COL ) colIndex = 0; if( +rowIndex = SZ_ROW ) colIndex = -1; rowIndex = -

35、1; return pixel;21UART moduleActually a half UARTOnly transmits, does not receiveUartInitialize is passed name of file to output toUartSend transmits (writes to output file) bytes at a time#include static FILE *outputFileHandle;void UartInitialize(const char *outputFileName) outputFileHandle = fopen

36、(outputFileName, w);void UartSend(char d) fprintf(outputFileHandle, %in, (int)d);22CODEC moduleModels FDCT encodingibuffer holds original 8 x 8 blockobuffer holds encoded 8 x 8 blockCodecPushPixel called 64 times to fill ibuffer with original blockCodecDoFdct called once to transform 8 x 8 blockExpl

37、ained in next slideCodecPopPixel called 64 times to retrieve encoded block from obufferstatic short ibuffer88, obuffer88, idx;void CodecInitialize(void) idx = 0; void CodecDoFdct(void) int x, y; for(x=0; x8; x+) for(y=0; y8; y+) obufferxy = FDCT(x, y, ibuffer); idx = 0;void CodecPushPixel(short p) i

38、f( idx = 64 ) idx = 0; ibufferidx / 8idx % 8 = p; idx+;short CodecPopPixel(void) short p; if( idx = 64 ) idx = 0; p = obufferidx / 8idx % 8; idx+; return p;23CODEC (cont.)Implementing FDCT formula C(h) = if (h = 0) then 1/sqrt(2) else 1.0F(u,v) = x C(u) x C(v) x=0.7 y=0.7 Dxy x cos(2u + 1)u/16) x co

39、s(2y + 1)v/16)Only 64 possible inputs to COS, so table can be used to save performance timeFloating-point values multiplied by 32,678 and rounded to nearest integer32,678 chosen in order to store each value in 2 bytes of memoryFixed-point representation explained more laterFDCT unrolls inner loop of

40、 summation, implements outer summation as two consecutive for loopsstatic const short COS_TABLE88 = 32768, 32, 30273, 27245, 23170, 18204, 12539, 6392 , 32768, 27245, 12539, -6392, -23170, -32, -30273, -18204 , 32768, 18204, -12539, -32, -23170, 6392, 30273, 27245 , 32768, 6392, -30273, -18204, 2317

41、0, 27245, -12539, -32 , 32768, -6392, -30273, 18204, 23170, -27245, -12539, 32 , 32768, -18204, -12539, 32, -23170, -6392, 30273, -27245 , 32768, -27245, 12539, 6392, -23170, 32, -30273, 18204 , 32768, -32, 30273, -27245, 23170, -18204, 12539, -6392 ;static int FDCT(int u, int v, short img88) double

42、 s8, r = 0; int x; for(x=0; x8; x+) sx = imgx0 * COS(0, v) + imgx1 * COS(1, v) + imgx2 * COS(2, v) + imgx3 * COS(3, v) + imgx4 * COS(4, v) + imgx5 * COS(5, v) + imgx6 * COS(6, v) + imgx7 * COS(7, v); for(x=0; x8; x+) r += sx * COS(x, u); return (short)(r * .25 * C(u) * C(v);static short ONE_OVER_SQR

43、T_TWO = 23170;static double COS(int xy, int uv) return COS_TABLExyuv / 32768.0; static double C(int h) return h ? 1.0 : ONE_OVER_SQRT_TWO / 32768.0;24CNTRL (controller) moduleHeart of the systemCntrlInitialize for consistency with other modules onlyCntrlCaptureImage uses CCDPP module to input image

44、and place in buffer CntrlCompressImage breaks the 64 x 64 buffer into 8 x 8 blocks and performs FDCT on each block using the CODEC moduleAlso performs quantization on each blockCntrlSendImage transmits encoded image serially using UART modulevoid CntrlSendImage(void) for(i=0; iSZ_ROW; i+) for(j=0; j

45、SZ_COL; j+) temp = bufferij; UartSend(char*)&temp)0); /* send upper byte */ UartSend(char*)&temp)1); /* send lower byte */ #define SZ_ROW 64#define SZ_COL 64#define NUM_ROW_BLOCKS (SZ_ROW / 8)#define NUM_COL_BLOCKS (SZ_COL / 8)static short bufferSZ_ROWSZ_COL, i, j, k, l, temp;void CntrlInitialize(vo

46、id) void CntrlCaptureImage(void) CcdppCapture(); for(i=0; iSZ_ROW; i+) for(j=0; jSZ_COL; j+) bufferij = CcdppPopPixel();void CntrlCompressImage(void) for(i=0; iNUM_ROW_BLOCKS; i+) for(j=0; jNUM_COL_BLOCKS; j+) for(k=0; k8; k+) for(l=0; l8; l+) CodecPushPixel( (char)bufferi * 8 + kj * 8 + l); CodecDo

47、Fdct();/* part 1 - FDCT */ for(k=0; k8; k+) for(l=0; l= 6; 25Putting it all togetherMain initializes all modules, then uses CNTRL module to capture, compress, and transmit one imageThis system-level model can be used for extensive experimentationBugs much easier to correct here rather than in later

48、modelsint main(int argc, char *argv) char *uartOutputFileName = argc 1 ? argv1 : uart_out.txt; char *imageFileName = argc 2 ? argv2 : image.txt; /* initialize the modules */ UartInitialize(uartOutputFileName); CcdInitialize(imageFileName); CcdppInitialize(); CodecInitialize(); CntrlInitialize(); /*

49、simulate functionality */ CntrlCaptureImage(); CntrlCompressImage(); CntrlSendImage();26DesignDetermine systems architectureProcessorsAny combination of single-purpose (custom or standard) or general-purpose processorsMemories, busesMap functionality to that architectureMultiple functions on one pro

50、cessorOne function on one or more processorsImplementationA particular architecture and mappingSolution space is set of all implementationsStarting pointLow-end general-purpose processor connected to flash memoryAll functionality mapped to software running on processorUsually satisfies power, size,

51、and time-to-market constraintsIf timing constraint not satisfied then later implementations could:use single-purpose processors for time-critical functionsrewrite functional specification27Implementation 1: Microcontroller aloneLow-end processor could be Intel 8051 microcontrollerTotal IC cost inclu

52、ding NRE about $5Well below 200 mW powerTime-to-market about 3 monthsHowever, one image per second not possible12 MHz, 12 cycles per instructionExecutes one million instructions per secondCcdppCapture has nested loops resulting in 4096 (64 x 64) iterations100 assembly instructions each iteration409,

53、000 (4096 x 100) instructions per imageHalf of budget for reading image aloneWould be over budget after adding compute-intensive DCT and Huffman encoding28Implementation 2: Microcontroller and CCDPPCCDPP function implemented on custom single-purpose processorImproves performance less microcontroller

54、 cyclesIncreases NRE cost and time-to-marketEasy to implementSimple datapathFew states in controllerSimple UART easy to implement as single-purpose processor alsoEEPROM for program memory and RAM for data memory added as well8051UARTCCDPPRAMEEPROMSOC29MicrocontrollerSynthesizable version of Intel 80

55、51 availableWritten in VHDL Captured at register transfer level (RTL)Fetches instruction from ROMDecodes using Instruction DecoderALU executes arithmetic operationsSource and destination registers reside in RAMSpecial data movement instructions used to load and store externallySpecial program genera

56、tes VHDL description of ROM from output of C compiler/linkerTo External Memory BusController4K ROM128RAMInstruction DecoderALUBlock diagram of Intel 8051 processor core30UARTUART in idle mode until invokedUART invoked when 8051 executes store instruction with UARTs enable register as target addressM

57、emory-mapped communication between 8051 and all single-purpose processorsLower 8-bits of memory address for RAMUpper 8-bits of memory address for memory-mapped I/O devicesStart state transmits 0 indicating start of byte transmission then transitions to Data stateData state sends 8 bits serially then

58、 transitions to Stop stateStop state transmits 1 indicating transmission done then transitions back to idle modeinvokedI = 8I 8Idle:I = 0Start: Transmit LOWData: Transmit data(I), then I+Stop: Transmit HIGHFSMD description of UART31CCDPPHardware implementation of zero-bias operationsInteracts with e

59、xternal CCD chipCCD chip resides external to our SOC mainly because combining CCD with ordinary logic not feasibleInternal buffer, B, memory-mapped to 8051Variables R, C are buffers row, column indicesGetRow state reads in one row from CCD to B66 bytes: 64 pixels + 2 blacked-out pixelsComputeBias st

60、ate computes bias for that row and stores in variable BiasFixBias state iterates over same row subtracting Bias from each elementNextRow transitions to GetRow for repeat of process on next row or to Idle state when all 64 rows completedC = 64C 64R = 64C = 66invokedR 64C 66Idle:R=0C=0GetRow:BRC=PxlC=

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论