Computer Memory Types

 
Chapter 2: Memory
 
CEG2400 – Embedded System Design
 
CEG2400 Ch2. Memory V6a
 
1
 
Overview
 
1) Memory in  a computer system
2) Different memory types
3) Concepts of address, data and program
running
 
CEG2400 Ch2. Memory V6a
 
2
 
1) Memory in  a computer system
 
A computer has
CPU (Central Processing Unit)
Memory
Input/output and peripheral devices
Glue logic circuits
 
CEG2400 Ch2. Memory V6a
 
3
 
Inside an ARM microcontroller
 
Inside ARM
 
CEG2400 Ch2. Memory V6a
 
4
CPU: Central
Processing unit
memory
 
Peripheral devices: serial, parallel interfaces;  real-time-clock etc.
Clock
Oscillator
Peripheral devices: USB, serial,
parallel bus etc.
 
A computer with a micro-controller
unit
 
 
CEG2400 Ch2. Memory V6a
 
5
 
CPU:
Central
Process-
ing unit
memory
 
Peripheral devices:
USB ports, Graphic
card, real-time-clock
etc.
Keyboard
mouse
Sensors:
Light,
Temperature
Etc.
actuators :
such as
Motors,
Heaters,
speakers
 
 
External
interfacing
Periphera
l IO
interface
devices:
such as
USB bus,
parallel
bus,
RS232
etc.
MCU:
 
CPU, MCU are microprocessors
 
CPU: Central Processing unit
Requires memory and input output system to
become  a computer (e.g. Pentium is a CPU).
MCU: micro-controller unit (or single chip
computer)
Contains memory, input output systems, can work
independently (e.g. Arm7, 8051 are MCUs).
Used in embedded systems such as washing
machines, mobile phones/pads.
 
CEG2400 Ch2. Memory V6a
 
6
 
2) Different memory types
 
Random access memory (RAM)
Read only memory (ROM)
 
CEG2400 Ch2. Memory V6a
 
7
 
Different kinds of Random access Memory
 (RAM)
 
Random access memory (RAM): data will
disappear after power down.
Static RAM (SRAM): each bit is a flip-flop, fast but
expensive.
 
 
 
 
Dynamic RAM (DRAM): each bit is a small capacitor,
and is needed to be recharged regularly; slower but
cheap. To be used as primary memory in a computer.
 
CEG2400 Ch2. Memory V6a
 
8
 
http://thalia.spec.gmu.edu/~pparis/classes/notes_101/img111.gif
http://www.prontotech.com/product/kingston-8gb-dram-memory-module-p_1732875237
 
Different kinds of Read Only Memory
 (ROM)
 
Read only memory (ROM)
UV-EPROM
EEPROM
FLASH ROM
 
CEG2400 Ch2. Memory V6a
 
9
 
UV-EPROM
 
Data can be erased
by putting it under
strong Ultra-Violet
(UV) light for 1/2
hours.
 
CEG2400 Ch2. Memory V6a
 
10
 
Flash memory
 
Block based read/write, e.g. one block can be
512 or 1024  bytes, etc.
Read/write is slower than DRAM, so it cannot
be used as the primary memory of a
computer.
 
CEG2400 Ch2. Memory V6a
 
11
 
www.sandisk.com
 
Exercise 0
 
What are these memory types: (DRAM, SRAM,
ROM) in a computer? Explain why.
 
CEG2400 Ch2. Memory V6a
 
12
Central Processing Unit
CPU
Registers: memory type = _______?
Primary memory
for storing program
and data: memory
type=______?
Firmware (
basic input/output
system
 or 
BIOS
 )
memory type=___________?
Registers 暫存器
 
3) Concepts of address, data and
program running
 
Address-- tells you where
to find the storage.
Data-- is the content stored
in the address.
 
CEG2400 Ch2. Memory V6a
 
13
 
Exercise 1:
Binary number and
hex number
 
A binary number  can be 1 or 0
4 binary numbers make up a
hexadecimal (hex) number (0-
>F)
Exercise1
Convert 3AH into binary .
Convert a binary number
100001011100B into hex and
decimal.
 
