Upload
kathy
View
42
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Hardware …and the stupidity of a computer. Hardware and software. In order to make a computer do something useful, we need both hardware and software Hardware : The physical parts of the computer (monitor, keyboard, mouse and whatever is ”inside the box”) - PowerPoint PPT Presentation
Citation preview
Hardware…and the stupidity of a computer
SWC1
Hardware and software
• In order to make a computer do something useful, we need both hardware and software
• Hardware: The physical parts of the computer (monitor, keyboard, mouse and whatever is ”inside the box”)
• Software: The computer programs (Word, Messenger, Counterstrike, Internet Explorer,…) we use for solving various tasks using the computer
SWC1
The computer way
• In order to understand hardware, you need to know a little about how a computer ”thinks”
• A computer does not ”think”, it calculates!
• How can you make pieces of metal calculate anything useful…?
SWC1
On or Off
• A computer calculates using metal and current
• A computer can only ”sense” if a current is ”On” or ”Off”
• How can we employ this for doing calculations?
• A transistor is used for this exact purpose
SWC1
Transistor
• A transistor is a very simple electronic device
• Two wires lead into the transistor, one wire leads out
• The smart part: The transistor can perform a (sort of) calculation, based on whether or not there is a current in the two input wires
• A so-called logical function
SWC1
A smart (?) transistor
• So, what calculation is that?• Not so impressive, actually
A B YOff Off On
Off On On
On Off On
On On OffInput
Output
SWC1
Logical, right…?
• The calculation performed by the transistor is an example of a logical function
• A logical funtion takes one or more input values, and pro-duces a single output value
• BUT these values can only be either true or false
• Also know as Boolean logic
SWC1
Logical functions - example
A B Y
false false
false true
true false
true true
Two input values
Four possible combinations
Output
SWC1
Logical functions - exampleA B C Y
false false false
false true false
true false false
true true false
false false true
false true true
true false true
true true true
Three input values
Eight possiblecombinations
SWC1
Logical functions - transistor
A B Y
false false true
false true true
true false true
true true false
If we putOff = falseOn = true
SWC1
Zeroes and Ones
• If we now exchange true with 1 (one), and false with 0 (zero), the previous table becomes:
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
• This is how we usually denote ”On” and ”Off”
• A numeral system using only 0 and 1 is also known as a binary numeral system
SWC1
The binary numeral system
• Computers use the binary numeral system (aka base-2), humans (mostly) use the decimal numeral system (aka base-10)
• In the context of a base-10 system, 110 means: 1x100 + 1x10 + 0x1 = 110
• In the context of a base-2 system, 110 means: 1x4 + 1x2 + 0x1 = 6
• Alternatively:– 11010 = 1x102 + 1x101 + 0x100 = 110– 1102 = 1x22 + 1x21 + 0x20 = 6
SWC1
The binary numeral system• Even if binary numbers appear a bit strange, the
rules for calculation are the same as for base-10– In base-10: 5 + 7 = 12– In base-2: 101 + 111 = 1100
• Using a carry works just as before:0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0, and 1 to carry
SWC1
Transistors revisited
• The transistor we saw before was not able to do correct binary addition
• However, if you are clever enough, you can combine transistors to implement other logical functions
• Proper binary addition is just a special logical function
1+1 = ?
SWC1
Transistors revisited
• The original transistor worked like this:
A B Y0 0 1
0 1 1
1 0 1
1 1 0
SWC1
Transistors revisited
• If you combine two transistors, you can implement a different logical function
A B Y0 0 1
0 1 0
1 0 1
1 1 1
A
B
Y
SWC1
Transistors revisited
• The combination before was not very useful, but we can of course just build more complex combinations, involving more transistors
• Our goals is to be able to do binary addition • Binary addition is ”just” a special logical function,
taking three input values and producing two output values
• Can be considered to be two separate logical functions
SWC1
Binary additionA B Carry
inY Carry
out
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 0 1
0 0 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 1
SWC1
This should do the trick…
• Some clever person found out that the below combination implements proper binary addition
SWC1
The first building block
• We have now found a way to do proper addition, using metal and current
• Implementing the other arithmetic operations is then not particularly complicated
• This actually forms the foundation for the first electronic computers
SWC1
ENIAC
• Built around 1945• Weighs about 30 tons• Based on vacuum tubes• Ca. 18.000 transistors• Used for calculating
projectile trajectories• Was only operational
about half of the time…
SWC1
60 years later
• Today we do not use individual transistors. A chip contains a (large) number of transistors
• Most advanced chips contain a few billion transistors – within an area of perhaps 1 cm2
• What if car technology had progressed at the same rate:– Price: 1 $– Gas consumption: 10.000 km/l– Max speed: 100.000 km/h
SWC1
Moore’s law
• ”Within two years, the number of transistors on a chip will double”
SWC1
From 0 and 1 to Counterstrike
• Even if we can now make metal and current do calcu-lations, there is still a very long way from 0’s and 1’s to Counterstrike…
• A computer can handle vast amounts of data, at vast speeds– How fast?– How much data?
SWC1
Bits and bytes
• For a computer, the basic unit for data is an entity which is either 0 or 1
• This entity is called a bit• A computer performs operations on bits.• A more practical unit is a sequence of 8
bits; this is known as a byte.• Why 8 bits? Why not 7 or 9? Tradition…• We can for instance define a character set
using 8 bits
SWC1
Bits and bytes• How many distinct bytes are there?• One byte is 8 bits, each bit is either 0 or 1• Combinations: 2x2x2x2x2x2x2x2 = 256 (28)• Each combination can now be interpreted as a
specific symbol (letter, number, etc), for instance the letter ”H”
• With 256 combinations, we have enough combinations for capital letters, small letters, numbers, etc..
• Example: ASCII codes
SWC1
ACSII codes
SWC1
Amounts of data
• Amounts of data are usually measured in bytes (each byte being 8 bits)
• For a computer, all kinds of data are just sequences of bits
• It requires a program – written by humans – to interpret a bit sequence as e.g. music, video, a Word docu-ment, and so on
• How many bytes does each type of data require?
SWC1
Size of some data types
Plain text
(no pictures)
Music
(mp3 format)
Video
(DVD quality)
Kilo-byte Half a page --- --
Mega-byte 500-page novel
One minute One second
Giga-byte Large book-shelf
16 hours 20 minutes
Tera-byte Large library Two years Two weeks
SWC1
Speed of calculation
• When a computer calculates, it processes many sequences of bits simultaneously
• All calculation units must be ”syn-cronized” for this to work properly
• A ”conductor” manages when the calculation units should calculate
• The speed of the conductor defines the speed of the computer
SWC1
Speed of calculation
• How many ”beats per second” (hertz) can the conductor manage?
• Old computer (ENIAC); about 10.000 beats per second (10 kiloHertz)
• Modern PC; about 3.000.000.000 beats per second (3 GigaHertz)
• Also known as clock rate
SWC1
3.000.000.000 Hertz
• Three billion beats per second is quite fast…
• For every beat, light only travels 10 centimeters
• The physical size of the chip begins to matter
• Unfortunately, energy consump-tion rises with the clock rate, at a quadratic rate
SWC1
CPU
• Where are calculations actually performed?• Calculations are done in a unit called the CPU
(Central Processing Unit)• This unit is basically just one large chip, which
looks fairly uninteresting…
SWC1
The CPU and Primary Storage
• The job of the CPU is to perform calculations on streams of bits, but who provides these bits?
• Somebody has to feed bits to the CPU, and ”consume” the results produced by the CPU
• For this task, the computer uses the Primary Storage
SWC1
Primary Storage• A calculation involves the below steps
– Input data is moved from primary storage to the CPU– The CPU performs the calculation– The result is moved from the CPU to primary storage
• The primary storage is thus just a ”container” for a certain amount of data
• The primary storage is ”passive”; no kind of data processing is performed here
• Primary storage is usually of the type RAM (Random Access Memory)
SWC1
Primary Storage
• What is primary storage physically?• Just some chips, which contains a
certain amount of data• A modern PC will typically have 2-8
Gigabytes of primary storage• What could the data represent? For
instance data from an mp3-file, for which the CPU must perform some calculation to transform it into music
SWC1
Primary vs. Secondary
• Primary storage (RAM) has a large advantage: transfer of data between the CPU and RAM is quite fast (several Gigabytes pr. second)
• Fast – but compared to what?• There are however also several drawbacks:
– RAM is expensive (compared to what?)– When power is cut, all data in the primary storage will
be lost
• We thus also need secondary storage
SWC1
Secondary storage
• Who provides data to the primary storage? That data is provided by secondary storage
• What is secondary storage? In principle the same as primary storage – a passive container for data - but– Is much cheaper than RAM (per byte)– Data is preserved when power is turned off
• Presently, the most common form of secondary storage in a PC is a hard drive
SWC1
Quite hard…(old school)
• A (traditional) hard drive con-tains a number of magnetic platters, on which individual bits are stored by magnetising a specific area of the platter
• A modern hard drive contains 500-2,000 Giga-bytes of data
SWC1
Quite hard…(new school)
• A SSD (Solid-State Drive) hard drive contains a number of memory chips, on which individual bits are stored in transistors (but retained when power is turned off)
• A modern SSD contains 60-500 Giga-bytes of data
SWC1
Hard drive vs. RAM
Hard drive
(Traditional)
Hard drive
(SSD)
RAM
Typical amount in PC
500-2000 GB 60-500 GB 2-8 GB
Price pr. Gigabyte
≈ 0,5 kr. ≈ 10 kr. ≈ 100 kr.
Data transfer speed
0,1-0,3 GB/sek 0,5-1 GB/sek 4-8 GB/sek
Preserves data without power
Yes Yes No
Technology Mechanical Electronic Electronic
SWC1
Harddisk vs. RAM
• In other words:• RAM:
– Very fast and stable, BUT– Expensive, does not preserve data
without power
• Hard drive:– Cheap, large capacity and preser-
ves data without power, BUT– Rather slow, mechanical technology
(except SSD)
SWC1
Other types of secondary storage
USB-key CD, DVD and Blu-ray
Floppy disks Online
Capacity
(Gigabytes)
2-256 0,7-30 0,0015 (!) ??
Price
(kr pr. GB)
Ca. 10 Ca. 1 >100 ??
Speed
(MB pr. sek)
10-100 25 < 1 Depends on connection
Technology Electronic Optical / Mechanical
Magnetic / Mechanical
Internet
Note Same tech as SSD
Stagnant Almost extinct
On the rise
SWC1
Motherboard
• A PC contains a board, on which the central components of the PC are mounted – this board is usually denoted the motherboard
• The motherboard will (at least) contain– CPU– RAM (primary storage)– Auxiliary components– Sockets/slots for adding ”other components”
SWC1
Other components
• Examples of ”other components” are:– Graphics card– Sound card– Network card– TV card
• In some PCs, these components are found directly on the motherboard, on others they are found as extra components, inserted into slots on the motherboard
• Why…?
SWC1
Other components
• Even though a modern CPU is very fast, it may benefit from being relieved from certain tasks
• Graphics card– Specially designed for effective
graphics calculations– Takes computational load off CPU– May increase graphical performance
by a factor 100– Typical application: GAMES!
SWC1
SWC1
SWC1
Data exchange by bus
• All these units and components need to exchange data in order to do their job
• How do they do that?• Data exchange is done using
so-called data buses• A data bus transports data
between two units
SWC1
Data exchange by bus
• A data bus sends data:– A number of times pr. second– A certain amount of data each time
• Example: a 32-bit bus running at 100 Mhz– Carries 32 bit (4 bytes) each time– Sends 100 million times pr. second
• A PC contains a number of buses running at different speeds
SWC1
Countryside bus
• A bus is also used for exchanging data with additional components, like a graphics card
• Types of buses for extra components:– PCI (Peripheral Component Interconnect) – those
slots in which additional components (such as a graphics card) can be inserted
– USB (Universal Serial Bus) – used by many external devices such as printers, USB memory keys, etc..
• Fortunately, buses follow a standard
SWC1
External devices
• Devices which enable communication between humans and computers
• Typical external devices– Keyboard and mouse– Monitor– Speakers / headset– Printer
• But also– Digital camera, phone, USB-key, …