Transcript Computers

Chapter 3
Data Storage
17/07/2015
CIS110
1
Learning outcomes

By the end of this Chapter you will know:
•
•
•
•
•
The difference between electronic, magnetic and
optical memory
How data are stored in these types memories
The main memory is made up of logic gates
The main memory is organised in terms of cells and
addresses
memory terms:
•
How the address decoder works
• Memory capacity, access time, transfer rate, etc …
17/07/2015
CIS110
2
Additional Reading


Essential Reading
•
Stalling (2003): Chapters 5 and 6
Further Reading
•
•
•
•
Burrell (2004): Chapters 3 and 7
Schneider and Gersting (2004): Chapters 4 and 5
Tanenbaum (1990): Chapter 3
White (2002): Parts 3 and 4.
17/07/2015
CIS110
3
Introduction (1)



Information can be stored in different ways:
•
•
•
Books,
Films
Paintings,
It is not information if it could not used
Information in computers must be able to able to be
processed by computers:
•
•
Information must be represented in appropriate format
Information must be stored in appropriate places
17/07/2015
CIS110
4
Introduction (2)


Breakthrough:
•
•
The use of the binary system (Base 2)
In the binary system:
• There is only two types of values, 1s and 0s.
• It is easy to store binary information/data in physical
media
• It is also easy to process binary information
Different type of media storage
•
•
•
Electronic memory (main memory)
Magnetic memory
optical memory
17/07/2015
CIS110
5
Media Storage

Main memory (Electronic Memory):

Secondary Memory
• Stores data currently being used
• Is made of semiconductor chips.
• magnetic (floppy discs, hard disc )
• Optical (CD-ROM, DVD)
17/07/2015
CIS110
6
Main Memory (Electronic Memory)

Main memory stores data which are currently used by the
CPU.
•




To run a program, it is first loaded in the main memory
Main Memory is volatile
•
•
Its content changes frequently
Data is lost when the power is off
It is also called electronic memory
•
•
Based on electronic principles.
Formed with logic gates
•
Group of transistors
Cells
•
Sequence of one-bit memories
Addresses
•
Each cell has a unique address
17/07/2015
CIS110
7
The physical principles of electronic
memory

Transistor
• The smallest unit of an electronic
memory

Logic Gates

Flip-Flops
• Groups of transistors
• Special type of circuit
17/07/2015
CIS110
8
Logic Gates (2)
AND
NOT
OR
¬ a.
a b a.b
a b a.b
a
00
01
10
11
00
01
10
11
0 1
1 0
0
0
0
1
17/07/2015
0
1
1
1
CIS110
9
Logic Gates (3)
NAND
XOR
NOR
a b a.b
00
01
10
11
1
1
1
0
a b a.b
a b a.b
00
01
10
11
00
01
10
11
1
0
0
0
0
1
1
0
• For more details see
•Schneider and Gersting (2004: 155-177)
•Burrell (2004: 43-62)
17/07/2015
CIS110
10
Flip-Flop circuits



Up to now the output of combinational circuits
depends solely up the input
Combinational circuits has no memory
To build a sophisticated digital signal circuits,
memory, we need:
• We need circuits whose output depends upon both the
•
input of the circuit and its previous states.
In other words, we need circuit that have memory.
17/07/2015
CIS110
11
A Simple Flip-flop Circuit
•
•
•
•
As long as both inputs remain 0: output does not change
Temporarily placing 1 on upper input => output = 1
Temporarily placing 1 on lower input => output = 0
So: output flip-flops between 2 values under external control
17/07/2015
CIS110
12
Setting the Output of a Flip-flop
to 1
17/07/2015
CIS110
13
Setting the Output of a Flip-flop
to 1 (cont’d)
17/07/2015
CIS110
14
Setting the Output of a Flip-flop
to 1 (cont’d)
17/07/2015
CIS110
15
Controlled Flip-Flop
• If control = 0 the the flip-flop does not change the state
• If control = 1, then if D=0 then Q =1 else Q = 0
17/07/2015
CIS110
16
Clocked SR flip-flop
•
If CP = 0 the output of both AND gates is 0.
• Regardless of the values of S and R.
•If S=R=CP=1, then both outputs are set to 0
17/07/2015
CIS110
17
Main Memory


Large collection of circuits, each capable of storing a single bit
Arranged in small cells, typically of 8 bits each (a.k.a.: byte)
17/07/2015
CIS110
18
Arrangement of Memory Cells

