Main Memory Organisation – Learning Objectives
Total Page:16
File Type:pdf, Size:1020Kb
17/10/2011 Main Memory Organisation – Learning Objectives" !# At the end of this lecture you will:" !# Understand the main concepts of memory organisation" Main Memory Organisation !# Know the different memory hardware options" " !# Registers, cache, RAM, Disk" !# Understand the relationship between cost and speed of access" !# Understand byte ordering in words" !# Understand the concept of addressing" Eddie Edwards" !# Understand word and byte addressing" [email protected]" !# Understand how RAM memory is organised into chips and modules" " !# Comprehend high order and low order interleaving and their uses" http://www.doc.ic.ac.uk/~eedwards/compsys" Computer Systems – Architecture E Edwards Main Memory Organisation (2.1) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.2) ! Question" Memories" !# Memories hold binary values. These can be:! !# Do you have a laptop or internet device here?" ! A yes B no C what$s a laptop D where is here? " Data (e.g. Integers, Reals, Characters)%" ! E none of the above" CPU Instructions (i.e. Computer Programs)! ! Memory Addresses (“Pointers” to data or instructions)%" " "" !# The contents of a memory remain unchanged unless overwritten with a new binary value. For some memories the contents are "lost" when power to the memory is turned off.! ! " Computer Systems – Architecture E Edwards Main Memory Organisation (2.3) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.4) ! 1 17/10/2011 Examples" CPU Organisation" !# CPU " Registers! " CPU Main Memory Caches – L1, L2 [L3]! " Registers " Control " RAM RAM !# Motherboard Unit Arithmetic & Logic Unit (ALU) ! RAM (Random Access Memory)! ROM (Read Only Memory)! Caches! Input/Output Controllers I/O Registers & Buffers! Videocard Memory! " !# Storage Devices Hard Disk Mouse, Keyboard Ethernet Speakers, Hard Disks, CDs, DVDs, Tapes, DVD Drive Monitor, Printer, Modem Microphone, Memory Sticks, Flashcards" Memory Stick Scanner Wifi Camera, Game Bluetooth Devices GSM/GPRS Computer Systems – Architecture E Edwards Main Memory Organisation (2.5) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.6) ! 3 Types of Memory" Capacity" CPU Main Memory CPU Main Memory Registers RAM Registers RAM Semi-conductor Semi-conductor < 2 KB 256 MB to 8 GB+ (Fixed) ! (Expandable) ! 1 KB = 210 bytes 1 MB = 220 bytes Hard Disk Hard Disk 1 GB = 230 bytes Storage Device Magnetic Storage Device 250 GB to 2 TB+ (Expandable) ! 1TB = 240 bytes Computer Systems – Architecture E Edwards Main Memory Organisation (2.7) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.8) ! 2 17/10/2011 Speed (Access Time)%" Volatility" CPU Main Memory CPU Main Memory Registers RAM Registers RAM < 1 nanosecs 2 nanosecs Contents Lost Contents Lost -3 milli = 10 -6 micro = 10 -9 nano = 10 Storage Device Hard Disk Storage Device Hard Disk 5 - 10 millisecs Contents Not Lost Computer Systems – Architecture E Edwards Main Memory Organisation (2.9) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.10) ! Cost" Summary" CPU Main Memory faster easier Registers Registers RAM Cache FLEXIBILITY SPEED USABILITY CPU ~ £70-£300 4GB ~ £30 RAM Hard Disk slower difficult expensive COST cheap Storage Device Hard Disk 1 TB ~ £40 small CAPACITY large high VOLATILITY low Computer Systems – Architecture E Edwards Main Memory Organisation (2.11) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.12) ! 3 17/10/2011 How many registers are there in a X86-64 processor?" How much memory is given to registers in a X86-64 processor?" A 2 B 4 C 16 D 64 E 256 " A 16B B 128B C 256B D 32B E 1024B" Computer Systems – Architecture E Edwards Main Memory Organisation (2.13) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.14) ! Main Memory (RAM)%" Addressing" W bits !# Memory Location Main Memory (Memory Word) ! !# Where in memory is the ! 101111101010101010111110 = W bits. Normally a 0110 1101 1010 1101 16-bit two$s Complement value byte-multiple, e.g. 16- 3?" bits, 32-bits." 001010101011101010101011 0000 0000 0000 0011 " " 011011010010100111011000 0000 0000 0000 0000 !# We need a scheme for uniquely R !# Memory Size identifying every memory ........ R x W bits! 1111 1111 1111 1111 rows location " " 101010101001001010111010 0000 0000 0000 0000 " !# Access: *** In our !# ADDRESSING 110110101000100010101010 model we will always 1001 1010 1010 0010 Identify memory locations with a Read/Write a whole 010101011110001011111011 Memory Word at a 0000 0000 0000 0000 positive number called the time ***" (memory) address" 111011000000111110111111 1111 1111 1111 1110 Computer Systems – Architecture E Edwards Main Memory Organisation (2.15) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.16) ! 4 17/10/2011 Memory Word Addressing" Byte Addressing" Main Memory Address Address (binary) ! Main Memory Word Address 0110 1101 1010 1101 0 0000 " 0110 1101 1010 1101 0 !# With byte addressing, every Memory[ 1 ] = ? 0000 0000 0000 0100 1 0001 0000 0000 0000 0011 2 byte in main memory has an address" 0000 0000 0000 0000 2 0010 Memory[ ? ] = -1 0000 0000 0000 0000 4 " 1111 1111 1111 1111 3 0011 1111 1111 1111 1111 6 !# In this example Memory[ ? ] = 0 0000 0000 0000 0000 4 0100 0000 0000 0000 0000 8 which is byte 0 and which is byte 1?" 1001 1010 1010 0010 5 0101 Mem[Mem[1]]= ? 1001 1010 1010 0010 10 0000 0000 0000 0000 6 0110 0000 0000 0000 0000 12 1111 1111 1111 1110 7 0111 1111 1111 1111 1110 14 Computer Systems – Architecture E Edwards Main Memory Organisation (2.17) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.18) ! Byte Ordering (Big Endian)%" Byte Ordering (Little Endian)%" Byte Address Main Memory Byte Address Byte Address Main Memory Byte Address 0 0110 1101 1010 1101 1 1 0110 1101 1010 1101 0 2 0000 0000 0000 0011 3 3 0000 0000 0000 0011 2 4 0000 0000 0000 0000 5 5 0000 0000 0000 0000 4 6 1111 1111 1111 1111 7 7 1111 1111 1111 1111 6 8 0000 0000 0000 0000 9 9 0000 0000 0000 0000 8 10 1001 1010 1010 0010 11 11 1001 1010 1010 0010 10 12 0000 0000 0000 0000 13 13 0000 0000 0000 0000 12 14 1111 1111 1111 1110 15 15 1111 1111 1111 1110 14 Computer Systems – Architecture E Edwards Main Memory Organisation (2.19) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.20) ! 5 17/10/2011 Byte Ordering of Multibyte Data Items" Example 1: 16-bit integer (View 1)%" Most Significant Byte (MSB) ! Least Significant Byte (LSB) !# 16-bit (2's Complement) integer 5 stored at memory address 24. " Big Endian VALUE Big Endian (8-byte) ! 0000 0000 0000 0101 Byte Addresses +0 +1 +2 +3 +4 +5 +6 +7 Byte Addresses 24 25 Least Significant Byte (LSB) ! Most Significant Byte (MSB) Little Endian Little Endian VALUE 0000 0101 0000 0000 (8-byte) ! Byte Addresses +0 +1 +2 +3 +4 +5 +6 +7 Byte Addresses 24 25 Computer Systems – Architecture E Edwards Main Memory Organisation (2.21) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.22) ! Example 1: 16-bit integer (View 2)%" Example 2: 32-bit value (View 1)%" !# 16-bit (2's Complement) integer 5 stored at memory address 24. " !# 32-bit hex value 54 BC FE 30 stored at memory address 24. " Big Endian Big Endian 0000 0000 0000 0101 Word address 24 54 BC FE 30 Byte Addresses 24 25 0101 0100 1011 1100 1111 1110 0011 0000 Byte Addresses 24 25 26 27 Little Endian Little Endian 30 FE BC 54 0000 0000 0000 0101 Word address 24 0011 0000 1111 1110 1011 1100 0101 0100 Byte Addresses 25 24 Byte Addresses 24 25 26 27 Computer Systems – Architecture E Edwards Main Memory Organisation (2.23) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.24) ! 6 17/10/2011 Example 2: 32-bit value (View 2)%" Example 3: ASCII string (View 1)"% !# 32-bit hex value 54 BC FE 30 stored at memory address 24. " !# String “JIM BLOGGS” stored at memory address 24" !# Treat a string as an array of (ASCII) bytes. Each byte is considered Big Endian individually. " 54 BC FE 30 0101 0100 1011 1100 1111 1110 0011 0000 Big Endian J I M B L O G G S Byte Addresses 24 25 26 27 Byte Addresses 24 25 26 27 28 29 30 31 32 33 Little Endian 54 BC FE 30 0101 0100 1011 1100 1111 1110 0011 0000 Little Endian J I M B L O G G S Byte Addresses 27 26 25 24 Byte Addresses 24 25 26 27 28 29 30 31 32 33 Computer Systems – Architecture E Edwards Main Memory Organisation (2.25) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.26) ! Example 3: ASCII string (View 2)"% A Problem" !# String “JIM BLOGGS” stored at memory address 24" !# How do we transfer a multi-byte !# Treat a string as an array of (ASCII) bytes. Each byte is considered value (e.g. a 32-bit two$s individually. " complement integer) from a Big- Endian memory to a Little-Endian memory?" " Big Endian J I M B L O G G S !# How do we transfer an ASCII string value (e.g. “JIM BLOGGS”) Byte Addresses 24 25 26 27 28 29 30 31 32 33 from a Big-Endian memory to a Little-Endian memory?" " Little Endian !# How do we transfer an object S G G O L B M I J which holds both types of values above?" Byte Addresses 33 32 31 30 29 28 27 26 25 24 Computer Systems – Architecture E Edwards Main Memory Organisation (2.27) ! Computer Systems – Architecture E Edwards Main Memory Organisation (2.28) ! 7 17/10/2011 What is the maximum amount of memory we can have in a 32bit machine with byte addressing?" (Un) Aligned Memory Accesses (1)%" Main Memory (Big Endian) ! A 4GB B 800MB C 16GB D 16MB E 1GB" 0 0110 1101 1010 1101 !# The 16-bit hex value (A9A1) at 2 1010 1001 1010 0001 address 2 is memory word aligned.