Sunteți pe pagina 1din 32

Computer Hardware: Basic Denitions

Programming: The planning, scheduling, or performing of a task or event


Computer program: A sequence of instructions for a computer to execute
Computer: An electronic, programmable device that can store, retrieve, and process
data
Modern computers based on the von Neumann architecture
Information: General, abstract knowledge
Data: Information to be processed by a computer
Must be in form computer can understand
Computer converts data to information
Computer system consists of 2 general components:
1. Hardware
2. Software
Units
Unit Quantity symbol
Bit (binary digit) atomic piece of storage/memory b
Byte: 8 bits smallest standard size of storage/data B
Second s
Hertz Speed H
Common prexes
Prex Value Symbol Quantity
Tera 2
40
= 1, 099, 511, 627, 776 t memory, speed
Giga 2
30
= 1, 073, 741, 824 g memory, speed
Mega 2
20
= 1, 048, 576 m memory, speed
Kilo 2
10
= 1, 024 k memory, speed
Milli 10
3
(0.001) m time
Micro 10
6
(0.000001) time
Nano 10
9
(0.000000001) n time
1
Computer Hardware: Basic Denitions (2)
Approximations
Prex Approximate Value
Tera 10
12
= 1, 000, 000, 000, 000
Giga 10
9
= 1, 000, 000, 000
Mega 10
6
= 1, 000, 000
Kilo 10
3
= 1, 000
2
Computer Hardware: Basic Components
Represents physical components
2 general types
Computer proper
1. Main memory
2. Central Processing Unit (CPU)
3. Bus
Peripherals
Add-ons
E.g., printer, DVD drive, hard disk
3
Computer Hardware: Memory - Intro
Refers to data storage components of computer
Hierarchy of memory types:
Type Speed Cost Nature
Register fastest most expensive volatile
Cache volatile
RAM slowest least expensive volatile
ROM nonvolatile
Volatile memory loses its contents when computer is powered o
Stores everything used by the computer:
programs, data, ...
Stored electronically
Standard approach uses bi-stable (two-state) device
Transistors used - electronic switches
When voltage applied to base, electricity ows from collector to emitter
Switch is on
No voltage to base, no ow
Switch is o
Transistor represents a bit(binary digit) of data
Each transistor can represent 2 values:
on, and
o
Values represented as 1 and 0
Byte considered basic unit of storage
4
Computer Hardware: Memory - RAM
RAM stands for Random Access Memory
Consists of a linear sequence of storage locations (cells, words, ...)
Each byte has a unique address, numbered from 0 to total amount of memory - 1
Often, bytes grouped together into words
Memory generally measured in terms of mega or gigabytes
RAM is primary storage area for computer during operation
Often referred to as primary storage, main memory
Stores both programs and data
When power turned o, all switches open
Memory becomes 000000000000000...
Contents must be loaded during operation
Physically exists as an array of cells
Each row and column has a wired connection
To access a particular memory cell, activate the connections for its row and
column
5
Computer Hardware: Memory - RAM (2)
Types of RAM
Dynamic (DRAM)
Electricity stored in a capacitor
Transistor controls amount (voltage) stored
If greater than about 50% capacity 1
If less than about 50% capacity 0
Capacitors lose charge over time (msec)
Computer must refresh value in each bit on a regular basis
Done thousands of times per second
Hence: dynamic RAM
Static (SRAM)
Uses multiple transistors per bit
Value does not need to be refreshed
Compared to DRAM
1. Faster (no need to refresh)
2. More expensive
3. Larger
Hence, not used for main memory
Typical time to access data: 50 nsec
6
Computer Hardware: Memory - ROM
ROM stands for Read Only Memory
Often called BIOS (Basic Input Output System)
Data permanently stored - cannot be changed
Hardwired using diodes
Stores parts of operating system needed to start computer
7
Computer Hardware: Seconday Storage - Intro
Secondary storage refers to memory that is not part of the computer proper
Examples:
Disks
Tapes
CDR
DVD
Flash memory
These types of memory are nonvolatile:
They retain their contents when unpowered
Without secondary storage, programs, data, etc. would need to be typed into a
computer every time it was turned on
These devices generally are magnetic or optical in nature
8
Computer Hardware: Secondary Storage - Magnetic Devices
1. Disks
Typical disk structure:
Bits stored as alignments of magnetic particles
Microscopic magnetic particles have north and south poles
One alignment corresponds to a 1 bit, the other to a 0 bit
Data bits appear sequentially along a track
Disk addresses consist of track, block, and byte oset
Block size multiple of 512 bytes
Data transfer is a whole block at a time
9
Computer Hardware: Secondary Storage - Magnetic Devices (2)
Read/write process: Given a disk address to access
Disk spins
Typically 7200 rpm
8.33 msec per 1 rotation
Position arm over appropriate track
Called seek time
E.g., 0.02 msec to move to adjacent track
Wait until appropriate block rotates under head - latency time (fast)
Called (rotational) latency
E.g., 0.02 msec to move to adjacent track
Best case: 0 msec
Worst case: 8.33 msec
Read the block
Called read time
Requires 8.33/n msec, where n is number of blocks per track
10
Computer Hardware: Secondary Storage - Magnetic Devices (3)
Disk pack
Set of disks packaged as a rigid unit
Each arm has 2 read/write heads - one for each adjacent surface
Actuator moves arms as a unit
Disk address will include surface
Cylinder: set of tracks that can be read/written for a given position of the
actuator
Data transfers ow through a buer
Part of memory reserved for data transfers
Usually can hold several disk blocks
Want ecient data transfer
Factors that aect transfer speed:
Physical record structure
File organization
Buer management
11
Computer Hardware: Secondary Storage - Magnetic Devices (4)
Disk is a random access device
Can access disk address independently of others
2. Tape
Tape has 8 tracks
Each track stores one bit
Bytes stored sequentially along tape
Tape is sequential access device
Given an address, must pass over all data that precedes it
Signicantly slower than disk
Used for long-term storage of les
12
Computer Hardware: Secondary Storage - Optical Devices
CDR and DVD basically the same
Structure is similar to disk structure, except have continuous spiral instead of sepa-
rate tracks
Bits stored as dierences of reectivity
Laser shines on disk
Light is reected into a sensor
Bright interpreted as 1, dull as 0
CDROM
Plastic substrate has bumps burned in with laser
Shiny aluminum coated over the substrate
Laser light shining on a bump reected away from sensor, so appears dark (rep-
resenting a 0)
Data cannot be changed
13
Computer Hardware: Secondary Storage - Optical Devices (2)
CD-R
Uses a heat-sensitive, translucent dye instead of bumps
When heated, dye becomes opaque
To write a 0, heat spot on CD with write laser
More powerful than read laser
Read laser not strong enough to aect dye
Can only be written once
14
Computer Hardware: Secondary Storage - Optical Devices (3)
CD-RW
Uses a phase-change chemical
In crystalline form, is translucent
In amorphous form, is opaque
When melted and cooled quickly, becomes amorphous
When melted and cooled slowly, becomes crystalline
Initially, compound in crystalline form
To write a 0, melt and cool quickly
To overwrite a 0 with a 1, melt and cool slowly
15
Computer Hardware: Flash Memory
Flash memory is like ROM on the motherboard
However, it uses an EEPROM - Eelectronically Erasable Programmable ROM
Using transistors and quantum eects at the atomic level, a charge can be semi-
permanantly stored in a memory cell
The charge can be removed at a later date
16
Computer Hardware: Representation
1. Integers (whole numbers)
Each digit of a binary integer represents a power of 2
In decimal (base 10), each digit represents a power of 10:
1826
10
= 1 10
3
+ 8 10
8
+ 2 10
1
+ 6 10
0
In binary (base 2), each digit represents a power of 2:
10110101
2
= 1 2
7
+0 2
6
+1 2
5
+1 2
4
+0 2
3
+1 2
2
+0 2
1
+1 2
0
=
1 128 + 0 64 + 1 32 + 1 16 + 0 8 + 1 4 + 0 2 + 1 1 = 181
10
Note that the largest value that can be represented is limited by the amount of
storage allocated
If 1 byte is used for integers, the largest integer that can be represented is
11111111 = 2
8
1 = 255
If 2 bytes are used for integers, the largest integer that can be represented is
1111111111111111 = 2
16
1 = 65535
To convert decimal representation to binary: Cast out 2s
Steps:
(a) Divide decimal representation by 2
(b) Write down the remainder
(c) Repeat the previous 2 steps, using the quotient for the dividend
(d) Continue until quotient is 0
(e) Write the remainders in the reverse order in which they were calculated
Example: 53
10
(a) 53/2 = 26R1
(b) 26/2 = 13R0
(c) 13/2 = 6R1
(d) 6/2 = 3R0
(e) 3/2 = 1R1
(f) 1/2 = 0R1
(g) Answer = 110101
17
Computer Hardware: Representation (2)
Negative integers are represented using a leading 1
Ones complement
A leading 1 means a negative number
A leading 0 means a positive number
Remaining digits interpreted as above
Example: 10110101
2
=
(0 2
6
+ 1 2
5
+ 1 2
4
+ 0 2
3
+ 1 2
2
+ 0 2
1
+ 1 2
0
) =
(1 128 + 0 64 + 1 32 + 1 16 + 0 8 + 1 4 + 0 2 + 1 1) =
53
10
There is a problem with this representation:
1000000
2
= 0
10
0000000
2
= +0
10
Twos complement
Developed to eliminate above problem
To represent an integer in twos complement representation:
(a) Write the binary representation as usual
(b) Flip all the digits (1 0, 0 1)
(c) Add 1
Example: 53
10
(a) Binary representation of +53: 00110101
(b) Flip all the digits: 11001010
(c) Add 1: 11001011
Note that using either approach cuts the size of the largest integer that can
be represented in half
Ones complement:
Largest positive integer (1 byte): 01111111 = 127
10
Smallest negative integer (1 byte): 11111111 = 127
10
Twos complement:
Largest positive integer (1 byte): 01111111 = 127
10
Smallest negative integer (1 byte): 10000000 = 128
10
18
Computer Hardware: Representation (3)
2. Floating point (real) numbers
Represented using scientic notation:
32.746 10
7
= 327, 460, 000
In the computer, only the values are stored:
sign mantissa sign exponent
Since storage is of xed size, a xed set of bits are used for the mantissa and
exponent
In addition, the decimal point is assumed to be in a specic location
For example (base 10):
(a) Assuming decimal is in front of rst digit of mantissa
(b) 4 digits for mantissa
(c) 2 digits for exponent
327, 460, 000 = .32746 10
9
+3274 + 09
This leads to loss of precision (inability to represent all digits in original)
It increases the range of values that can be represented:
Largest value: 9999 10
99
(As opposed to 9999999 in decimal using 8 digits)
Binary representation is used for mantissa, exponent, and signs in the computer
19
Computer Hardware: Representation (4)
3. Characters
There is no direct correlation between printable characters and binary represen-
tation
Arbitrary codes are used
ASCII (American Standard Code for Information Interchange)
Standard code for representing characters
Uses 7 bits
A represented by 65
10
= 01000001
a represented by 97
10
= 01100001
1 represented by 49
10
= 00110001
Note: Character 1 not the same as the integer 1
Unicode
Extension of ASCII
Uses up to 4 bytes
EBCDIC
IBM standard for mainframes
4. Parity bits
Extra bit to help insure data integrity
Odd parity means the number of 1s in a byte will add to an odd number
The parity bit is set to insure this is the case
For example:
00110101 100110101
00110100 000110100
If an extended byte does not have the proper parity, an error has occured
20
Computer Hardware: Representation (5)
5. Hexadecimal
Used to simplify representation of binary values
Hexadecimal is base 16
Requires 16 digits
Uses letters in addition to the digits 0 - 9
hex digit 0 1 2 3 4 5 6 7 8 9 A B C D E F
value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Every byte can be represented by a pair of hex digits
Example:
11010010
2
is represented as 1101 = 13
10
= D, 0010 = 2
10
= 2, or D2
16
21
Computer Hardware: Central Processing Unit (CPU)
Brains of computer
Components:
1. Registers
Special high-speed memory cells local to the CPU
2. Arithmetic Logic Unit (ALU)
Performs computations
3. Control unit (CU)
Controls operation of the system
22
Computer Hardware: Central Processing Unit (CPU) (2)
Operation based on von Neumann architecture
1. Computer composed of following systems
(a) Memory
(b) CPU
(c) IO system
2. Programs are stored in memory
3. Program statements are executed sequentially
23
Computer Hardware: CPU - Registers
Storage local to CPU
High-speed memory directly accessible to CPU components
Examples:
1. General purpose registers to hold operands and results of computations
2. Accumulator - Specially designated register for operands and results
3. 0
4. +1
5. -1
6. Memory Address Register (MAR)
Stores address of memory location to be accessed
Must be large enough to store largest address in memory address space
E.g., 4GB = 2
30
memory requires 31 bits
7. Memory Data Register (MDR)
Stores data to be retrieved from or saved to memory
One or more bytes in width
8. Instruction Register (IR)
Holds instruction being executed
Must be large enough to hold largest instruction
E.g., 4, 8, 16 bytes
9. Program Counter (PC)
Holds address (in memory) of next instruction to be executed
Must be large enough to store largest address of memory reserved for holding
programs
24
Computer Hardware: CPU - ALU
Types of operations performed:
Arithmetic
Addition
Subtraction
Logic
AND
1 0
1 1 0
0 0 0
OR
1 0
1 1 1
0 1 0
NOT
1 0
0 1
EXCLUSIVE OR
1 0
1 1 0
0 0 1
Shifts
Shift left
11001010 10010100
Shift right
11001010 01100101
Rotate left
11001010 10010101
Rotate right
11001010 01100101
25
Computer Hardware: CPU - ALU (2)
Operands can be loaded from registers, or from elsewhere
Results can be stored into a register, or elsewhere
The control line selects the operation to be performed
Can be designed to perform more complex operations
But requires more circuitry
26
Computer Hardware: CPU - CU
Manages operation of computer
Operates using following cycle
1. Retrieve instruction from memory
(a) This step referred to as a fetch
(b) A copy of the instruction is loaded into the IR
(c) Increment the PC
It now holds the address of the next instruction to be executed
2. Decode the instruction
Each instruction is in binary format
Instructions of form opcode operands
There is one opcode for each specic operation the CPU can perform
Operands may take the form of actual values (e.g., 105, c) or addresses (where
values are stored)
Instructions may have from 0 to 3 operands
For example:
10100101 01100000
11010101 00000110
10000101 01100001
8 bit opcode, 8 bit operand
Performs x = y + 6
27
Computer Hardware: CPU - CU (2)
The instruction decoder circuit reads the opcode of the instruction
The circuitry of this decoder converts the opcode into signals that carry out
the execution of the instruction; e.g.
To add the contents of 2 registers and store the results into another register
To load the value at a particular memory address into the MDR
The signals enable various bus lines and devices needed for the task
3. Execute instruction
The circuitry carries out the task
28
Computer Hardware: CPU - Memory Access
Execution may require transfer of data between memory and CU
Fetch (read)
1. Load address into MAR
2. Copy contents of address into MDR
3. A fetch is non-destructive - contents of address are unaected
29
Computer Hardware: CPU - Memory Access (2)
Store (write)
1. Load address into MAR
2. Load value into MDR
3. Copy contents of MDR into address
4. A write is destructive - original contents of address are lost
30
Computer Hardware: CPU - Cache Memory
To speed up processing, CPU may have cache memory
This is high-speed memory local to CPU
Access time about 10 ns
Generally a few KB in size
Operation based on Principle of Locality:
What has been recently accessed is likely to be accessed again in near future
Used as follows:
When CPU needs something from memory
Search cache for item
if not found in cache
retrieve from main memory
store in cache
To see how it improves speed:
Assume memory fetch requires 50 ns
Assume memory fetch requires 10 ns
Assume data will be found in cache 60% of the time
Average time to fetch a piece of data:
(0.60 10) + (0.4 (10 + 50)) = 6 + 24 = 30 ns on average
Why not use cache for RAM if so fast?
Expensive
31
Computer Hardware: CPU - Processing Speed
Speed measured in
Hertz (mega, giga)
This refers to how fast the system clock ticks
MIPS (Millions of Instructions Per Second)
May require more than one clock tick per instruction
FLOPS (FLOating Point operations per Second)
Considered a more realistic measurement of speed
The system clock controls the speed at which instructions are executed
In general, each major step in CPU takes one clock cycle:
Fetch
Decode
Execute
Fetch data from memory
Write result to memory
Bus width aects transfer speeds
If bus width is 16 bits, but data is 32 bits, requires 2 memory fetches
32

S-ar putea să vă placă și