Each cell has a unique address

Longer strings stored by using
consecutive cells
value = 01101101

17/07/2015
CIS110
RAM (random access
memory)
19
One-bit Memory
Q
D
CP
•To write a datum (0 or 1) to this memory
•send data to D, and at the same time
•send a WRITE signal to CP
•To read a datum from this memory
•connect to Q by sending a READ signal
17/07/2015
CIS110
20
Main memory = linking many flip-flops
See Burrell (2004: 111-112) and Tanenbaum (1990: 105-109)
t
17/07/2015
CIS110
21
Memory cells
n-bit cell
Can hold
m*n bits
m cells

In reality, most electronic memories have 8-bit cells.
17/07/2015
CIS110
22
Accessing Data in the Main
Memory




Instructions and data are stored in the main memory in a serial
order.
CPU executes instructions one by one top down.
An instruction may tell the CPU
•
•
to jump to particular cell and execute the instruction held in it,
or fetch the data stored is that cell.
How is this done?
17/07/2015
CIS110
23
System Bus

Main memory and CPU are linked using a set of wire:
•
•
Three wires:
•
•
•
address lines,
data lines and
control lines.
Known as
•
•
•
address bus,
data bus and
control bus.
17/07/2015
System bus
CIS110
24
CPU
Main
memory
Add. bus
Data bus
Control bus
17/07/2015
CIS110
25
To read data from each
cell
To issue read or write
signal
To identify each memory
cell
CPU
Main
memory
Add. bus
Data bus
Control bus
17/07/2015
CIS110
26
Address Bus
Address
Of the cell
To activated
CPU
Main
memory
Address
Of the cell
To activated
Address bus
17/07/2015
CIS110
27
Binary Address Representation



Each cell has a unique address.
I.e. using 4 digit binary representation we have:
0000 cell 0
0001
cell 1
0010
cell 2
0100
cell 3
How many bits are needed to represent an address?
17/07/2015
CIS110
28
Address Decoder
Address
Of the cell
To activated
Unique cell
Has a unique
Address.
CPU
Main
memory
Decoder
Address bus
17/07/2015
CIS110
29
A Simple Address Decoder
Q0 00 C0
2 ad-lines
A1
A0
Q1 01 C1
Q2 10 C2
22 = 4 address
cells
Q3 11 C3
Decoder is a device between the Main Memory and
the address lines.
17/07/2015
CIS110
30
Decoder with N Address Lines
Main Memory
a0
a1
0000…0000
0000…0001
0000…0010
2n
add
cell
n add.
lines
an-1
17/07/2015
1111…1111
CIS110
31
Main Memory with 4 Chips
decoder
Main memory
a0
a1.
.
.
.
.
.
.
aN-1
Chip 1
Chip 2
Chip 3
Chip 4
17/07/2015
CIS110
32
The higher 2 bits of
Address line to select
The chip.
a n-1
0
0
0
0
1
1
1
1
a n-2
0
0
1
1
0
0
1
1
17/07/2015
…..………..a0
0………….. 0
1………….. 1
0………….. 0
1………….. 1
0………….. 0
1………….. 1
0………….. 0
1………….. 1
CChip 1
h
i
Chip 2
p
1Chip 3
Chip 4
CIS110
33
Multiplexer




Cells form rows and columns.
Each cell can be identified by a row
address and column address.
Each cells address uses only n/2
address lines.
This can be done using a multiplixed
addresses.
17/07/2015
CIS110
34
Decoder with 4 Address Lines
(non-multiplexed addresses)
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
17/07/2015
CIS110
35
Decoder with 2 Address Lines
(multiplexed addresses)
00
01
10
11
00
0000
0001
0010
0011
01
0100
0101
0110
0111
10
1000
1001
1010
1011
11
1100
1101
1110
1111
17/07/2015
CIS110
36
Two-Input Multiplexer

A multiplexer is an electronic device that
allows multiple logical signals to be
transmitted simultaneously across a
single physical channel (address line).
17/07/2015
CIS110
37
Example 1

Suppose computer’s Main Memory is linked to
a decoder with 8 address lines.
1.
2.
3.
Can 1000 memory cells be used?
If no what is the maximum number of addresses that can
generated?
What is the maximum number of addresses that can be
generated is multiplexed addresses are used?
17/07/2015
CIS110
38
Answer


