Syllabus Hardware Software Codesign of Embedded Systems Siamak Mohammadi Tehran University 1. Introduction to Embedded System Design 2. HW/SW Codesign Overview 3. Cospecification and modeling 4. Embedded System partitioning 5. CPU and Accelerator based Embedded System Codesign 6. Embedded Computer Organization 7. Embedded System controller case studies 8. Embedded SoPC: Virtex System on Programmable Chips Tehran University 2 Syllabus 9. Compilers for Embedded Systems 10. Real-time operating systems 11. System level power/energy optimization 12. HW/SW Codesign environments References Hardware/Software Co-Design: Principles and Practices J. Staunstrup and W. Wolf, Kluwer 1997 Embedded System Design: A Unified Hardware/Software Approach Frank Vahid and Tony Givargis, 1999 Papers Tehran University 3 Tehran University 4
Course goals Show benefits of the codesign approach over current design process Provide information on how to incorporate these techniques into a general digital design methodology for embedded systems Illustrate how codesign concepts are being introduced into design methodologies Introduce the fundamentals of HW/SW codesign and partitioning concepts in designing embedded systems Discuss the current trends in the codesign of embedded systems Provide information on the goals of and methodology for partitioning hardware/software in systems Course goals (cont.) Software and hardware components of an embedded system Understand real-time operating systems Embedded Computer Architecture Tehran University 5 Tehran University 6 Introduction What are Embedded Systems? Difficulties with the design of heterogeneous HW/SW Systems Requirements of modern embedded systems Embedded Systems Design Flow Embedded Systems Application What is an Embedded (real-time) System? Most embedded systems are also real-time systems. An embedded system is an information processing system that responds to externally generated input stimuli within a finite and specified period. The correctness depends not only on the logical result but also the time it was delivered Failure to respond is as bad as the wrong response! Embedded system: any device that includes a programmable computer but is not itself a generalpurpose computer Take advantage of application characteristics to optimize the design: Don t need all the general-purpose bells and whistles. Tehran University 7 Tehran University 8
Embedding a computer Embedded Systems Electronic devices that incorporate a computer (microprocessor/micro-controller) in their implementation A computer is used in such devices primarily as a means to simplify the system design and to provide flexibility Often the user of the device is not even aware that a computer is present Embedded Systems are every where Embedded processors account for more than 90% of worldwide microprocessor production. Embedded:desktop = 100:1 99% of all processors are for the embedded systems market. Number of embedded processors in a typical home is estimated at 50-60 (a recent Acura automobile has more than 48 processors) Tehran University 9 Tehran University 10 Embedded Real Time Systems Real-time systems process events Events occurring on external inputs cause other events to occur as outputs Minimizing response time is usually a primary objective, or otherwise the entire system may fail to operate properly Types of Embedded Real Time System: Hard real-time Soft real-time Firm real-time Types of Real-Time Systems Hard real-time systems where it is absolutely imperative that the responses occur within the required deadline. For ex: Flight control systems, heart pace makers Soft real-time systems where deadlines are important but which will still function correctly if deadlines are occasionally missed. For ex: dropping frames while displaying a video Firm real-time allow occasional deadline violations but discard any jobs that are not finished by their deadlines A single system may have all hard, soft and firm real-time subsystems. In reality many systems will have a cost function associated with missing each deadline. Tehran University 11 Tehran University 12
Multi-tasking and Concurrency Most embedded systems have several inputs/outputs and multiple events occurring independently Separating tasks simplifies programming, but requires somehow switching back and forth among multiple tasks (multitasking) Concurrency is the appearance of simultaneous execution of multiple tasks Concurrent task for a Thermostat: /* Monitor Temperature*/ do forever { measure temp ; if (temp < setting) start furnace ; else if (temp > setting + delta) stop furnace ; } /* Monitor Time of Day */ do forever { measure time ; if (6:00am) setting = 26C ; else if (11:00pm) setting = 20C ; } /* Monitor Keypad */ do forever { check keypad ; if (raise temp) setting++ ; else if (lower temp) setting-- ; } Embedded Systems Applications Aerospace spacecrafts: Navigation systems, automatic landing systems, flight attitude controls, engine controls, space exploration (e.g., the Mars Pathfinder) Automotive: Fuel injection control, passenger environmental controls, anti-lock braking, air bag controls, GPS mapping Children toys: Nintendo's "Game Boy Communications: Satellites, network routers, switches, hubs Tehran University 13 Tehran University 14 Embedded Systems Applications Computer peripherals: Printers, scanners, keyboards, displays, modems, hard disk drives, CD-ROM drives Home: Dishwashers, microwave ovens, VCRs, televisions, stereos, fire/security alarm systems, lawn sprinkler controls, thermostats, cameras, clock radios, answering machines Industrial: Elevator controls, surveillance systems, robots Instrumentation: Data collection, oscilloscopes, signal generators, signal analyzers, power supplies Embedded Systems Applications Medical: Imaging systems (e.g., XRAY, MRI, and ultrasound), patient monitors, and heart pacers Office automation: FAX machines, copiers, telephones, and cash registers Personal: Personal Digital Assistants (PDAs), pagers, cell phones, wristwatches, video games, portable MP3 players, GPS Tehran University 15 Tehran University 16
Parts of an Embedded System USER SENSORS I/O EMBEDDED SYSTEM MEMORY PROCESSOR HARDWIRED UNIT Application-specific logic Timers A/D and D/A conversion ACTUATORS Parts Actuators - mechanical components (e.g., valve) Sensors - input data (e.g., accelerometer for airbag control) Data conversion, storage, processing Decision-making Range of implementation options Single-chip implementation: system on a chip ENVIRONMENT Tehran University 17 Tehran University 18 Early History of Embedded Systems First microprocessor 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 operation: warm-up, cruise, hill climbing, etc. Provides lower emissions, better fuel efficiency 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, and 32-bit. Automotive Embedded Systems Today s high-end automobile may have 100 microprocessors: 4-bit microcontroller checks seat belt Microcontrollers run dashboard devices 16/32-bit microprocessor controls engine BMW 850i brake and stability control system Anti-lock brake system (ABS): Pumps brakes to reduce skidding. Automatic Stability Control (ASC+T): Controls engine to improve stability ABS and ASC+T communicate. ABS was introduced first--- ASC+T needed to interface to existing ABS module. Tehran University 19 Tehran University 20
Anti-lock Brake System (ABS) Sensor Brake Sensor Brake Embedded System Applications Programmable Digital Thermostat 4-bit microprocessor ABS Hydraulic pump Brake Brake Sensor Sensor Tehran University 21 Tehran University 22 Embedded System Applications NASA s Mars Rover Intel 80C85 8-bit microprocessor Embedded System Applications Palm Vx Handheld 32-bit CPU Motorola Dragonball EZ Tehran University 23 Tehran University 24
Embedded System Applications DVD Player 32-bit RISC Microprocessor Embedded System Applications IBM Research s Linux Wrist Watch Prototype Hardware CPU: High speed, low power 32 bit MPU (18-74 MHz) Input devices: Touch panel, button Display: 320 x 240 dots, monochrome liquid crystal display Memory: 8MB low power DRAM, 16MB flash Interfaces: Bluetooth wireless technology (v1.1, voice-enabled), IrDA (V1.2), RS232C (via a cradle) Others: Speaker, microphone, vibrator, fingerprint sensor, accelerator sensor Cradle: RS232C, AC adapter, and AA batteries Software Operating system: Linux kernel version 2.4 GUI: Microwindows Bluetooth stack: IBM BlueDrekar (L2CAP, SDP, RFCOMM) Tehran University 25 Tehran University 26 Embedded System Applications SONY Aibo Robot Dog Embedded System Applications Vending Machine 8-bit Motorola 68HC11 Microcontroller Tehran University 27 Tehran University 28
Embedded Real-time System Features Large and complex vary from a few hundred lines of assembler or C to 20 million lines of Ada Concurrent control of separate system components devices operate in parallel in the real world; better to model this parallelism by concurrent entities in the program Facilities to interact with special purpose hardware need to be able to program devices in a reliable and abstract way Extreme reliability and safe embedded systems typically control the environment in which they operate; failure to control can result in loss of life, damage to environment or economic loss Guaranteed response times we need to be able to predict with confidence the worst case response times for systems; efficiency is important but predictability is essential Characteristics of Embedded Systems Sophisticated functionality Complex algorithms: filtering functions in cars User Interface: moving maps in GPS Real Time operations Multirate Several real-time activities at the same time for example audio and video multimedia Manufacturing cost Power Tehran University 29 Tehran University 30 Embedded Systems Non-Functional Requirements Performance Cost Manufacturing cost must often be low NRE (non-recurring engineering) Physical size and weight Power consumption Critical in battery-powered systems Excessive power consumption increases system cost even in wall-powered devices Custom logic is the clear winner for low power devices Software techniques can help reduce power consumption Why Use Microprocessors? Alternative to custom logic, FPGAs Efficient way to implement digital systems Can built various feature sets for different products using same logic Simplify the design of products μp-based designs can be as fast because: μps execute programs very efficiently (RISC: one instruction per cycle) CPUs run at very high speed Heavily pipelined Aggressive VLSI technology Tehran University 31 Tehran University 32
Challenges in Embedded System Design How much hardware do we need? How big is the CPU, Memory, Peripheral devices? How do we meet deadlines? Faster HW or cleverer SW? How do we minimize power? Run slower? Turn off unnecessary logic? Reduce memory access? How do we consider upgradeability? Add features by changing SW for next product generation Reliability Finding bugs in safety-critical systems before selling it! Challenges in Embedded System Design Design Methodology: A procedure for designing a system Requirements, Specification, Architecture, components, System Integration Understanding your methodology helps you ensure you didn t skip anything Compilers, software engineering tools, computer-aided design (CAD) tools, etc., can be used to: Help automate methodology steps Keep track of the methodology itself Tehran University 33 Tehran University 34 Question: What are Design Goals? Performance Overall speed, deadlines. Functionality and user interface Manufacturing cost Power consumption Other requirements (physical size, etc.) StreetPilot GPS Receiver 16-bit microprocessor Tehran University 35 Tehran University 36
Requirements Analysis of a GPS Moving Map Moving map obtains its position from the GPS (satellite-based navigation system) Paints map from the local database Hemat User s current position Lat: 20 12 long:40 15 Kurdistan 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 should scroll smoothly. No more than 1 sec power-up. Lock onto GPS within 15 seconds Cost: $700 street price = approx. $150 cost of goods sold Physical size/weight: Should fit in hand Power consumption: Should run for 8 hours on four AA batteries Tehran University 37 Tehran University 38 GPS Moving Map Requirements form Name Purpose Inputs GPS moving map Consumer-grade moving map for driving Power button, three control buttons Outputs Back-lit LCD 400 X 600 Functions Performance Manufacturing cost Power Physical size/weight 5-receiver GPS; three resolutions; displays current latitude/longitude Updates screen within 0.25 sec of movement $100 cost-of-goods-sold 100 mw No more than 2 X 6, 12 oz 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 It 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. Tehran University 39 Tehran University 40
System Architecture Design Moving Map Block Diagram What major components needed to satisfy the specification? Hardware components: CPUs Memory, Peripherals, etc. Software components: Major programs and their operations Must take into account functional and nonfunctional specifications Tehran University 41 Tehran University 42 GPS HW Architecture GPS SW Architecture Tehran University 43 Tehran University 44
Hardware Software Components Must spend time architecting the system before you start coding Some components are ready-made, some can be modified from existing designs, and others must be designed from scratch 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 An embedded system example: a digital camera lens CCD Digital camera chip A2D JPEG codec DMA controller CCD preprocessor Microcontroller Pixel coprocessor Multiplier/Accum Display ctrl Memory controller ISA bus interface UART LCD ctrl Single-functioned -- always a digital camera Tightly-constrained -- Low cost, low power, small, fast Reactive and real-time -- only to a small extent D2A Tehran University 45 Tehran University 46 Summary Embedded Systems are all around us Many systems have complex embedded hardware and software Embedded systems pose many design challenges: Design time Power Performance Deadlines Design methodology help us manage the design process What comes next? HW/SW Codesign Overview Modeling and co-specification of Embedded Systems SystemC as a specification language Partitioning and Scheduling Hardware Accelerator based Embedded Systems Embedded Computer Organization Code generation and retargetable Compilers Real-time operating systems System Level Power/Energy Optimization Etc. Tehran University 47 Tehran University 48