L3_IntroToMemoryAndComputing
L3_IntroToMemoryAndComputing
com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Topics
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Topics
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Internal organization of computers
www. Micro Digital Ed. com
BIHE university
• CPU
• Memory
• I/O
– Input
• E.g. Keyboard, Mouse, Sensor
– Output
• E.g. LCD, printer, hands of a robot
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory characteristics
www. Micro Digital Ed. com
BIHE university
• Capacity
– The number of bits that a memory can store.
• E.g. 128 Kbits, 256 Mbits
• Organization
4 bits
– How the locations are organized 0
128 locations
1
• E.g. a 128 x 4 memory 2
…
127
• Access time
– How long it takes to get data from memory
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory Organization
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory Organization
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Semiconductor memories
www. Micro Digital Ed. com
BIHE university
• ROM RAM •
– Mask ROM )Static RAM( SRAM –
– PROM (Programmable )Dynamic RAM( DRAM –
ROM) )Nonvolatile RAM( NV-RAM –
– EPROM (Erasable
PROM)
– EEPROM (Electronic
Erasable PROM)
– Flash EPROM
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\ROM\ Mask ROM
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\ROM\ PROM (Programmable ROM)
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\ROM\ EPROM (Erasable Programmable ROM)
www. Micro Digital Ed. com
BIHE university
• UV-EPROM
– You can shine ultraviolet (UV) radiation
to erase it
– Erasing takes up to 20 minutes
– The entire contents of ROM are erased
– Helps prototyping
Disadvantage – You have to remove it
from board to program it 2764
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\ROM\ EEPROM (Electrically Erasable
www. Micro Digital Ed. com
Programmable ROM) BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\ROM\ Flash ROM
www. Micro Digital Ed. com
BIHE university
• Erased in a Flash
• the entire device is erased at once – But
recent modifications allows to erase in chunk
– It has erase block size
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Semiconductor memories
www. Micro Digital Ed. com
BIHE university
• ROM RAM •
– Mask ROM )Static RAM( SRAM –
– PROM (Programmable )Dynamic RAM( DRAM –
ROM) Nonvolatile ( NV-RAM –
– EPROM (Erasable )RAM
PROM)
– EEPROM (Electronic
Erasable PROM)
– Flash EPROM
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\RAM\ SRAM (Static RAM)
www. Micro Digital Ed. com
BIHE university
– Faster SRAM
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\RAM\ DRAM (Dynamic RAM)
www. Micro Digital Ed. com
BIHE university
• Made of capacitors
• Advantages:
– Less power consumption
– Cheaper
– High capacity
• Disadvantages:
– Slower
– Refresh needed
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Memory\RAM\ NV-RAM (Nonvolatile RAM)
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
To read
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting memory to CPU
www. Micro Digital Ed. com
BIHE university
VCC
GND VCC
8
D0-D7
n
A0-An-1
WE
OE
CS
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting memory
Writing
Reading memory to CPU
to memory
from
www. Micro Digital Ed. com
Address
BIHE university
Address
CS
CS
OE
Data
Data
WE
WE
Time
Time
VCC
GND VCC
8
D0-D7
CPU n
A0-An-1
WE
OE
CS
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting I/Os to CPU
www. Micro Digital Ed. com
BIHE university
Network
CPU Keyboard
Sound Card
Graphic Card
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting I/Os to CPU using bus
www. Micro Digital Ed. com
BIHE university
Address bus
Data bus
Write
Control bus Read
CPU
I/O 0 I/O 1 I/O 2 I/O n
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting I/Os and Memory to CPU
www. Micro Digital Ed. com
BIHE university
Address bus
Data bus
Write
Control bus Read
GND VCC
n
A0-An-1
8
D0-D7
WE
OE
CS
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting I/Os and memory to CPU using bus
www. Micro Digital Ed. com
BIHE university
VCC
0
1
A0-An-1
GND
D0-D7
WE
OE
CS
0
Address bus
Data bus
Write
Control bus Read
CPU
I/O 0 I/O 1 I/O 2 I/O n
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting I/Os and Memory to CPU using bus
www. Micro Digital Ed. com
(Peripheral I/O) BIHE university
VCC
0
1
..
63
A0-An-1
GND
D0-D7
WE
OE
CS
Address bus
Data bus
Write
Control bus Read
IO/MEM
CPU
I/O 0 I/O 1 I/O 2 I/O n
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Connecting I/Os and Memory to CPU using bus
www. Micro Digital Ed. com
(Memory Mapped I/O) BIHE university
VCC
0
1 enables CS
..
How could we make the logic 15
when address is
A0-An-1
GND
D0-D7
circuit? between 0 and
WE
OE
CS
15
Logic circuit
Address bus
Data bus
Solution
Control 1.
bus Write
Write the address range in binary
Read
2. Separate the fixed part of address
3. Using a NAND, design a logic circuit whose output
CPU
activates when the fixed address is given to it.
a7 a6 a5 a4 a3 a2 a1 a0
From address 0 0 0 0 0 0 0 0 0 a4
I/O 16 I/O 17 I/O a5
18 I/OCS
n
To address15 0 0 0 0 1 1 1 1 a6
a7
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Another example for address decoder
www. Micro Digital Ed. com
BIHE university
Solution
1. Write the address range in binary
2. Separate the fixed part of address
3. Design the logic circuit.
a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 a8
a9
From address 300H 0 0 1 1 0 0 0 0 0 0 0 0 a10 CS
a11
To address 3FFH 001111111111
An easy way of
designing
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Internal parts of computers\CPU
www. Micro Digital Ed. com
BIHE university
• Tasks:
– It should execute instructions
• It should recall the instructions one after another
and execute them
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Inside the CPU
www. Micro Digital Ed. com
BIHE university
• PC (Program Counter)
• Instruction decoder
• ALU (Arithmetic Logic Unit)
• Registers
PC A
ALU B
CPU C
D
Instruction decoder
registers
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
How computers work 0 31h
31 A [17]
1 C4h BA
A [6]
www. Micro Digital Ed. com
BIHE university
2 26h
VCC
3 81h
AA+B
[7]A
4 EAh
5 0h
A0-An-1
GND
5h
D0-D7
6
WE
7
OE
CS
Logic circuit
Address bus
Data bus
Write
Control bus Read
ALU
CPU A
B
PC: 10 C
D I/O 16 I/O 17 I/O 18 I/O n
Inst. Dec. registers
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
How computers work 0 31h A [17]
1 C4h BA
A [6]
www. Micro Digital Ed. com
BIHE university
2 26h
VCC
3 81h AA+B
EAh
[7]A
4
5 0h
A0-An-1
GND
5h
D0-D7
6
WE
7
OE
CS
Logic circuit
Address bus 17
Data bus
Write
Control bus Read
ALU
CPU A
B
PC: 1 C 9
31
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
How computers work 0 31h A [17]
1 C4
C4h BA
A [6]
www. Micro Digital Ed. com
BIHE university
2 26
26h
VCC
3 81h AA+B
EAh
[7]A
4
5 0h
A0-An-1
GND
5
5h
D0-D7
6
WE
7
OE
CS
Logic circuit
Address bus 17
6
Data bus
Write
Control bus Read
ALU
CPU 9
A
B
PC: 1
2
3 C
D I/O 16 I/O 17 I/O 18 I/O n
Inst. Dec. registers
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
How computers work 0 31h A [17]
1 C4h BA
A [6]
www. Micro Digital Ed. com
BIHE university
2 26h
VCC
3 81
81h
AA+B
[7]A
4 EA
EAh
5 0h
A0-An-1
GND
5h
D0-D7
6
WE
7
OE
CS
7 Logic circuit
Address bus
Eh
Data bus
Write
Control bus Read
+
ALU
E CPU A
9
B
E
5
PC: 4
35 C
D I/O 16 I/O 17 I/O 18 I/O n
Inst. Dec. registers
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
How Instruction decoder works
www. Micro Digital Ed. com
BIHE university
Instruction
Instruction
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Von Neumann vs. Harvard architecture
www. Micro Digital Ed. com
BIHE university
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.