EC6703 EMBEDDED AND REAL TIME SYSTEMS
UNIT V CASE STUDY Data compressor Alarm Clock Audio player Software modem Digital still camera Telephone answering machine Engine control unit Video accelerator.
ALARM CLOCK
Alarm clock interface Alarm on Alarm off buzzer PM Alarm ready light set time set alarm hour minute button
Operations Set time: hold set time, depress hour, minute. Set alarm time: hold set alarm, depress hour, minute. Turn alarm on/off: depress alarm on/off.
Alarm clock requirements
Alarm clock class diagram 1 1 1 1 Lights* Display Mechanism 1 1 1 Buttons* Speaker* 1
Alarm clock physical classes Lights* Buttons* Speaker* digit-val() digit-scan() alarm-on-light() PM-light() set-time(): boolean set-alarm(): boolean alarm-on(): boolean alarm-off(): boolean minute(): boolean hour(): boolean buzz()
Display class Display time[4]: integer alarm-indicator: boolean PM-indicator: boolean set-time() alarm-light-on() alarm-light-off() PM-light-on() PM-light-off()
Mechanism class Mechanism Seconds: integer PM: boolean tens-hours, ones-hours: boolean tens-minutes, ones-minutes: boolean alarm-ready: boolean alarm-tens-hours, alarm-ones-hours: boolean alarm-tens-minutes, alarm-ones-minutes: scan-keyboard() update-time()
Update-time behavior update seconds with rollover display.set-time(current time) F Time >= alarm and alarm-on? Rollover? F T T update hh:mm with rollover alarm.buzzer(true) PM->AM AM->PM PM=true PM=false
Scan-keyboard behavior Set-time and not set-alarm and hours compute button activations Alarm-on Increment time tens w. rollover and AM/PM alarm-ready= true Alarm-off alarm-ready= false alarm.buzzer(false) Increment time ones w. rollover and AM/PM save button states Set-time and not set-alarm and minutes
System architecture Includes: Two major software components: periodic behavior (clock); aperiodic behavior (buttons, buzzer activation). Two major software components: interrupt-driven routine updates time; foreground program deals with buttons, commands.
Interrupt-driven routine Timer probably can’t handle one-minute interrupt interval. Use software variable to convert interrupt frequency to seconds.
Foreground program Operates as while loop: while (TRUE) { read_buttons(button_values); process_command(button_values); check_alarm(); }
Testing Component testing: System testing: test interrupt code on the platform; can test foreground program using a mock-up. System testing: relatively few components to integrate; check clock accuracy; check recognition of buttons, buzzer, etc.
Audio players Audio players may use flash, hard disk, or CD for mass storage. An MP3 player performs three basic functions: audio storage, audio decompression,and user interface. Decompression requires small amount of CPU: 10% of ARM7. File system must be compatible (FAT). Cirrus CS7410
Digital still cameras DSC must determine exposure before taking picture. After taking picture: Improve image quality. Compress. Save as file.
Digital still camera architecture DSC uses CPU for general-purpose processing, DSP for image processing. Internal memory buffers the passes on the image. Display is lower resolution than image sensor. Image must be down sampled.
Image capture Before taking picture: Determine exposure. Determine focus. Optimize white balance. Bayer pattern
Image processing Must perform basic processing to get usable picture: Bayer->RGB interpolation. DSCs perform many functions formerly performed by photoprocessors for film: Image sharpening. Color balance.
File management EXIF standard gives format for digital pictures: Format of data in a file. Directory structure. EXIF file includes: Image (JPEG, etc.) Thumbnail. Metadata (camera type, date/time, etc.)
Accelerators Example: video accelerator
Concept Build accelerator for block motion estimation, one step in video compression. Perform two-dimensional correlation: f2 Frame 1 f2 f2 f2 f2 f2 f2 f2 f2 f2
Block motion estimation MPEG divides frame into 16 x 16 macroblocks for motion estimation. Search for best match within a search range. Measure similarity with sum-of-absolute-differences (SAD): S | M(i,j) - S(i-ox, j-oy) |
Best match Best match produces motion vector for motion block:
Full search algorithm bestx = 0; besty = 0; bestsad = MAXSAD; for (ox = - SEARCHSIZE; ox < SEARCHSIZE; ox++) { for (oy = -SEARCHSIZE; oy < SEARCHSIZE; oy++) { int result = 0; for (i=0; i<MBSIZE; i++) { for (j=0; j<MBSIZE; j++) { result += iabs(mb[i][j] - search[i-ox+XCENTER][j-oy-YCENTER]);
Full search algorithm, cont’d. } if (result <= bestsad) { bestsad = result; bestx = ox; besty = oy; }
Computational requirements Let MBSIZE = 16, SEARCHSIZE = 8. Search area is 8 + 8 + 1 in each dimension. Must perform: nops = (16 x 16) x (17 x 17) = 73984 ops CIF format has 352 x 288 pixels -> 22 x 18 macroblocks.
Accelerator requirements
Accelerator data types, basic classes Motion-vector Macroblock Search-area x, y : pos pixels[] : pixelval pixels[] : pixelval PC Motion-estimator memory[] compute-mv()
Sequence diagram :PC :Motion-estimator compute-mv() Search area memory[] memory[] macroblocks memory[]
Architectural considerations Requires large amount of memory: macroblock has 256 pixels; search area has 1,089 pixels. May need external memory (especially if buffering multiple macroblocks/search areas).
Motion estimator organization PE 0 search area network PE 1 comparator ctrl Address generator ... Motion vector macroblock network PE 15
Pixel schedules M(0,0) S(0,2)
System testing Testing requires a large amount of data. Use simple patterns with obvious answers for initial tests. Extract sample data from JPEG pictures for more realistic tests.