CEG2400 Ch2. Memory V6a
 
14
 
Memory is like a tall building
Address cannot change; content (data) can change
 
Address content, e.g. A 64K-byte RAM
 
CEG2400 Ch2. Memory V6a
 
15
 
Memory for storing
program and data
(An 8-bit machine)
 
Basic concept
Memory is like a tall building
Address cannot change; content (data) can
change
 
CEG2400 Ch2. Memory V6a
 
16
 
After power up , goto 0000H , run
instructions in data
 
Two important modules in a 8-bit CPU (because data is 8-bit,
e.g. Intel 8051):
Program counter and registers
 
A 
C
entral 
P
rocessing 
U
nit (CPU) has
PC : program counter to keep track the program
R0, R1, etc, for general purpose usage
 
CEG2400 Ch2. Memory V6a
 
17
Memory
(data is 8-bit)
 
An 8-bit 
CPU (Intel 8051)
 
Program counter (PC)
 
After CPU reset (power up) , PC=0000H, so the
first instruction is always at 0000H.
After each instruction is run,
PC increments once, or
PC is set by the instruction it just executed. E.g.
goto to a new address.
 
CEG2400 Ch2. Memory V6a
 
18
 
How does a computer work?
What is the content of Program counter (PC) after each step?
 
Program is in memory
 
CEG2400 Ch2. Memory V6a
 
19
 
After power up
PC=0000H
 
step1
 
step2
 
step3
 
Inside a
n 8-bit 
C
entral 
P
rocess.
U
nit
 
Exercise2 : A simple program , fill in ‘?’
 
After power up, the first instruction is in 0000H, PC=0000H
 
CEG2400 Ch2. Memory V6a
 
20
 
 
Exercise 3: Program to find 2+3=?,
Fill in ‘?’
 
 PC=program counter; R0=general purpose register 0
 
CEG2400 Ch2. Memory V6a
 
21
 
Memory in a 32-bit machine
 
Moving from 8-bit to 32-bit:
The ARM processor example
 
CEG2400 Ch2. Memory V6a
 
22
 
ARM
 chip
 
 
CEG2400 Ch2. Memory V6a
 
23
 
Memory
 
We will learn how to use memory in the ARM
microcontroller.
We know that the data size is 8-bit for all
memory systems (in PC or mainframe alike).
So each location has 8 bits.
We can deal with them in n-bit groups called 
words
(typically 8, 16, 32 or 64 bits)
 
CEG2400 Ch2. Memory V6a
 
24
 
Address in a 32-bit machine (e.g.
ARM7)
 
The address is 32-bit.
So the address range is from 0000 0000(hex) to FFFF FFFF(hex)
totally 2^32=4G locations.
The data is also 32-bit.
So each data is xxxx xxxx (hex)
But the memory is arranged as 8-bit for one location. So
how to do it?
Solution: Arm7 uses 4 address locations to access a 32-
bit (4 bytes) data.
 
CEG2400 Ch2. Memory V6a
 
25
 
Rules/Examples
 
Each location
must be 8-bit.
For a 32-bit
word, you are
referring to 4
locations.
 
CEG2400 Ch2. Memory V6a
 
26
A 16-bit
word
(0000 0002-
>
0000
0003H)
One byte
at
0000 0000H
One byte
At
0000 0001H
 
32-bit
Word
(0000 000 ->
0000 0003H)
 
Address
 
data
 
Organization of memory in ARM
 
CEG2400 Ch2. Memory V6a
 
27
 
second 32-bit word
 
First 32-bit  word
 
n
 
 =32bits (4 bytes)
 
last 32-bit word
 
i
 
 th word
 
 
 
 
 
 
0x0000 0010
0x0000 000C
0x0000 0008
0x0000 0004
0x0000 0000
 
Address
0xFFFF FFFC
0xFFFF FFF8
 
1Byte    1 Byte  1 Byte    1 Byte
 
n
 
 =32bits (4 bytes)
 
