A mechanical switch can remember 2 values: ON (= 1) and OFF (= 0)
(It is a mechanical device because you need mechanical motion to turn the switch on/off by hand
Computers are electrical devices
Therefore:
|
Electrical switches (and circuits to make computer memory are constructed using transistors:
How to construct a computer memory circuit is beyond the scope of CS255
|
A taste of CS355: /home/cs255001/demo/355/8-bit-memory
The electrical switch can be in one of these 2 states:
|
How a switch work as a memory device:
|
One switch can retain (= remember) a value in the range:
0 .. 1 |
This range of values is too small to be of much use....
How to make larger memory devices:
A row of n switches can be in one of 2n possible states !
Example: build larger memory with more switches
A group of 3 switches can be in one of these 23 = 8 states:
000 010 100 110 (all 8 possible states 001 011 101 111 of 3 switches) |
DEMO: /home/cs255001/demo/355/3-bits
Binary digit:
|
Bit (or bit memory):
|
Byte memory (or "byte" for short):
|
Each byte memory can store one of the following 256 possible patterns of binary numbers:
00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010 00001011 00001100 00001101 00001110 00001111 00010000 00010001 00010010 00010011 00010100 00010101 00010110 00010111 00011000 00011001 00011010 00011011 00011100 00011101 00011110 00011111 00100000 00100001 00100010 00100011 00100100 00100101 00100110 00100111 00101000 00101001 00101010 00101011 00101100 00101101 00101110 00101111 00110000 00110001 00110010 00110011 00110100 00110101 00110110 00110111 00111000 00111001 00111010 00111011 00111100 00111101 00111110 00111111 .... (And so on... too many to list) |
(1 bit can store 21 = 2 patterns. So 8 bits can store 28 = 256 patterns.)
The computer memory is used to facilitate the execution of a computer program:
|
Purpose of the computer memory:
|
Recall: what can the CPU do with the memory ?
(1) The CPU can get an instruction from memory
Therefore: instructions are binary numbers (= codes) (whose bits are sent over the wires in the data bus)
Recall: what can the CPU do with the memory ?
(2) The CPU can get data (variables) from memory
Therefore: data (in variables) are also binary numbers (= codes) (whose bits are sent over the wires in the data bus) !!
Recall: what can the CPU do with the memory ?
(3) The CPU can update data (variables) in memory
Meaning: the computer can update the bits in the memory and change the values in a variable
Humans are
very flexible and can use
many (different) methods to
store
data/information.
Example: humans can use
symbols to
represent
data/information:
Computers
can
only store
data/information as
binary numbers
This is how a
computer
(must)
stores (= "writes") the
letter A:
01000001
Repeat for emphasis:
both
(1) computer instructions and
(2) data in variables
are
binary numbers
inside
a computer