Memory device used by the computer
 

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:

  • Computers must use an electrical switches as memory device

  • Electrical switches can be turned ON or OFF using an electrical current

Today's computer memory are made with transistors
 

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

  • If you want to learn more about how computer memory is constructed, you need to take CS355

  • In CS355, you will build a working CPU in the projects

A taste of CS355:   /home/cs255001/demo/355/8-bit-memory

An electronical switch used a (the smallest unit of) computer memory
 

The electrical switch can be in one of these 2 states:

  • off state

      • Inside the computer , the off state represents the digit 0  


  • on state

      • Inside the computer , the on state represents the digit 1  

How a switch work as a memory device:

  • A switch in the off state will retain (= remember) the value 0
  • A switch in the on state will retain (= remember) the value 1            

How to build a larger computer memory element (that can remember more states)
 

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 !

How to build larger memory elements - Example
 

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

Computer memory and binary numbers
 

Binary digit:

  • Binary digit = the digit 0 or the digit 1

    (In contrast, the digits 0,1,2,3,4,5,6,7,8,9 are called: decimal digits)


 

Bit (or bit memory):

  • Bit (= Binary digit) memory
    = a memory device that can retain (= remember) one binary digit

    I.e.: a bit (memory) can remember one of the two values {0 or 1}.

Byte memory
 

Byte memory (or "byte" for short):

  • Byte = 8 bits

    = a memory device that can retain (= remember) 8 binary digits

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.)

What kind of things are stored in the computer memory
 

The computer memory is used to facilitate the execution of a computer program:

  1. A computer program that is being run/executed by the computer system must be stored in memory in its entirety (CS355 with Virtual Memory)

  2. A computer program consists of:

    • Program instructions (i.e.: statements)
    • Variables (i.e.: data)

 

Purpose of the computer memory:

  • Computer memory is a very fast memory device used to store:

      1. Program instructions

      2. Program variables (= data) used by program instructions       

How is the memory used ?
 

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)

How is the memory used ?
 

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) !!

How is the memory used ?
 

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

Contrasting how humans and computers store data/information

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