Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1 Embedded Computing 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)

Similar presentations


Presentation on theme: "Chapter 1 Embedded Computing 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)"— Presentation transcript:

1

2 Chapter 1 Embedded Computing 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)

3 Embedded Computing-1 Outline  What are embedded systems?  Challenges in embedded computing system design  Design methodologies  Object-oriented design and Unified Modeling Language (UML)  Example: model train controller

4 Embedded Computing-2 Definition  Embedded system: any device that includes a programmable computer but is not itself a general-purpose computer.  Take advantage of application characteristics to optimize the design: don’t need all the general-purpose bells and whistles.

5 Embedded Computing-3 Embedding a computer CPU mem input output analog embedded computer

6 Embedded Computing-4 Examples  Personal digital assistant (PDA).  Printer.  Cell phone.  Automobile: engine, brakes, dash, etc.  Television.  Household appliances.  PC keyboard (scans keys).

7 Embedded Computing-5 Early history  Late 1940’s: MIT Whirlwind computer for real- time operations; Originally designed to control an aircraft simulator.  First  P was Intel 4004 in early 1970’s.  HP-35 calculator used several chips to implement a microprocessor in 1972  Automobiles used microprocessor-based engine controllers starting in 1970’s. Control fuel/air mixture, engine timing, etc. Multiple modes of operations: warm-up, hill climbing.. Provides lower emissions, better fuel efficiency.

8 Embedded Computing-6 Microprocessor varieties  Microcontroller: includes I/O devices, on-board memory.  Digital signal processor (DSP): microprocessor optimized for digital signal processing.  Typical embedded word sizes: 8-bit, 16-bit, 32- bit.

9 Embedded Computing-7 Application examples  Simple control: front panel of microwave oven, etc.  Canon EOS 3 has three microprocessors. 32-bit RISC CPU runs autofocus and eye control systems.  Analog TV: channel selection, etc.  Digital TV: programmable CPUs + hardwired logic.

10 Embedded Computing-8 Automotive embedded systems  High-end automobile may have 100  Ps: 4-bit microcontroller checks seat belt; microcontrollers run dashboard devices; 16/32-bit microprocessor controls engine.  BMW 850i Anti-lock brake system (ABS): pumps brakes to reduce skidding. Automatic stability control (ASC+T): controls engine to improve stability. ABS was introduced first--> ASC+T needs to interface to existing ABS module.

11 Embedded Computing-9 BMW 850i, cont’d. brake sensor brake sensor brake sensor brake sensor ABS hydraulic pump

12 Embedded Computing-10 Characteristics of embedded systems  Sophisticated functionality. Often run sophisticated algo. or multiple algo.  Cell phone, laser printer. Often provide sophisticated user interfaces.  Real-time operation. Must finish operations by deadlines.  Hard real time: missing deadline causes failure.  Soft real time: missing deadline results in degraded performance. Many systems are multi-rate: must handle operations at widely varying rates.

13 Embedded Computing-11 Characteristics of embedded systems  Low manufacturing cost. Many embedded systems are mass-market items that must have low manufacturing costs.  Limited memory, microprocessor power, etc.  Low power. Power is critical in battery-powered devices  Excessive power consumption increases system cost even in wall-powered devices.  Designed to tight deadlines by small teams. 6 month market window is common. E.g., can’t miss back-to-school window for calculator.

14 Embedded Computing-12 Why use microprocessors?  Alternatives: field-programmable gate arrays (FPGAs), custom logic, etc. Intuition: Microprocessors use much more logic to implement a function than does custom logic.  But, microprocessors are often efficient, because can use same logic to perform different functions heavily pipelined large design teams aggressive VLSI technology  Microprocessors simplify the design of families of products.

15 Embedded Computing-13 Although power is a concern,  Custom logic is a clear winner for low power devices.  Modern microprocessors offer features to help control power consumption.  Software design techniques can help reduce power consumption.

16 Embedded Computing-14 Outline  What are embedded systems?  Challenges in embedded computing system design  Design methodologies  Object-oriented design and Unified Modeling Language (UML)  Example: model train controller

17 Embedded Computing-15 Challenges in embedded system design  How much hardware do we need? How big is the CPU? Memory?  How do we meet our deadlines? Faster hardware or cleverer software?  How do we minimize power? Turn off unnecessary logic? reduce mem. accesses?  Does it really work? Is the specification correct? Is the spec met? How do we test for real-time, real data?  How do we work on the system? Observability, controllability? development platform?