Address is
incremented by 4
 
Compare 8-bit (e.g.8051) and 32-
bit (Arm7) machines
 
examples
 
CEG2400 Ch2. Memory V6a
 
28
 
Address is incremented by 4
 
Address is incremented by 1
 
Integers and Characters
 
CEG2400 Ch2. Memory V6a
 
29
 
Exercise 4:
More/less significant bytes
 
Consider the hexadecimal (base 16) 32-bit number
12342A3F(H)=1x16
7
+2x16
6
+3x16
5
+4x16
4
+2x16
3
+10x16
2
+3x16
1
+15x16
0
This number has four bytes 12, 34, 2A, 3F (4x8=32-bits)
Bytes/bits with higher weighting are “more significant” e.g. the byte 34
is more significant than 2A
Bytes/bits with lower weighting are “less significant”
We also use terms “most significant byte/bit” and “least significant
byte/bit”
Excise4: For 12342A3F(H)
Write the binary number.
What is the most significant byte/bit?
What is the least significant byte/bit?
 
 
CEG2400 Ch2. Memory V6a
 
30
 
Big/little endian
 
Two different ways: byte addresses are
assigned across words
more significant bytes first (big endian)
less significant bytes first (little endian)
ARM allows both big and little endian
addresses
LPC2100 
allows big and small 
endian
s
 
CEG2400 Ch2. Memory V6a
 
31
 
Examples
From 
http://en.wikipedia.org/wiki/Endianness
 
more significant bytes first (big endian)
less significant bytes first (little endian)
 
CEG2400 Ch2. Memory V6a
 
32
 
Most significant
 
least significant
 
Exercise 5, fill in ‘?’
 
Save 0x2EAB057E in memory starting from 0x4000
 
CEG2400 Ch2. Memory V6a
 
33
 
Word alignment
 
32-bit words align naturally at addresses 0, 4, 8 …
These are aligned addresses
Unaligned accesses are either not allowed or slower e.g. read a 32-bit
word from address 1 (why?)
E.g 
0x2EAB057E from 0x4000 is aligned
E.g 
0x2EAB057E from 0x4001 is misaligned
In ARM
A word = 32-bits, half-word = 16 bits
Words aligned on 4-byte boundaries i.e. word addresses must be
multiples of 4
Half words aligned on even byte boundaries
 
CEG2400 Ch2. Memory V6a
 
34
 
Example of word alignment
 
32-bit words align naturally at
addresses 0, 4, 8..etc
That means 
a (address)
=
0,4,8,… or
a(address)
=4N where
N=integer
a is a multiple of N
 
 
CEG2400 Ch2. Memory V6a
 
35
 
End
 
 
CEG2400 Ch2. Memory V6a
 
36
 
References/ reading exercise
 
http://www.howstuffworks.com/computer-
memory.htm
ARM versus Intel: a successful stratagem for
RISC or grist for CISC's tricks?
http://www.edn.com/design/integrated-circuit-design/4369610/ARM-versus-
Intel-a-successful-stratagem-for-RISC-or-grist-for-CISC-s-tricks-
 
CEG2400 Ch2. Memory V6a
 
37
Slide Note
Embed
Share

This chapter delves into the intricacies of memory in computer systems, exploring different types of memory, concepts of address, data, and program execution. Learn about the components inside a computer, ARM microcontrollers, and the role of CPU and MCU as microprocessors. Discover the various memory types like RAM and ROM, their characteristics, and usage in embedded systems. Uncover the distinctions between SRAM and DRAM, highlighting their strengths and weaknesses for primary memory applications.

  • Computer memory
  • Memory types
  • Address
  • Data
  • Program execution

