400 likes | 2.75k Views
The Computer Memory Model. Everything derives from this. Address. Data. Memory. J/K. J/K. J/K. J/K. J/K. J/K. J/K. J/K. r/w. info stored in digital logic (J/K latches) therefore, only 1s and 0s. What if?. You were a computer designer and... You needed to store information
E N D
The Computer Memory Model Everything derives from this
Address Data Memory J/K J/K J/K J/K J/K J/K J/K J/K r/w info stored in digital logic (J/K latches) therefore, only 1s and 0s
What if? • You were a computer designer and... • You needed to store information • and retrieve it? • info would be stored as numbers (numbers can “represent” anything) • numbers would be placed at addressable locations (addresses are numbered from 0 to some maximum)
why 1s and 0s • remember CSE241 • memory banks are J/K latches, capable of “remembering” a binary state • latches are grouped into banks merely to store more information than is possible in 1s and 0s • 1or 0 is a bit, 8 bits are a byte
store something in memory • there are 16 banks of 8 latches each • rules: r/w = 0 reads latches, = 1 sets latches • memory addresses 0 to 15 banks, or • 0000 to 1111 in binary • data size is 8 bits (number of latches in each bank) e.g. store the value 22 at location 10 • r=0 (passive) • address = 10102 (10 decimal) • data = 0001 01102 (22 decimal) • r/w=1, then r/w=0 (write strobe)
Address Data 15 Memory 0 1111 1111 r/w
How much memory is there, if the address bus is 8 bits? • How much memory if the address bus is 32 bits? • Does the size of the data bus matter? • This is a bigger deal than you might imagine • Should all memory behave the same?
A Byte • Eight bits • Can represent a number from 0 to 25510 • Reflect computer memory as a huge bank of 8-bit switches
Extending bytes • Use 7 bits 111 1111 - represent 0 to 12710 • Use the highest bit for “sign” 0 111 1111 127 1 111 1111 ( -127 )
2’s Compliment Replaces the redundancy of 0000 0000 1000 0000 To get negative: take the positive number, “complement” all the bits, add 1 To get positive: take the negative number, “complement” all the bits, add 1
For example, Positive Integer 4 0000 0100 Compliment of 4 1111 1011 + 1 0000 0001 Negative Integer 4 1111 1100 ----------------------------------- 3 0000 0011 2 0000 0010 1 0000 0001 0 0000 0000 -1 1111 1111 -2 1111 1110 -3 1111 1101
Size of storable numbers? 4 bits: 0000 to 1111 16 different numbers, maximum number is 15, or 24- 1 for unsigned -8 to +7 for signed two’s compliment 8 bits? 28=256 different numbers maximum number is 28 -1 = 255 for unsigned -27 to +(27-1) = -128 to 127 for signed
Difference between address and data • Address : number of different locations is important: 32 bit means 232 different locations • Data : range is important: 32 bit means -231 to+(231 - 1) for signed numbers 0 to +(232 - 1) for unsigned numbers
0000 - 0 0001 - 1 0010 - 2 0011 - 3 0100 - 4 0101 - 5 0110 - 6 0111 - 7 1000 - 8 1001 - 9 1010 -10 - A 1011 -11 - B 1100 -12 - C 1101 -13 - D 1110 -14 - E 1111 -15 - F Start Thinking Binary Nibbles and Hex Digits
Converting Binary to Hex 1010011110011110101100110100 step 1: break into “nibbles” 1010 0111 1001 1110 1011 0011 0100 step 2: convert each to Hex number 1010 0111 1001 1110 1011 0011 0100 A 7 9 E B 3 4
Converting Hex to Binary 26D47FE16 2 6 D 4 7 F E 0010 0110 1101 0100 0111 1111 1110
“Literals” • Hard numbers • 0, 15, 121, 78716 etc.
Java Support for Binary / Hex From the Java Reference Manual: Integer literals are written in three formats: decimal (base 10), hexadecimal (base 16), and octal (base 8). Decimal literals are written as ordinary numbers, hexadecimal literals always begin with 0X or 0x, and octal literals begin with 0. For example, the decimal number 10 is 0xA or 0XA in hexadecimal format, and 012 in octal format.
what does that mean? 0x1234 means 123416, which means 466010 0xAEF4 means 4478810
why? 0 x 1AF4 can be converted easily into binary 1 A F 4 0001 1010 1111 0100 So hex shows up in programming all the time, because binary is the computer’s interface to the world
Address Data Memory r/w
Address Data Memory J/K J/K J/K J/K J/K J/K J/K J/K r/w info stored in digital logic (J/K latches) therefore, only 1s and 0s
store something in memory • there are 16 banks of 8 latches each • rules: r/w = 0 reads latches, = 1 sets latches • memory addresses 0 to 15 banks, or • 0000 to 1111 in binary • data size is 8 bits (number of latches in each bank) e.g. store the value 22 at location 10 • r=0 (passive) • address = 10102 (10 decimal) • data = 0001 01102 (22 decimal) • r/w=1, then r/w=0 (write strobe)
Address bus size determines how many separately addressable banks Data bus size determines how many bits in a bank J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K select J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K decoder J/K J/K J/K J/K J/K J/K J/K J/K binary r/w
Address bus size determines how many separately addressable banks Data bus size determines how many bits in a bank J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K rw = 0 out J/K J/K J/K J/K J/K J/K J/K J/K in rw = 1 r/w
I/0 Memory Data Memory Program Memory Fast Specialty Memory
What goes in Program Memory? • What goes in Data Memory? • What’s the difference between address and data? • Why “Specialty” Memory? • What goes “in” Memory-Mapped I/O?
Address bus size determines how many separately addressable banks Data bus size determines how many bits in a bank Memory J/K J/K J/K J/K J/K J/K J/K J/K r/w
Design dilemma #1 Should the number of bits in a bank, be greater than the data bus size? 16 bit memory, but only 8 bit data 2 write cycles to fill up each address No. That just wastes time.
Design dilemma #2 What if the “computer” uses and needs numbers that are larger than the data bus? Now... this one is real. 8 bit data bus can only pass around numbers, like, -128 to 127. Virtually useless.
Data Storage • Address size is usually 32 bits 232 different locations 0 to 232-1 • Data bus and memory banks that store data are usually 8 bits wide Numbers limited to 0 to 255 (or -128 to 127) • How then, do you store bigger numbers? say, 32 bits = 4 bytes = 8 hex digits = 1 word - 429497296 to + 429497295. Now that’s reasonable.
So “numbers” in the computer are ALWAYS stored as 4 bytes, or 8 hex digits
Address bus size determines how many separately addressable banks Data bus size determines how many bits in a bank J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K J/K 4 bytes (4 address locations), always regarded as one computer “word” r/w
4 bytes (4 address locations), always regarded as one computer “word” e.g 0x A2 01 C4 FF Data Memory 4 FF 5 C4 01 6 A2 7 0 A2 1 01 2 C4 FF 3
which end of the Word goes in the lower address? • does the big end of the number go in address 0? (big endian) • does the little end of the number go in address 0? (little endian) • Big Endian: words are stored with Big byte low • Little Endian: words are stored with Little byte low
the “representation” • constructs are designed and stored and routed and presented for simplest, fastest, easiest manufacturing • what they represent may be complicated
Fast Specialty Memory dependable, 32-bit memory blocks: called “registers” a counter for tracking where in data memory you currently are: called a “stack pointer” a counter for tracking where your program is: program counter (means that program memory can be within data memory)
The Architecture Golden Rules • Account for memory volatility - dependable storage and retrieval • Maximize throughput - reduce the time it takes to perform an operation, especially storage and retrieval • Separate encoding of information from hardware - data is stored fast and dependably (see above), but what it means is up to the user.
Assignment 3 – due in two weeks Part 1: • Build a Java (or any language) based memory simulator • memory: 00 thru ff (8 bit addressing) • data is 8 bits • stores data on Write function • takes data in Base 10 Integer • limit data to -128 to +127, 2’s complement • takes address in Hex • memory dump - show contents of 00-ff in Hex
Assignment 3 Part 2: Take in 32 bit word storage as big Base 10 integer Limit input to numbers possible using 32 bits Ask for storage address in Hex, use the next highest 4-byte boundary. Store data words in big endian format Display on memory dump