18 Embedded Computing-16 Design methodologies  A procedure for designing a system.  Understanding methodology helps you ensure you didn’t skip anything.  Compilers, computer-aided design (CAD) tools, software engineering tools, etc., can be used to: help automate methodology steps; keep track of the methodology itself.

19 Embedded Computing-17 Need to consider design goals  Performance. Overall speed, deadlines.  Functionality and user interface.  Manufacturing cost.  Power consumption.  Other requirements (physical size, etc.)

20 Embedded Computing-18 Work with levels of abstraction requirements specification architecture component design system integration Top-down design Bottom-up design Real design uses both techniques

21 Embedded Computing-19 Stepwise refinement  At each level of abstraction, we must: analyze the design to determine characteristics of the current state of the design; refine the design to add detail.

22 Embedded Computing-20 Level 1: Requirements  Plain language description of what the user wants and expects to get.  May be developed in several ways: talking directly to customers; talking to marketing representatives; providing prototypes to users for comment.

23 Embedded Computing-21 Functional vs. non-functional requirements  Functional requirements: output as a function of input.  Non-functional requirements: time required to compute output; size, weight, etc.; power consumption; reliability; etc.

24 Embedded Computing-22 Our requirements form

25 Embedded Computing-23 Example: GPS moving map requirements  Moving map obtains position from GPS, paints map from local database. lat: 40 13 lon: 32 19 I-78 Scotch Road

26 Embedded Computing-24 GPS moving map needs  Functionality: For automotive use. Show major roads and landmarks.  User interface: At least 400 x 600 pixel screen. Three buttons max. Pop-up menu.  Performance: Map scroll smoothly. Less than 1 sec power-up. Lock onto GPS within 15 sec  Cost: $500 street price = approx. $100 cost of goods sold.  Physical size/weight: Should fit in hand.  Power consumption: 8 hours on 4 AA batteries.

27 Embedded Computing-25 GPS moving map requirements form

28 Embedded Computing-26 Level 2: Specification  A more precise description of the system: should not imply a particular architecture; provides input to the architecture design process.  May include functional and non-functional elements.  May be executable or may be in mathematical form for proofs.  UML (Unified Modeling Language)

29 Embedded Computing-27 GPS specification  Should include: What is received from GPS; map data; user interface; operations required to satisfy user requests; background operations needed to keep the system running.

30 Embedded Computing-28 Level 3: Architecture design  What major components go satisfying the specification?  Hardware components: CPUs, peripherals, etc.  Software components: major programs and their operations.  Must take into account functional and non- functional specifications.

31 Embedded Computing-29 GPS moving map block diagram GPS receiver search engine renderer user interface database display

32 Embedded Computing-30 GPS moving map hardware architecture GPS receiver CPU panel I/O display frame buffer memory

33 Embedded Computing-31 GPS moving map software architecture position database search renderer timer user interface pixels

34 Embedded Computing-32 Level 4: HW and SW components  Must spend time architecting the system before you start coding.  Some components are ready-made, some can be modified from existing designs, others must be designed from scratch.

35 Embedded Computing-33 Level 5: System integration  Put together the components. Many bugs appear only at this stage.  Have a plan for integrating components to uncover bugs quickly, test as much functionality as early as possible.

36 Embedded Computing-34 Outline  What are embedded systems?  Challenges in embedded computing system design  Design methodologies  Object-oriented design and Unified Modeling Language (UML)  Example: model train controller

37 Embedded Computing-35 System modeling  Need languages to describe systems: useful across several levels of abstraction; understandable within and between organizations.  Block diagrams are a start, but don’t cover everything.

38 Embedded Computing-36 Object-oriented design  Object-oriented (OO) design: A generalization of object-oriented programming.  Object = state + methods. State provides each object with its own identity. Methods provide an abstract interface to the object.  Class: object type Defines the object’s state elements but state values may change over time. Defines the methods used to interact with all objects of that type.  Each object has its own state.

39 Embedded Computing-37 OO implementation in C++ class display { pixels : pixeltype[IMAX,JMAX]; public: display() { } pixeltype pixel(int i, int j) { return pixels[i,j]; } void set_pixel(pixeltype val, int i, int j) { pixels[i,j] = val; } }

