Download presentation
Presentation is loading. Please wait.
Published byHilary Franklin Modified over 8 years ago
1
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Introduction to Computing Chapter 0 The AVR microcontroller and embedded systems using assembly and c
2
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.Topics Internal organization of computers –The different parts of a computer I/O Memory CPU –Connecting the different parts Connecting memory to CPU Connecting I/Os to CPU –How computers work
3
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Internal organization of computers CPU Memory I/O –Input E.g. Keyboard, Mouse, Sensor –Output E.g. LCD, printer, hands of a robot
4
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved.Memory Everything that can store, retain, and recall information. –E.g. hard disk, a piece of paper, etc.
5
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory characteristics Capacity –The number of bits that a memory can store. E.g. 128 Kbits, 256 Mbits Organization –How the locations are organized E.g. a 128 x 4 memory has 128 locations, 4 bits each Access time –How long it takes to get data from memory … 4 bits 128 locations 0 1 2 127
6
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Historical context Once upon a time, computer professionals noticed that 2 10 was very nearly equal to 1000 and started using the SI prefix "kilo" to mean 1024. That worked well enough for a decade or two because everybody who talked kilobytes knew that the term implied 1024 bytes. But, almost overnight a much more numerous "everybody" bought computers, and the trade computer professionals needed to talk to physicists and engineers and even to ordinary people, most of whom know that a kilometre is 1000 meters and a kilogram is 1000 grams. Then data storage for gigabytes, and even terabytes, became practical, and the storage devices were not constructed on binary trees, which meant that, for many practical purposes, binary arithmetic was less convenient than decimal arithmetic. The result is that today "everybody" does not "know" what a megabyte is. When discussing computer memory, most manufacturers use megabyte to mean 2 20 = 1 048 576 bytes, but the manufacturers of computer storage devices usually use the term to mean 1 000 000 bytes. Some designers of local area networks have used megabit per second to mean 1 048 576 bit/s, but all telecommunications engineers use it to mean 10 6 bit/s. And if two definitions of the megabyte are not enough, a third megabyte of 1024 000 bytes is the megabyte used to format the familiar 90 mm (3 1/2 inch), "1.44 MB" diskette. The confusion is real, as is the potential for incompatibility in standards and in implemented systems.
7
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Prefixes for binary multiples In December 1998 the International Electrotechnical Commission (IEC), the leading international organization for worldwide standardization in electrotechnology, approved as an IEC International Standard names and symbols for prefixes for binary multiples for use in the fields of data processing and data transmission. In computing, a binary prefix is a specifier or mnemonic that is prepended to the units of digital information, the bit and the byte, to indicate multiplication by a power of 2. In practice the powers used are multiples of 10, so the prefixes denote powers of 1024 = 2 10.unitsbitbytepower The computer industry uses terms such as kilobyte, megabyte, and gigabyte, and corresponding symbols KB, MB, and GB, in two different ways. For example, in citations of main memory or RAM capacity, gigabyte customarily means 1073741824 bytes. This is a power of 2, specifically 2 30, therefore this usage is referred to as a binary unit or binary prefix.power of 2
8
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Binary Prefix Prefixes for binary multiples Value Pronunciation Prefix OriginDerivation 2 10 kibiKi kilobinary: (2 10 ) 1 kilo: (10 3 ) 1 2 20 mebiMi megabinary: (2 10 ) 2 mega: (10 3 ) 2 2 30 gibiGi gigabinary: (2 10 ) 3 giga: (10 3 ) 3 2 40 tebiTi terabinary: (2 10 ) 4 tera: (10 3 ) 4 2 50 pebiPi petabinary: (2 10 ) 5 peta: (10 3 ) 5 2 60 exbiEi exabinary: (2 10 ) 6 exa: (10 3 ) 6
9
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Decimal Prefix ValuePrefixPronunciation 1000Kkilo 1000 2 Mmega 1000 3 Ggiga 1000 4 Ttera 1000 5 Ppeta 1000 6 Eexa 1000 7 Zzetta 1000 8 Yyotta
10
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Prefixes in Industry In most other contexts, the industry uses kilo, mega, giga, etc., in a manner consistent with their meaning in the International System of Units (SI): as powers of 1000. For example, a 500 gigabyte hard drive holds 500000000000 bytes, and a 100 megabit per second Ethernet connection transfers data at 100000000 bit/s.International System of Units As of 2011 the adoption of the IEC International Standard names and symbols for prefixes for binary multiples for use in the fields of data processing and data transmission has been slow and usage has been limited in the marketplace and in the press.
11
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Reality About Binary and Decimal Prefix Faced with this reality, the IEEE Standards Board decided that IEEE standards will use the conventional, internationally adopted, definitions of the SI prefixes. Mega will mean 1 000 000, except that the base- two definition may be used (if such usage is explicitly pointed out on a case-by-case basis) until such time that prefixes for binary multiples are adopted by an appropriate standards body. In our SEE 3223 course we will use the binary prefix
12
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. The reality of Binary Prefix Implementation The original Decimal Is adopted as Binary Prefix in most Computing books/manuals Prefix Value Pronunciation (as from derivation) K 1024kilo M 1024 2 mega G 1024 3 giga T 1024 4 tera P 1024 5 peta E 1024 6 exa Z 1024 7 zetta Y 1024 8 yotta
13
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Semiconductor memories RAM –SRAM (Static RAM) –DRAM (Dynamic RAM) –NV-RAM (Nonvolatile RAM) ROM –Mask ROM –PROM ( Programmable ROM) –EPROM (Erasable PROM) –EEPROM (Electronic Erasable PROM) –Flash EPROM
14
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\ROM\ Mask ROM Programmed by the IC manufacturer
15
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\ROM\ PROM (Programmable ROM) OTP (One-Time Programmable) –You can program it only once
16
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\ROM\ EPROM (Erasable Programmable ROM) UV-EPROM –You can shine ultraviolet (UV) radiation to erase it –Erasing takes up to 20 minutes –The entire contents of ROM are erased 2764
17
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\ROM\ EEPROM (Electrically Erasable Programmable ROM) Erased Electrically –Erased instantly –Each byte can be erased separately
18
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\ROM\ Flash ROM Erased in a Flash the entire device is erased at once
19
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Semiconductor memories RAM –SRAM (Static RAM) –DRAM (Dynamic RAM) –NV-RAM (Nonvolatile RAM) ROM –Mask ROM –PROM ( Programmable ROM) –EPROM (Erasable PROM) –EEPROM (Electronic Erasable PROM) –Flash EPROM
20
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\RAM\ SRAM (Static RAM) Made of flip-flops (Transistors) Advantages: –Faster –No need for refreshing Disadvantages: –High power consumption –Expensive 2K x 8 SRAM
21
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\RAM\ DRAM (Dynamic RAM) Made of capacitors Advantages: –Less power consumption –Cheaper –High capacity Disadvantages: –Slower –Refresh needed
22
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Memory\RAM\ NV-RAM (Nonvolatile RAM) Made of SRAM, Battery, control circuitry Advantages: –Very fast –Infinite program/erase cycle –Non-volatile Disadvantage: –Expensive
23
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Review Questions
24
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Review Questions (Cont’d)
25
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Internal parts of computers\ CPU Tasks: –It should execute instructions It should recall the instructions one after another and execute them
26
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting memory to CPU Memory pin out
27
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting memory to CPU Address Data WE Time CS Writing to memory Address Data WE Time CS Reading from memory OE
28
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting I/Os to CPU CPU should have lots of pins! MouseKeyboard Graphic CardSound Card Network CPU
29
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting I/Os to CPU using bus CPU I/O 0 Address bus Data bus Control bus I/O 1 I/O 2 I/O n Write Read
30
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting I/Os and Memory to CPU CPU I/O 0 Address bus Data bus Control bus I/O 1 I/O 2 I/O n Write Read
31
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting I/Os and memory to CPU using bus CPU I/O 0 Address bus Data bus Control bus I/O 1 I/O 2 I/O n Write Read 01230123 0 How could we manage it?
32
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting I/Os and Memory to CPU using bus (Peripheral I/O) CPU Address bus Data bus Control bus Write Read 0 1.. 63 IO/MEM I/O 0 I/O 1 I/O 2 I/O n
33
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Connecting I/Os and Memory to CPU using bus (Memory Mapped I/O) CPU I/O 16 Address bus Data bus Control bus I/O 17 I/O 18 I/O n Write Read 0 1.. 15 Logic circuit The logic circuit enables CS when address is between 0 and 15 How could we make the logic circuit? Solution 1. Write the address range in binary 0 0 0 0 0 0 0 0 1 1 1 1 From address 0 To address15 2. Separate the fixed part of address 3. Using a NAND, design a logic circuit whose output activates when the fixed address is given to it. a7a6a5 a4 a3 a2a1a0 a5 a6 a4 a7 CS
34
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Another example for address decoder Design an address decoder for address of 300H to 3FFH. Solution 1. Write the address range in binary 2. Separate the fixed part of address 3. Design the logic circuit. a9 a10 a8 a11 CS 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 From address 300H To address 3FFH a7a6a5 a4 a3 a2a1a0 a11 a10a9a8 0 0 1 1 a11 a10 a9 a8 An easy way of designing An easy way of designing
35
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Exercise (refer Figure 0-16) 1.Is the memory device a RAM or ROM? 2.What is the size of the device? 3.What is the base address of the device? 4.Modify the circuit such that the base address starts at C000H
36
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Figure 0-16
37
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Exercise (refer Figure 0-19) 1.Is the memory device a RAM or ROM? 2.What is the size of the device? 3.What is the base address of the device 4.Modify the circuit such that the base address starts at C000H
38
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Figure 0-19
39
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Inside the CPU PC (Program Counter) Instruction decoder ALU (Arithmetic Logic Unit) Registers CPU PC ALU B A D C registers Instruction decoder
40
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Operation of a Processor While (in operation) Fetch instruction pointed by PC Increment PC to point to next Instruction Decode Instruction Load 1 st Operand (if any) Load 2 nd Operand (if any) Execute Instruction End While
41
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. How computers work CPU ALU B A D C registers Inst. Dec. I/O 16 I/O 17 I/O 18 I/O n Logic circuit PC: 0 1 Address bus Data bus Control bus Write Read 0 0123456701234567 31h C4h 26h 81h EAh 0h 5h 31 A [17] B A A [6] A A+B [7] A
42
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. How computers work CPU ALU B A D C registers Inst. Dec. I/O 16 I/O 17 I/O 18 I/O n Logic circuit PC: 1 Address bus Data bus Control bus Write Read 0123456701234567 31h C4h 26h 81h EAh 0h 5h 31 A [17] B A A [6] A A+B [7] A 17 9
43
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. How computers work CPU ALU B A D C registers Inst. Dec. I/O 16 I/O 17 I/O 18 I/O n Logic circuit PC: 1 2 Address bus Data bus Control bus Write Read 1 0123456701234567 31h C4h 26h 81h EAh 0h 5h C4 A [17] B A A [6] A A+B [7] A 17 99 2 26 3 6 5
44
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. How computers work CPU ALU B A D C registers Inst. Dec. I/O 16 I/O 17 I/O 18 I/O n Logic circuit PC: Address bus Data bus Control bus Write Read 0123456701234567 31h C4h 26h 81h EAh 0h 5h A [17] B A A [6] A A+B [7] A 5 9 81 3 3 4 5 9 + E 4 EA E 7 Eh 5
45
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. How Instruction decoder works Opcode Operand Instruction Opcode Operand Instruction Operation CodeMeaning 000A x 001A [x] 010A A – register (x) 011A A + x 100A A + register (x) 101A A – x 110Register (x H ) Register (x L ) 111[x] A 0123456701234567 31h C4h 26h 81h EAh 0h 5h A [17] B A A [6] A A+B [7] A 0011 0001 1100 0100 0010 0110 1000 0001 1110 1010 0000 0000 0101 17 = 10001b
46
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Von Neumann vs. Harvard architecture Von Neumann architecture Address bus Data bus Control bus Address bus Data bus Control bus CPU Address bus Data bus Control bus Data Memory Code Memory Harvard architecture CPU Code Memory Data Memory
47
www. Micro Digital Ed. com BIHE university AVR Microcontroller and Embedded System Using Assembly and C Mazidi, Naimi, and Naimi © 2011 Pearson Higher Education, Upper Saddle River, NJ 07458. All Rights Reserved. Review Questions
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.