ceng-336 introduction to embedded systems...
TRANSCRIPT
CENG-336Introduction to Embedded Systems Development
CENGCENG--336336Introduction to Embedded Introduction to Embedded Systems DevelopmentSystems Development
An Introduction toAn Introduction to
MicroprocessorMicroprocessors and Embedded Systemss and Embedded Systems
CENG-336 Introduction to Embedded Systems Development 2
What is this course about?What is this course about?
CENG 336 Introduction to Embedded CENG 336 Introduction to Embedded Systems Development (2Systems Development (2--2)2) 33Assembly language and controller architecture. Peripheral interfaces: A/D and D/A conversion, parallel and serial ports, interrupts and timers/counters. I/O bus architectures. Sensors and actuators. Design and analysis techniques. Real time operating systems.
Prerequisite: CENG 232.
http://catalog.metu.edu.tr/
CENG-336 Introduction to Embedded Systems Development 3
Course ScheduleCourse Schedule (Spring(Spring’’0088))
� Text Book� No Textbook
� Reference Material� PIC 16F87X Data sheets (http://www.microchip.com)� PIC 18F4520 Data Sheets
� Design with PIC Microcontrollers, John B. Peatman, Prentice Hall,1998.
� Course webpage/newsgoup: � http://cow.ceng.metu.edu.tr/Courses� nntp://news.ceng.metu.edu.tr/metu.ceng.course.336
CENG-336 Introduction to Embedded Systems Development 4
What is an What is an EEmbeddedmbedded CComputeromputerSSystemystem??
� What is a computer?� [Merriam-Webster Dictionary] one that computes; specifically: a programmable electronic device that can store, retrieve, and process data.
� Classification of Computers– by price and computing power
� Dedicated controllers – Embedded controllers
� Personal computers� Mainframes� Supercomputers
CENG-336 Introduction to Embedded Systems Development 5
Types of ComputersTypes of Computers
� Mainframes (?)� largest and most powerful
�massive amounts of memory
� use large data words…64 bits or greater
�mostly used for military defense and large business data processing
� examples: IBM 4381, Honeywell DPS8(old!!)
CENG-336 Introduction to Embedded Systems Development 6
Types of ComputersTypes of Computers
� Microcomputers� range from small controllers that work with 4 bit words to the PCs we are familiar with that work with 32 bit words� modern microcomputers are becoming indistinguishable from early minicomputers…functionally speaking
� large variety of uses from specialized controls like a printer to personal publishing
� the CPU is usually 1 Integrated Circuit (IC) called a microprocessor
� examples: Intel 8051 controller chip, IBM PC, Apple Macintosh
CENG-336 Introduction to Embedded Systems Development 7
Types of ComputersTypes of Computers
� Supercomputers� fastest and most powerful mainframes
� contains multiple central processors
� used for scientific applications, and number crunching
� now have teraflop performance
� Grid-computing
� Parallelism
CENG-336 Introduction to Embedded Systems Development 8
AgendaAgenda
� Types of Computers
� Microcomputer Structure
� Microprocessor Evolution
� Internal Architecture
� Introduction to Embedded Systems
CENG-336 Introduction to Embedded Systems Development 9
Microcomputer StructureMicrocomputer Structure
� Central Processing Unit (CPU)
� Memory
� Input/Output (I/O) circuitry
� Buses�Address bus�Data bus�Control bus
CENG-336 Introduction to Embedded Systems Development 10
MemoryMemory
� A mixture of RAM and ROM…may also include magnetic hard disks and optical disks
� 2 purposes of memory� store the binary codes for the sequence of instructions specified by programs
� store binary data that the computer needs to execute instructions
CENG-336 Introduction to Embedded Systems Development 11
I/OI/O� the way the computer communicates with the outside world
� peripherals are connected to the I/O ports� printers, modems, keyboard, mouse, scanner� Universal Serial Bus (USB)
� ports� physical devices needed to interface with the computer’s internal buses
� actually a set of D flip-flops connected in parallel� how do we distinguish between an input port and an output port?
CENG-336 Introduction to Embedded Systems Development 12
CPUCPU
� the “brains” of the computer
� its job is to fetch instructions, decode them, and then execute them
� contains:� an Instruction Pointer register which contains the address of the next instruction
� general purpose registers for temporary storage� circuitry to generate signals to the control bus
CENG-336 Introduction to Embedded Systems Development 13
Address BusAddress Bus
� consists of multiple (typically 16,20, 24, or 32) parallel signal lines (wires)� these lines contain the address of the memory location to read or written
� just how many unique addresses can an address bus specify?
CENG-336 Introduction to Embedded Systems Development 14
Data Data BBusus
� consists of multiple (typically 8,16, or 32) parallel signal lines � these are bi-directional… meaning that data can be read from/written to either memory or a port
� only one device at a time can have its outputs enabled, even though many will have their outputs connected to the same data bus� this requires the devices to have three-state output
CENG-336 Introduction to Embedded Systems Development 15
Control BusControl Bus
� consists of multiple (typically 4 to 10)parallel signal lines
� CPU sends signals along these lines to memory and to I/O ports� examples: Memory Read, Memory Write, I/O Read, I/O Write
CENG-336 Introduction to Embedded Systems Development 16
Typical CPU BehaviorTypical CPU Behavior
Goal: � Read a word of data from a memory location
Process: � CPU first sends out the address along the address bus to the memory device
� CPU then sends the Memory Read signal along the control bus
� the output from the memory device travels back to the CPU along the data bus
CENG-336 Introduction to Embedded Systems Development 17
AgendaAgenda
� Types of Computers
� Microcomputer Structure
� Microprocessor Evolution
� Internal Architecture
� Introduction to Embedded Systems
CENG-336 Introduction to Embedded Systems Development 18
Microprocessor EvolutionMicroprocessor Evolution� microcomputers are commonly categorized by the number of bits that their ALU can work with at a time� regardless of the number of address lines or data lines� the first commercial microprocessor was the Intel 4004…a 4-bit device combined with other devices to make a calculator
� next came the Intel 8008…an 8-bit device, but it required many additional devices to be a functional CPU
� Intel 8080…another 8-bit device, but it only required 2 additional devices– it also used different transistors making it much faster, and started the 2nd generation of microprocessors– then Motorola entered the market with the MC6800
CENG-336 Introduction to Embedded Systems Development 19
Directions Directions ......
� Embedded controllers� used to control smart machines� printers, auto braking systems� also called “microcontrollers”
� Bit-slice processors� custom-designed hardware and custom-designed instruction set made by connecting devices…each part becomes a slice needed for a specific application
� these were created because general-purpose CPUs were not fast enough or did not have a rich enough instruction set
CENG-336 Introduction to Embedded Systems Development 20
General Purpose CPUsGeneral Purpose CPUs
� Intel released the 8086, a 16-bit microprocessor, in 1978
� Motorola followed with the MC68000 as their 16-bit processor
� the 16-bit processor works with 16 bit words, rather than 8 bit words…� instructions are executed faster� provide single instructions for more complex instructions…multiply and divide
�Reminder: “clock cycle” is also improving during these developments
CENG-336 Introduction to Embedded Systems Development 21
32 bit Processors32 bit Processors
� 16 bit processors evolved into 32 bit processors� now able to work with gigabytes (109 bytes) and terabytes (1012 bytes)
� Intel released the 80386�Motorola released the MC68020
CENG-336 Introduction to Embedded Systems Development 22
The 8086 Microprocessor FamilyThe 8086 Microprocessor Family
� Characteristics� 16 bit microprocessor� 16 bit data bus
� it can read from or write to memory and I/O ports either 8 or 16 bits at a time
�20 bit address bus� it can address 220 memory locations– each location is 1 byte (8 bits) wide, thus 16 bit words will require consecutive memory locations
CENG-336 Introduction to Embedded Systems Development 23
Members of this familyMembers of this family
� 8088� same as 8086 but has an 8 bit data bus
� 80186/80188� enhanced instruction set…but still backwards compatible
� 80286� designed for a multi-user, multi-tasking microcomputer� users a virtual address mode to prevent collision of users’programs
� 80386/80486� first Intel 32 bit processor� can directly address up to 4 GB of memory
Intel 80x86
CENG-336 Introduction to Embedded Systems Development 24
Story of the Humble TransistorStory of the Humble Transistor
CENG-336 Introduction to Embedded Systems Development 25
CENG-336 Introduction to Embedded Systems Development 26
CENG-336 Introduction to Embedded Systems Development 27
DefinitionDefinition
�� Embedded systemEmbedded system: any device that includes a programmable computer but is not itself a general-purpose computer.
� Computer purchased as part of some other piece of equipment• Typically dedicated software (may be user-customizable)• Often replaces previously electromechanical components• Often no “real” keyboard• Often limited display or no general- purpose display device: don’t need all the general-purpose features.
CENG-336 Introduction to Embedded Systems Development 28
Embedded systems: ApplicationsEmbedded systems: Applications
� Consumer segment, e.g. cameras, camcorders, VCRs, washers, microwave ovens, …
� Automobiles, e.g., engine control, anti-lock brake, air bags, …
� Office automation, e.g., copiers, printers, FAX machines, …
� Telecommunications, e.g.,, cellular phones, PDAs, interactive game boxes, answering machines, …
� Other industrial products, e.g., door locks in hotel rooms, automatic faucets, …
CENG-336 Introduction to Embedded Systems Development 29
Embedded Systems: Typical Embedded Systems: Typical CharacteristicsCharacteristics
� Perform a single or tightly knit set of functions (not usually “general purpose”)
� Is part of a larger system that may not be a “computer”
� Works in a reactive and time-constrained environment
� Employs a combination of hardware & Software� Software provides features and flexibility� Hardware provides performance (Application specific processor design)
CENG-336 Introduction to Embedded Systems Development 30
What makes an embedded system What makes an embedded system unique? unique? -- Hardware perspectiveHardware perspective
� Microprocessor technology� Personal computers
� Pentium Chips, Power-PC chips� General purpose computers, raw computing power� 75 million units per year
�Embedded controllers� Special purpose microcontrollers� 2.5 billion units per year, 30 times larger in unit volume
CENG-336 Introduction to Embedded Systems Development 31
WorldWorld--wide Figureswide Figures
� GartnerGroupestimates 70 Billion µP used in embedded systems in 2001
� Other estimates say 50 to 120 Billion µP
� Average embedded system has 4 µP
� Of all µP sold, 90% go into “non-computers”, 10% in “computers”
� You will most likely end up working with a “non-computer”at some point in your career
CENG-336 Introduction to Embedded Systems Development 32
What makes an embedded system What makes an embedded system unique? unique? –– Software perspectiveSoftware perspective
� No operating systems
� Execute a single program, tailored exactly to the controller hardware
� Assembly language (vs. High-level language)� Not transportable, machine specific� Programmer need to know CPU architecture� Speed� Program size� Uniqueness
CENG-336 Introduction to Embedded Systems Development 33
An embedded system example An embedded system example ---- a a digital cameradigital camera
Microcontroller
CCD preprocessor Pixel coprocessorA2D
D2A
JPEG codec
DMA controller
Memory controller ISA bus interface UART LCD ctrl
Display ctrl
Multiplier/Accum
Digital camera chip
lens
CCD
� Single-functioned -- always a digital camera
� Tightly-constrained -- Low cost, low power, small, fast
� Reactive and real-time -- only to a small extent
CENG-336 Introduction to Embedded Systems Development 34
Automotive embedded systemsAutomotive 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.
CENG-336 Introduction to Embedded Systems Development 35
BMW 850i brake and stability BMW 850i brake and stability control systemcontrol 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---needed to interface to existing ABS module.
CENG-336 Introduction to Embedded Systems Development 36
BMW 850i, contBMW 850i, cont’’d.d.
brake
sensor
brake
sensor
brake
sensor
brake
sensor
ABShydraulic
pump
CENG-336 Introduction to Embedded Systems Development 37
Example: BMW 745iExample: BMW 745i
� 2,000,000 LOC
� Windows CE OS
� 53 x 8-bit µP
� 11 x 32-bit µP
� 7 x 16-bit µP
� Multiple Networks
� Buggy!
CENG-336 Introduction to Embedded Systems Development 38
Components of Embedded SystemsComponents of Embedded Systems
CENG-336 Introduction to Embedded Systems Development 39
Embedded SystemsEmbedded Systems� Analog Components
� Sensors, Actuators, Controllers, …
� Digital Components
� Processor, Coprocessors
� Memories
� Controllers, Buses
� Application Specific Integrated Circuits (ASIC)
� Converters –A2D, D2A, …
� Software
� Application Programs
� Exception Handlers
CENG-336 Introduction to Embedded Systems Development 40
CharacteristicsCharacteristics
� Application Specific� Applications are known a priori� Optimize for cost, area, power, and performance
� Digital Signal Processing� Signals are represented digitally
� Reactive� Reacts to changes in the system’s environment
� Real-time� Compute certain tasks before deadline
� Distributed, Networked, …
CENG-336 Introduction to Embedded Systems Development 41
FeaturesFeatures
� Reliability� Probability of system working correctly at time T, provided that is was working at t=0
� MTBF – Mean Time Between Failure
� Maintainability� Probability of system working correctly d time units after error occurred.
� Safety� Not harmful for user
� Security� Confidential and authentic communication
CENG-336 Introduction to Embedded Systems Development 42
Traditional Design ChallengesTraditional Design Challenges
� Low cost
� Light weight
� Reliability
� Low power
� Portable
� Complexity
� Ease of use
�� Mixed digital/analog Mixed digital/analog
requirementsrequirements
�� Shrinking timeShrinking time--toto--
marketmarket
�� Short product lifetimeShort product lifetime
�� RealReal--time processingtime processing
�� Inherent concurrencyInherent concurrency
�� HW/SW coHW/SW co--designdesign
CENG-336 Introduction to Embedded Systems Development 43
Recent Design ChallengesRecent Design Challenges
� Design Complexity
� Ultra low power
� Highly adaptive� Active power management (voltage scaling, etc.)� Alternative energy source (solar, etc.)
� Internet aware
� Incorporate RF (Radio Frequency) technologies� Networking capabilities
� Verification
� Security
CENG-336 Introduction to Embedded Systems Development 44
Processor Processor TTechnologyechnology� The architecture of the computation engine used to implement a system’s desired functionality
� Processor does not have to be programmable� “Processor” is not equal to general-purpose processor
Application-specific
Registers
CustomALU
DatapathController
Program memory
Assembly code for:
total = 0for i =1 to …
Control logic and State register
Datamemory
IR PC
Single-purpose (“hardware”)
DatapathController
Controllogic
State register
Datamemory
index
total
+
IR PC
Registerfile
GeneralALU
DatapathController
Program memory
Assembly code for:
total = 0for i =1 to …
Control logic and
State register
Datamemory
General-purpose (“software”)
CENG-336 Introduction to Embedded Systems Development 45
GeneralGeneral--PPurposeurpose PProcessorsrocessors
� Programmable device used in a variety of applications� Also known as “microprocessor”
� Features� Program memory� General datapath with large register file and general ALU
� User benefits� Low time-to-market and NRE costs� High flexibility
� “Pentium” is the most well-known, but there are hundreds of others
IR PC
Registerfile
GeneralALU
DatapathController
Program memory
Assembly code for:
total = 0for i =1 to …
Control logic and State register
Datamemory
CENG-336 Introduction to Embedded Systems Development 46
SingleSingle--PPurposeurpose PProcessorsrocessors
� Digital circuit designed to execute exactly one program/task� a.k.a. coprocessor, accelerator or peripheral
� Features� Contains only the components needed to execute a single program
� No program memory
� Benefits� Fast� Low power� Small size
DatapathController
Control logic
State register
Datamemory
index
total
+
CENG-336 Introduction to Embedded Systems Development 47
ApplicationApplication--SSpecificpecific PProcessorsrocessors� Programmable processor optimized for a particular class of applications having common characteristics� Compromise between general-purpose and single-purpose processors
� Features� Program memory� Optimized datapath� Special functional units
� Benefits� Some flexibility, good performance, size and power
IR PC
Registers
CustomALU
DatapathController
Program memory
Assembly code for:
total = 0for i =1 to …
Control logic and State register
Datamemory
CENG-336 Introduction to Embedded Systems Development 48
MultiMulti--level Machines in level Machines in Structured Computer OrganizationStructured Computer Organization
Physical Physical -- Level 0Level 0
MicroarchitectureMicroarchitecture -- Level 1Level 1
Instruction Set Architecture Instruction Set Architecture -- Level 2Level 2
Assembly Language Assembly Language -- Level 4Level 4
High Order Language High Order Language -- Level 5Level 5
Operating System Operating System -- Level 3Level 3
CENG-336 Introduction to Embedded Systems Development 49
The Physical Level into The Physical Level into MicroarchitectureMicroarchitecture
� Transistors and logic gates form the basis of the components used to create modern digital microprocessors and microcontrollers� Arithmetic Logic Units� Memories and Registers� Control Units� Other functionality (e.g., counters, state machines, decoders, encoders, parity generators, multipliers, shifters)
� Putting the digital logic together to produce a controlled and useful computing machine creates a microarchitecture
CENG-336 Introduction to Embedded Systems Development 50
General EGeneral ES S TypesTypes�� General General ComputingComputing
� Applications similar to desktop computing, but in an embedded package
� Video games, set-top boxes, wearable computers, automatic tellers
�� Control SystemsControl Systems� Closed-loop feedback control of real- time system
� Vehicle engines, chemical processes, nuclear power, flight control, home automation
�� SignalSignal ProcessingProcessing� Computations involving large data streams
� Radar, Sonar, video compression
�� CommunicationCommunication & & NetworkingNetworking� Switching and information transmission
� Telephone system, Internet, PDA, Cellular Phone
CENG-336 Introduction to Embedded Systems Development 51
CharacteristicsCharacteristics
�� RealReal--Time Time OperationOperation� Reactive: computations must occur in response toexternal events
� Correctness is partially a function of time
�� SmallSmall SizeSize, Low , Low WeightWeight� Hand- held electronics and Transportation applications-- weight costs money
�� Low Low PowerPower� Battery power for 8+ hours (laptops often last only 2 hours)
CENG-336 Introduction to Embedded Systems Development 52
�� HarshHarsh environmentenvironment� Heat, vibration, shock, power fluctuations, RF interference, lightning, corrosion
�� SafetySafety-- criticalcritical operationoperation� Must function correctly and (never functionincorrectly)
�� Extreme Extreme costcost sensitivitysensitivity� $ 0.05 adds up over 1,000,000 units
CharacteristicsCharacteristics
CENG-336 Introduction to Embedded Systems Development 53
Why use microprocessors?Why use microprocessors?
� Microprocessors simplify the design of families of products.
� Microprocessors are often very efficient: can use same logic to perform many different functions, but Microprocessors use much more logic to implement a function than does custom logic.
� Alternatives: field-programmable gate arrays (FPGAs), ASIC’s, custom logic, etc.
� What about MicroControllers or DSP’s….
� Custom logic is a clear winner for low power devices.