40 Embedded Computing-38 OO design principles  Some objects will closely correspond to real- world objects. Some objects may be useful only for description or implementation.  Objects provide interfaces to read/write state, hiding the object’s implementation from the rest of the system.

41 Embedded Computing-39 UML  Unified Modeling Language  Developed by Booch et al.  Goals: object-oriented; visual; useful at many levels of abstraction; usable for all aspects of design.

42 Embedded Computing-40 UML object d1: Display pixels: array[] of pixels elements menu_items pixels is a 2-D array comment object name class name attributes

43 Embedded Computing-41 UML class Display pixels elements menu_items mouse_click() draw_box operations class name  The operations provide the abstract interface between the class’s implementation and other classes.  Operations may have arguments, return values.  An operation can examine and/or modify the object’s state.

44 Embedded Computing-42 Relationships between objects and classes  Association: objects communicate but one does not own the other.  Aggregation: a complex object is made of several smaller objects.  Composition: aggregation in which owner does not allow access to its components.  Generalization: define one class in terms of another.

45 Embedded Computing-43 Class derivation  Define one class in terms of another. Derived class inherits attributes, operations of base class. Derived_class Base_class UML generalization

46 Embedded Computing-44 Class derivation example Display pixels elements menu_items pixel() set_pixel() mouse_click() draw_box BW_displayColor_map_display base class derived class

47 Embedded Computing-45 Multiple inheritance SpeakerDisplay Multimedia_display base classes derived class

48 Embedded Computing-46 message msg: ADPCM_stream length : integer message set count : integer 0..*1 contains # contained messages # containing message sets Association  Association: describes relationship between classes.  Example: association name

49 Embedded Computing-47 Links  Link: describes relationships between objects.  Example: Link defines the contains relationship message msg = msg1 length = 1102 message msg = msg2 length = 2114 message set count = 2

50 Embedded Computing-48 Behavioral description  We have discussed how to specify structure  Now consider describing behavior of the system: internal view external view  Use state machines ab state state name transition

51 Embedded Computing-49 Event-driven state machines  Behavioral descriptions are written as event- driven state machines. Machine changes state when receiving an input.  Events may come from inside or outside of the system Signal: asynchronous event. Call: synchronized communication. Timer: activated by time.

52 Embedded Computing-50 > mouse_click leftorright: button x, y: position declaration a b mouse_click(x,y,button) event description Types of events  Signal event:

53 Embedded Computing-51 cd draw_box(10,5,3,2,blue) Types of events  Call event:  Timer event: ef tm(time-value)

54 Embedded Computing-52 Example state machine region found got menu item called menu item found object highlighted start finish mouse_click(x,y,button)/ find_region(region) input/output region = menu/ which_menu(i) call_menu(I) region = drawing/ find_object(objid) highlight(objid)

55 Embedded Computing-53 Sequence diagram  Shows sequence of operations over time.  Relates behaviors of multiple objects. m: Moused1: Displayu: Menu mouse_click(x,y,button) which_menu(x,y,i) call_menu(i) time

56 Embedded Computing-54 Outline  What are embedded systems?  Challenges in embedded computing system design  Design methodologies  Object-oriented design and Unified Modeling Language (UML)  Example: model train controller

57 Embedded Computing-55 Model train setup console power supply rcvrmotor ECCaddressheadercommand

58 Embedded Computing-56 Requirements  Console can control 8 trains on 1 track.  Throttle has at least 63 levels.  Inertia control adjusts responsiveness with at least 8 levels.  Emergency stop button.  Error detection scheme on messages.

59 Embedded Computing-57 Requirements form

60 Embedded Computing-58 Conceptual specification  Before we create a detailed specification, we will make an initial, simplified specification. Gives us practice in specification and UML. Good idea in general to identify potential problems before investing too much effort in detail.  Can start with message definitions, which determines what the controller can do CommandParameter set-speedspeed (positive or negative) set-inertiainertial-value (nonnegative) estopNone

61 Embedded Computing-59 Message classes command set-inertia value: unsigned- integer set-speed value: integer estop

62 Embedded Computing-60 :console:train_rcvr set-inertia set-speed estop :console:receiver 1..n: command Subsystem collaboration  Sequence diagram

63 Embedded Computing-61 Major subsystem roles  Console: read state of front panel; format messages; transmit messages.  Train: receive message; interpret message; control the train.

