CS100: Introduction to Computer Science

Review: History of Computers
CS100: Introduction to
Computer Science
Lecture 2: Data Storage -- Bits, their
storage and main memory
Review: The Role of Algorithms
n
Algorithm:
n
Program:
q
Mainframes
q
Minicomputers
q
Personal Computers & Workstations
How are data stored inside computers?
n
n
1.1 Bits and Their Storage
1.2 Main Memory
n
n
Programming:
n
Software:
n
n
Hardware:
Bits and Bit Patterns
n
n
Bit: Binary Digit (0 or 1)
Bit Patterns (strings of 0 and 1s) are used to
represent information.
q
q
q
q
q
Numbers
Text characters
Images
Sound
And others
Bits and Boolean Operations
n
Boolean Operation: An operation that
manipulates one or more true/false values
n
Specific operations
q
q
q
q
AND
OR
XOR (exclusive or)
NOT
1
Bits and Boolean Operations
n
Boolean operations
q
AND
n
n
q
n
q
P OR Q,
The output is true when at lease one of them is true
XOR (exclusive or)
n
q
Based on compound statement of the form P AND Q
1 AND 1 =1, 1 represents the value true, 0 represents false
OR
n
The output is true when its inputs are different
NOT: the output is the opposite of the input
Gates
n
Gate: A device that computes a Boolean
operation
q
q
Figure 1.2 A pictorial representation of
AND, OR, XOR, and NOT gates as well
as their input and output values
implemented as (small) electronic circuits inside
today’s computes
Other technologies to implement gates
n
q
Gears, relays, optic devices.
Provide the building blocks from which computers
are constructed
Flip-flops
n
Figure 1.1 The Boolean operations
AND, OR, and XOR (exclusive or)
Figure 1.3 A simple flip-flop circuit
Flip-flop: A circuit built from gates that can
store one bit.
q
q
q
Has an input line which sets its stored value to 1
Has an input line which sets its stored value to 0
While both input lines are 0, the most recently
stored value is preserved
2
Figure 1.4 Setting the output of
a flip-flop to 1
Figure 1.4 Setting the output of
a flip-flop to 1 (continued)
Figure 1.4 Setting the output of
a flip-flop to 1 (continued)
Figure 1.5 Another way of
constructing a flip-flop
What happens if 1 is placed on the lower input?
Flip-flops
n
The flip-flop is one means of storing a bit
within a computer.
q
q
q
n
Can have the output value of either 1 or 0
Other circuit can adjust the output value (write)
Other circuit can respond to the stored value
(read)
How does this flip-flop work?
Exercise:
What input bit patterns will cause the following circuit to
produce an output of 1?
Inputs
Output
Flip-flops show how devices can be
constructed from gates.
3
Main Memory
n
n
n
A collection of integrated circuits to store data (such as
flip-flops)
Needs to have electrical power in order to maintain its
information
n
Cell: A unit of main memory (typically 8 bits
which is one byte)
q
Computer can manipulate only data that in main
memory
q
q
n
Main Memory Cells
q
Copy programs into main memory from a storage device to
execute
Copy files into main memory to access
Most significant bit: the bit at the left (high-order)
end of the conceptual row of bits in a memory cell
Least significant bit: the bit at the right (loworder) end of the conceptual row of bits in a
memory cell
The amount of main memory is crucial
q
q
How many programs can be executed
How much data can be readily available to a program?
Figure 1.7 The organization of a
byte-size memory cell
Main Memory Addresses
n
Address: A “name” that uniquely identifies
one cell in the computer’s main memory
q
q
q
Figure 1.8 Memory cells arranged by
address
The names are actually numbers.
These numbers are assigned consecutively
starting at zero.
Numbering the cells in this manner associates an
order with the memory cells.
Measuring Memory Capacity
n
Kilobyte: 210 bytes = 1024 bytes
q
q
n
Megabyte: 220 bytes = 1,048,576 bytes
q
q
n
Example: 3 KB = 3 × 1024 bytes
Sometimes “kibi” rather than “kilo”
Example: 3 MB = 3 × 1,048,576 bytes
Sometimes “megi” rather than “mega”
Gigabyte: 230 bytes = 1,073,741,824 bytes
q
q
Example: 3 GB = 3 × 1,073,741,824 bytes
Sometimes “gigi” rather than “giga”
4
Questions:
n
If the memory cell whose address is 5
contains the value 8, what is the difference
between writing the value 5 into cell number
6 and moving the contents of cell number 5
into cell number 6?
Questions:
n
Suppose we want to interchange the values
stored in memory cells 2 and 3. Does the
following algorithm perform the task
correctly?
q
q
Questions:
n
How many bits would be in the memory of a
computer with 4KB memory
Main Memory Technologies
n
RAM (Random Access Memory)
q
q
q
n
What is the amount of main memory inside
your computer?
n
q
q
n
n
n
n
Boolean operations
Gates
Flip-flops (store a single bit)
Main memory (RAM)
q
Allow the stored data to be accessed in any order
No physical movement of the storage medium or a physical
reading head
Any piece of data can be returned quickly and in a constant time
Modern computers use other technologies to
improve the performance of main memory (size,
respond time)
q
Summarization
Step1: Move the contents of cell number 2 to cell
number 3.
Step 2: Move the contents of cell number 3 to cell
number 2.
DRAM (Dynamic RAM)
SDRAM (Synchronous DRAM)
DDR-SDRAM (Double Data Rate-SDRAM ) (doubled
standard SDRAM efficiency)
Next Lecture:
n
n
Mass (or secondary) storage & representing
information
Reading assignments: Chapter 1.3, 1.4
Cell, Byte, Address
5