Uploaded on Feb 23, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Chapter 2: Memory CEG2400 Embedded System Design CEG2400 Ch2. Memory V6a 1

  2. Overview 1) Memory in a computer system 2) Different memory types 3) Concepts of address, data and program running CEG2400 Ch2. Memory V6a 2

  3. 1) Memory in a computer system A computer has CPU (Central Processing Unit) Memory Input/output and peripheral devices Glue logic circuits CEG2400 Ch2. Memory V6a 3

  4. Inside an ARM microcontroller Inside ARM CPU: Central Processing unit Clock Oscillator memory Peripheral devices: serial, parallel interfaces; real-time-clock etc. Peripheral devices: USB, serial, parallel bus etc. CEG2400 Ch2. Memory V6a 4

  5. A computer with a micro-controller unit External interfacing MCU: CPU: Central Process- ing unit memory actuators : such as Motors, Heaters, speakers Periphera l IO interface devices: such as USB bus, parallel bus, RS232 etc. Keyboard mouse Peripheral devices: USB ports, Graphic card, real-time-clock etc. Sensors: Light, Temperature Etc. CEG2400 Ch2. Memory V6a 5

  6. CPU, MCU are microprocessors CPU: Central Processing unit Requires memory and input output system to become a computer (e.g. Pentium is a CPU). MCU: micro-controller unit (or single chip computer) Contains memory, input output systems, can work independently (e.g. Arm7, 8051 are MCUs). Used in embedded systems such as washing machines, mobile phones/pads. CEG2400 Ch2. Memory V6a 6

  7. 2) Different memory types Random access memory (RAM) Read only memory (ROM) CEG2400 Ch2. Memory V6a 7

  8. Different kinds of Random access Memory (RAM) Random access memory (RAM): data will disappear after power down. Static RAM (SRAM): each bit is a flip-flop, fast but expensive. Dynamic RAM (DRAM): each bit is a small capacitor, and is needed to be recharged regularly; slower but cheap. To be used as primary memory in a computer. http://thalia.spec.gmu.edu/~pparis/classes/notes_101/img111.gif http://www.prontotech.com/product/kingston-8gb-dram-memory-module-p_1732875237 CEG2400 Ch2. Memory V6a 8

  9. Different kinds of Read Only Memory (ROM) Read only memory (ROM) UV-EPROM EEPROM FLASH ROM CEG2400 Ch2. Memory V6a 9

  10. UV-EPROM Data can be erased by putting it under strong Ultra-Violet (UV) light for 1/2 hours. CEG2400 Ch2. Memory V6a 10

  11. Flash memory Block based read/write, e.g. one block can be 512 or 1024 bytes, etc. Read/write is slower than DRAM, so it cannot be used as the primary memory of a computer. www.sandisk.com CEG2400 Ch2. Memory V6a 11

  12. Exercise 0 What are these memory types: (DRAM, SRAM, ROM) in a computer? Explain why. Central Processing Unit Registers Primary memory for storing program and data: memory type=______? CPU Registers: memory type = _______? Firmware (basic input/output system or BIOS ) memory type=___________? CEG2400 Ch2. Memory V6a 12

  13. 3) Concepts of address, data and program running Address-- tells you where to find the storage. Data-- is the content stored in the address. CEG2400 Ch2. Memory V6a 13

  14. Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F Exercise 1: Binary number and hex number A binary number can be 1 or 0 4 binary numbers make up a hexadecimal (hex) number (0- >F) Exercise1 Convert 3AH into binary . Convert a binary number 100001011100B into hex and decimal. CEG2400 Ch2. Memory V6a 14

  15. Memory is like a tall building Address cannot change; content (data) can change Address content, e.g. A 64K-byte RAM 16-bit Address (H=Hex) FFFF H 35H FFFE H 23H 0ACD H 24H 0001 H 32H 0000 H 2BH 8-bit content (data) CEG2400 Ch2. Memory V6a 15

  16. Memory for storing program and data (An 8-bit machine) 16-bit Address (H=Hex) FFFF H FFFE H 0ACD H 8-bit content (program /data) 35H 23H 24H (do something) 32H 2BH (goto 0ACDH) Basic concept Memory is like a tall building Address cannot change; content (data) can change 0001 H 0000 H After power up , goto 0000H , run instructions in data CEG2400 Ch2. Memory V6a 16

  17. Two important modules in a 8-bit CPU (because data is 8-bit, e.g. Intel 8051): Program counter and registers A Central Processing Unit (CPU) has PC : program counter to keep track the program R0, R1, etc, for general purpose usage An 8-bit CPU (Intel 8051) Registers (8 bits): PC: program counter Memory (data is 8-bit) R0 (general purpose) R1 (general purpose) CEG2400 Ch2. Memory V6a 17

  18. Program counter (PC) After CPU reset (power up) , PC=0000H, so the first instruction is always at 0000H. After each instruction is run, PC increments once, or PC is set by the instruction it just executed. E.g. goto to a new address. CEG2400 Ch2. Memory V6a 18

  19. How does a computer work? What is the content of Program counter (PC) after each step? 16-bit Address (H=Hex) FFFF H FFFE H 0ACD H 8-bit content (data) 35 23 24 (goto FFFF) 32 2B (goto0ACD) Program is in memory Inside an 8-bit Central Process.Unit Program counter (16 bits): PC xxxxH step3 General purpose registers ( 8bits): R0=xxH R1=yyH etc. 0001 H 0000 H step2 After power up PC=0000H step1 CEG2400 Ch2. Memory V6a 19

  20. Exercise2 : A simple program , fill in ? After power up, the first instruction is in 0000H, PC=0000H Address (H=Hex) 8-bit content (data)=instructions (Hex) PC before Running the instruction (hex) ? PC after Running the instruction (hex) ? 0BC8 Instruction k = 25: (meaning R0<=R0+1) Instruction j = 24 (meaning :goto 0BC8) Instruction 2=xx Instruction1=2B (meaning : goto 0AC0H) 0AC1 0AC0 ? ? 0001 0000 ? ? CEG2400 Ch2. Memory V6a 20

  21. Exercise 3: Program to find 2+3=?, Fill in ? PC=program counter; R0=general purpose register 0 Address (H=Hex) 8-bit content (data) The machine code is make up for this example Before the instruction is run After the instruction is run PC R0 PC R0 0F00 What is the Content after the program is run? 0AD3 3F=stop 0AD3 ? ? ? 0AD2 C0=Save R0 into address location 0F00 and clear R0 0AD2 ? ? ? 0AD1 2E=Add 2 to Reg .R0 0AD1 ? ? ? 0AD0 15=Move 3 into Reg. R0 0AD0 ? ? ? 0001 0000 2B=Goto address 0AD0 0000 0 (after reset) ? ? CEG2400 Ch2. Memory V6a 21

  22. Memory in a 32-bit machine Moving from 8-bit to 32-bit: The ARM processor example CEG2400 Ch2. Memory V6a 22

  23. ARM chip CEG2400 Ch2. Memory V6a 23

  24. Memory We will learn how to use memory in the ARM microcontroller. We know that the data size is 8-bit for all memory systems (in PC or mainframe alike). So each location has 8 bits. We can deal with them in n-bit groups called words (typically 8, 16, 32 or 64 bits) CEG2400 Ch2. Memory V6a 24

  25. Address in a 32-bit machine (e.g. ARM7) The address is 32-bit. So the address range is from 0000 0000(hex) to FFFF FFFF(hex) totally 2^32=4G locations. The data is also 32-bit. So each data is xxxx xxxx (hex) But the memory is arranged as 8-bit for one location. So how to do it? Solution: Arm7 uses 4 address locations to access a 32- bit (4 bytes) data. CEG2400 Ch2. Memory V6a 25

  26. Rules/Examples Address data Each location must be 8-bit. For a 32-bit word, you are referring to 4 locations. 0000 0003H A 16-bit word (0000 0002- > 0000 0003H) 0000 0002H 32-bit Word (0000 000 -> 0000 0003H) 0000 0001H One byte At 0000 0001H 0000 0000H One byte at 0000 0000H CEG2400 Ch2. Memory V6a 26

  27. Organization of memory in ARM n=32bits (4 bytes) Address 0xFFFF FFFC 0xFFFF FFF8 last 32-bit word ith word 0x0000 0010 0x0000 000C 0x0000 0008 0x0000 0004 0x0000 0000 second 32-bit word 1Byte 1 Byte 1 Byte 1 Byte First 32-bit word n=32bits (4 bytes) Address is incremented by 4 CEG2400 Ch2. Memory V6a 27

  28. Compare 8-bit (e.g.8051) and 32- bit (Arm7) machines examples A 32-bit machine program (e.g. ARM) An 8-bit machine program (e.g. 8051) Address (H=Hex) Address (H=Hex) 1E00 0ADC 1E00 0AD8 1E00 0AD4 1E00 0AD0 : 0000 0008 0000 0004 0000 0000 Address is incremented by 4 Each data is 32-bit (4 bytes) 1123 556D 0012 2A3F 2134 5678 3A11 89A1 Each data is 8-bit (1 byte) 13 : 21 22 89 4A 2D 0F00 : 0AD2 0AD1 0AD0 0001 0000 Address is incremented by 1 1122 3344 9870 A178 0000 002A CEG2400 Ch2. Memory V6a 28

  29. Integers and Characters 32 bits b31b30 b1 b0 for positive numbers for negative numbers Sign bit: b31 b31 = = 0 1 (a) A signed integer 8 bits 8 bits 8 bits 8 bits ASCII ASCII ASCII ASCII character character character character (b) Four characters CEG2400 Ch2. Memory V6a 29

  30. Exercise 4: More/less significant bytes Consider the hexadecimal (base 16) 32-bit number 12342A3F(H)=1x167+2x166+3x165+4x164+2x163+10x162+3x161+15x160 This number has four bytes 12, 34, 2A, 3F (4x8=32-bits) Bytes/bits with higher weighting are more significant e.g. the byte 34 is more significant than 2A Bytes/bits with lower weighting are less significant We also use terms most significant byte/bit and least significant byte/bit Excise4: For 12342A3F(H) Write the binary number. What is the most significant byte/bit? What is the least significant byte/bit? CEG2400 Ch2. Memory V6a 30

  31. Big/little endian Two different ways: byte addresses are assigned across words more significant bytes first (big endian) less significant bytes first (little endian) ARM allows both big and little endian addresses LPC2100 allows big and small endians CEG2400 Ch2. Memory V6a 31

  32. Examples From http://en.wikipedia.org/wiki/Endianness more significant bytes first (big endian) less significant bytes first (little endian) Most significant least significant CEG2400 Ch2. Memory V6a 32

  33. Exercise 5, fill in ? Save 0x2EAB057E in memory starting from 0x4000 Address (data in each address location must be 8-bit) 0x4000 0x4001 0x4002 0x4003 Little endian data Big endian data 7E ? ? ? ? ? ? 7E CEG2400 Ch2. Memory V6a 33

  34. Word alignment 32-bit words align naturally at addresses 0, 4, 8 These are aligned addresses Unaligned accesses are either not allowed or slower e.g. read a 32-bit word from address 1 (why?) E.g 0x2EAB057E from 0x4000 is aligned E.g 0x2EAB057E from 0x4001 is misaligned In ARM A word = 32-bits, half-word = 16 bits Words aligned on 4-byte boundaries i.e. word addresses must be multiples of 4 Half words aligned on even byte boundaries CEG2400 Ch2. Memory V6a 34

  35. Example of word alignment 32-bit words align naturally at addresses 0, 4, 8..etc That means a (address)= 0,4,8, or a(address)=4N where N=integer a is a multiple of N CEG2400 Ch2. Memory V6a 35

  36. End CEG2400 Ch2. Memory V6a 36

  37. References/ reading exercise http://www.howstuffworks.com/computer- memory.htm ARM versus Intel: a successful stratagem for RISC or grist for CISC's tricks? http://www.edn.com/design/integrated-circuit-design/4369610/ARM-versus- Intel-a-successful-stratagem-for-RISC-or-grist-for-CISC-s-tricks- CEG2400 Ch2. Memory V6a 37

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#