64 Embedded Computing-62 Console system classes console panelformattertransmitter receiver*sender* 1 1 1 1 1 1 1 1 1 1

65 Embedded Computing-63 Console class roles  panel: describes analog knobs and interface hardware.  formatter: turns knob settings into bit streams.  transmitter: sends data on track.

66 Embedded Computing-64 Train system classes train set train receiver controller motor interface detector*pulser* 1 1..t 1 1 1 1 1 1 1 1 1 1

67 Embedded Computing-65 Train class roles  receiver: digitizes signal from track.  controller: interprets received commands and makes control decisions.  motor interface: generates signals required by motor.

68 Embedded Computing-66 Detailed specification  We can now fill in the details of the conceptual specification: more classes; behaviors.  Sketching out the spec first helps us understand the basic relationships in the system.

69 Embedded Computing-67 Train speed control  Motor controlled by pulse width modulation: V + - duty cycle

70 Embedded Computing-68 Console physical object classes knobs* train-knob: integer speed-knob: integer inertia-knob: unsigned- integer emergency-stop: boolean pulser* pulse-width: unsigned- integer direction: boolean sender* send-bit() detector* read-bit() : integer

71 Embedded Computing-69 Panel and motor-interface classes  panel class defines the controls. new-settings() behavior reads the controls.  motor-interface class defines the motor speed held as state. panel train-number() : integer speed() : integer inertia() : integer estop() : boolean new-settings() motor-interface speed: integer

72 Embedded Computing-70 Transmitter and receiver classes  Transmitter: 1 behavior for each type message  Receiver function provides methods to: detect a new message, decide type, read parameters transmitter send-speed(adrs: integer, speed: integer) send-inertia(adrs: integer, val: integer) set-estop(adrs: integer) receiver current: command new: boolean read-cmd() new-cmd() : boolean rcv-type(msg-type: command) rcv-speed(val: integer) rcv-inertia(val:integer)

73 Embedded Computing-71 Formatter class formatter current-train: integer current-speed[ntrains]: integer current-inertia[ntrains]: unsigned-integer current-estop[ntrains]: boolean send-command() panel-active() : boolean operate()  Formatter class holds state for each train, setting for current train.  The operate() operation performs the basic formatting task.

74 Embedded Computing-72 Control input cases  Use a soft panel to show current panel settings for each train.  Changing train number: must change soft panel settings to reflect current train’s speed, etc.  Controlling throttle/inertia/estop: read panel, check for changes, perform command.

75 Embedded Computing-73 Control input sequence diagram :knobs:panel:formatter:transmitter change in speed/ inertia/estop change in train number change in control settings read panel panel settings panel-active send-command send-speed, send-inertia. send-estop read panel panel settings read panel panel settings change in train number set-knobs new-settings

76 Embedded Computing-74 Formatter operate behavior idle update-panel() send-command() panel-active()new train number other

77 Embedded Computing-75 Panel-active behavior panel*:read-train() current-train = train-knob update-screen changed = true T panel*:read-speed() current-speed = throttle changed = true T F... F

78 Embedded Computing-76 Controller class controller current-train: integer current-speed[ntrains]: integer current-direction[ntrains]: boolean current-inertia[ntrains]: unsigned-integer operate() issue-command()

79 Embedded Computing-77 Setting the speed  Don’t want to change speed instantaneously.  Controller should change speed gradually by sending several commands.

80 Embedded Computing-78 Sequence diagram for set-speed command :receiver:controller:motor-interface:pulser* new-cmd cmd-type rcv-speed set-speed set-pulse

81 Embedded Computing-79 Controller operate behavior issue-command() receive-command() wait for a command from receiver

82 Embedded Computing-80 Refined command classes command type: 3-bits address: 3-bits parity: 1-bit set-inertia type=001 value: 3-bits set-speed type=010 value: 7-bits estop type=000

83 Embedded Computing-81 Summary  Embedded computers are all around us. Many have complex embedded HW and SW  Many design challenges: design time, deadlines, power, etc.  Methodologies help manage design process.  Object-oriented design helps organize a design.  UML is a transportable system design language. Provides structural and behavioral primitives.  Separate specification and programming.  Can’t completely separate specification and architecture. Make a few tasteful assumptions.


Download ppt "Chapter 1 Embedded Computing 金仲達教授 清華大學資訊工程學系 (Slides are taken from the textbook slides)"

Similar presentations


Ads by Google