Suppose computer’s Main Memory is linked to a decoder with 8
address lines.
1.
Can 1000 memory cells be used?
2.
If no what is the maximum number of addresses that can generated?
Answer:
1. NO
2. With 8 address lines, the maximum number of addresses
3.
is 28=256
22*8 = 216
17/07/2015
CIS110
39
Example 2


Suppose that a computer’s Main Memory has
1013 cells.
How many address lines are needed in order for
all the cells to be useable? Explain your answer.
17/07/2015
CIS110
40
Answer

Suppose that a computer’s Main Memory has 1013 cells. How many
address lines are needed in order for all the cells to be useable? Explain
your answer.

Answer:
•
•
•
•
•
With N address lines a computer can have a maximum 2N usable cells. 29 =
512, 210 = 1024.
9 address lines would not generate enough addresses for 1013 cells to be
used. 10 address lines would.
Having more than 10 address lines would lead to too many addresses
wasted. So the desired number of address lines is 10.
N = ⌈log2(1050)⌉ can be used to find the number of address lines.
If multiplexed addresses is used, then 5 address lines would be sufficient
for 1013 cells to be useable.
17/07/2015
CIS110
41
What does a word mean?




A word is the length of instructions the CPU
can execute at one time.
Some processor can handle 8-bit words others
16-bit, 32-bit, 64-bit.
A cell does not necessarily store one word.
A word can occupy more than one cell.
17/07/2015
CIS110
42
Address Space

The address space of a computer is the maximum
number of cells a computer can hold.

The address space is determined by the number of
address lines used in a computer.

If each cell in a memory is 8-bit, then the memory is
called byte addressable: 1 byte long has a unique
address
17/07/2015
CIS110
43
Features of the Main Memory




Memory Capacity.
Access of information
Access time
Transfer rate
17/07/2015
CIS110
44
Memory Capacity



Most computer’s memory have 8-bit (1-byte)
cells.
In this case we have:
Address lines
No of cells
Capacity (byte)
n
2n
2n x 1
32KB, 256MB and 20GB are used to describe
the memory capacity.
17/07/2015
CIS110
45
Capacity Units
1kB = 210 = 1024 Byte.
1MB =1024 KB = 220 Bytes= 1, 048,576 B.
1GB =1024 MB = 230 kB=1, 073,741,824 Bytes.
17/07/2015
CIS110
46
Access Time



Access time is taken between the moment
when the CPU wants the read/write from/into
a cell and the moment when the cell is
activated.
It is the moment that the CPU takes to activate
a cell.
60ns (10-9 sec)
17/07/2015
CIS110
47
Transfer Rate

Is the amount of information per second exchanged
between the CPU and main memory.

If the CPU can read n cells in a second and each cell has
m bytes then transfer rate is n*m (bytes/s)

Main memory
• electronic signals
• Implies fast transfer rate in the scale about 100MB/sec
17/07/2015
CIS110
48
Random Access

If the CPU wants to activate particular
cell.
• It does not search for the target cell from top
•
•
to bottom.
It does put the address of the target cell in
the address line, then the cell will be
activated.
This type of accessing information is called
Random Access
17/07/2015
CIS110
49
The need for other type of
memories.

Main memory
• Fast as all the exchange between CPU and
•
Main memory is done electronically.
However, it is volatile.
• Information lost when the machine is turned off.
• The need for non-volatile memory:
• Hold information when the machine is off.
• i.e. Magnetic disk, optical disk, magnetic tape
17/07/2015
CIS110
50
Magnetic Memory



Another way of storing information in the binary framework.
Magnetic memory contains a number of spots.
The information is stored by magnetising and demagnetising
these spots.
• Magnetised spot 1
• unmagnetised spot 0
• i.e. floppy disk
17/07/2015
CIS110
51
A Magnetic Disk Storage
System
• Each track contains same number of sectors
• Location of tracks and sectors not permanent (formatting)
• Examples: hard disks, floppy disks, ...
17/07/2015
CIS110
52
Magnetic Disk Terminology





Platter:
•
•
rigid metal or glass platter Coated with magnetic material.
rotating at constant angular velocity
Arm:
•
With movable magnetic read/write heads
Track:
•
•
A complete ring of data
The disk surface is divided into tracks
Sectors:
•
Each track is subdivided into sectors
Cylinder (see slides 71-72):
•
A vertical collection of tracks at the same radial position
17/07/2015
CIS110
53
Data Organization and
Formatting


Concentric rings or tracks
• Gaps between tracks
• Reduce gap to increase capacity
• Same number of bits per track (variable packing
density)
• Constant angular velocity
Tracks divided into sectors
•
•
•
Minimum block size is one sector
May have more than one sector per block
See Stalling (2003) pages:167-168
17/07/2015
CIS110
54
Disk Data Layout
spots
sector
17/07/2015
CIS110
55
Magnetic Disks
17/07/2015
CIS110
56
Magnetic Disks
Thus as the platter rotates under the head, a stream of bits
can be written and later read back.
17/07/2015
CIS110
57
Read/write Head

Coil of wire
Iron former



17/07/2015
A coil of wire wound onto an iron former.
gap.
If a spot on the magnetic memory passes
under the gap then an electrical current is
induced in the coil. And the read/write head
will know that there is a 1 stored on that
spot. Otherwise it is 0.
By passing an electric current on the wire
we can magnetise and demagnetise spots.
CIS110
58
Read and Write Mechanism (1)





Recording and retrieval via conductive coil called a head
May be single read/write head or separate ones
During read/write, head is stationary, platter rotates
Write
•
•
•
Electric Current through coil of wire produces magnetic field
Magnetic Pulses sent to the head
Magnetic pattern recorded on surface below
Read
•
•
Magnetised bit pattern
•
•
Magnetic field induces an electrical current in the coil
The bit pattern contains 1
Demagnetised bit pattern
•
•
No Magnetic field induced, hence, no electrical current in the coil
The bit pattern contains 0
17/07/2015
CIS110
59
Read and Write Mechanism (2)
1
CPU
01010
Add. bus
01010
1
Data bus
1
Control bus
17/07/2015
CIS110
60
Fixed/Movable Head Disk

Fixed head

Movable head
• One read/write head per track
• Heads mounted on fixed ridged arm
• One read/write head per side
• Mounted on a movable arm
17/07/2015
CIS110
61
Access Information on a Floppy
disk

To access information on a floppy:

Head moves to the target track.
waits for the desired sector to spin underneath it
read/write begins.


• Track number, and
• Sector number.
17/07/2015
CIS110
62
Seek time and average seek
time


Seek time:
•
is the time it takes, the read/write head to move from
one track to a particular track on a disk
Average seek time:
•
is the average of seek time between every pair of
tracks.
17/07/2015
CIS110
63
Example

A disk has 5 tracks and the read/write head
takes 1ms to move from a track to an adjacent
one
•
•
1-2:1ms, 1-3:2ms, 1-4:3ms, 1-5:4ms,
2-3:1ms,
2-4:2ms, 2-5:3ms, 3-4:1ms,
3-5:2ms, 4-5:1ms
Average seek time: 20/10= 2ms.
17/07/2015
CIS110
64
Average latency

Average latency :

Example:
• is the time taken to make half a revolution.
• Disk rotates at a speed of 100 rev/sec
• Average latency is:
17/07/2015
1 / 200 sec.
CIS110
65
Maximum data transfer rate

It is the rate at which data passes under
the read/write head (bytes/sec).
• Number of bytes / track
17/07/2015
CIS110
* Number of rev / sec
66
Constant Angulair Velocity (CAV)
Variable
density
17/07/2015
CIS110
67
Multiple Platter (hard disk)





Permanent storage that is inside of
the computer, and NOT portable.
Consists of several platters which
spin very fast
Heads are joined and aligned
Aligned tracks on each platter form
cylinders
Data is striped by cylinder
•
•
reduces head movement
Increases speed (transfer rate)
17/07/2015
CIS110
68
Multiple Platters (2)
• Disk platters speed (3600 to 10 000 rpm
(rev/min).
•floppy (360rpm).
•The read data we need to specify cylinder,
head, and sector numbers.
Each cylinder represents a track number.
17/07/2015
CIS110
69
Cylinders
17/07/2015
CIS110
70
Magnetic Tape (1)





Serial access
Slow
Very cheap
High capacity
Backup
17/07/2015
CIS110
71
Magnetic tape (2)
• Serial access (slow)
• Good choice for off-line data storage (archives)
17/07/2015
CIS110
72
Magnetic Tape
column
R/W head
Blocks of data
Track 1
Track 2
Track 9
A magnetic tape is a series of columns.
Each column can store a word or two.
Tapes offer a large storage capacity for backup.
See Stalling (2003) pages:189-190.
17/07/2015
CIS110
73
Features of Magnetic Memory







Memory capacity:
Floppy can hold 700KB – 120MB.
Hard disk can hold dozen of GB, 10, 20,..
Tapes can hold 100MB- 80GB.
Access method
• Floppy and hard disks is random as the main memory
• Tape is serial
Access time:
• It is the average time taken to position the R/W head over
the data to be read
• For disk drives is about 10-3 sec when in MM 10-9 sec.
Transfer rate: is slower. It is the transfer of data between MM
and Mag/M. Floppy (500kB-2MB) and hard disc (4-12MB).
17/07/2015
CIS110
74
Optical Storage CD-ROM







Originally for audio
650 Mbytes giving over 70 minutes audio
Polycarbonate coated with highly reflective coat, usually
aluminium
Data stored as pits
Read by reflecting laser
Constant packing density (data/surface= constant)
•
•
More data in outer edges
Less data towards the centre of the disc
Constant linear velocity
•
The drive must adjust the disc speed (495 to 212 rev/m) edges
• Faster when reading data closer to the centre
• Slower when reading data in outer edges
17/07/2015
CIS110
75
CD-ROMs
In recent years, optical (as opposed to magnetic) disks
have become available.
They have much higher recording densities than
conventional magnetic disks.
Optical disks were originally developed for recording
television programs, but they can be put to more esthetic
use as computer storage devices.
Due to their potentially enormous capacity, optical disks
have been the subject of a great deal of research and have
gone through an incredibly rapid evolution.
17/07/2015
CIS110
76
17/07/2015
CIS110
77
Optical Storage – CD-ROM




Is a disc with highly reflective surface.
Tiny areas flat and depressed:
• Flat (land)  strong reflection.
• Depressed (pits)  low reflection.
Laser  landstrong reflectionphoto-sensor generates
electrical voltagestore 1s.
• Laser: (light Amplification stimulated emission of
radiation).
Lightpitslow reflection no electrical voltage 
stores 0s.
17/07/2015
CIS110
78
CD-ROM Operation
17/07/2015
CIS110
79
Laser
•Monochromatic light (single wave length)
• Coherent (photons move in the same direction)
• Directional (very tight beam, strong concentrated)
17/07/2015
CIS110
80
CD/DVD Storage Format
•
•
•
•
Data stored by creating variations in the reflective surface
Data retrieved by means of a laser beam
Data stored uniformly (so CD rotation speed varies)
Random access much slower than for magnetic disks
17/07/2015
CIS110
81
The pits and lands are written in a single continuous spiral starting near
the hole and working out a distance of 32 mm toward the edge.
The spiral makes 22,188 revolutions around the disk (about 600 per
mm). If unwound, it would be 5.6 km long.
17/07/2015
CIS110
82
Constant linear velocity
sector
Constante
density
rev/m
centre
17/07/2015
edges
CIS110
83
Random Access on
CD-ROM





Difficult
Move head to the right position
Set correct speed
Read address
Adjust to required location
17/07/2015
CIS110
84
head
Read and Write Mechanism (1)
1
CPU
Head
01010
Add. bus
01010
1
Data bus
1
Control bus
17/07/2015
CIS110
85
CD-ROM for & against






Large capacity
Easy to mass produce
Removable
Expensive for small runs
Slow
Read only
17/07/2015
CIS110
86
Other Optical Storage

CD-Recordable (CD-R)

CD-RW
• WORM(write once read many)
• Compatible with CD-ROM drives
• Erasable
• Mostly CD-ROM drive compatible
17/07/2015
CIS110
87
DVD - what’s in a name?

Digital Video Disk
• Used to indicate a player for movies
• Only plays video disks

Digital Versatile Disk
• Used to indicate a computer drive
• Will read computer disks and play video disks
17/07/2015
CIS110
88
DVD - technology



Multi-layer
Very high capacity (4.7GB per layer)
Full length movie on a single disk
• Using MPEG (Moving Picture Expert Group)
compression
• Digital Compression of audio and video signals.
• MPEG achieves high compression rate by
storing only changes from one frame to
another, instead of each entire frame.
17/07/2015
CIS110
89
Summary



Main memory
•
•
•
•
RAM
Low storage capacity
Fast (electrical signals)
Volatile.
Magnetic memory
•
•
•
Floppy disk
Hard disk
Magnetic tape
Optical memory
•
•
CD_ROM disk
DVD
17/07/2015
CIS110
90