Lecture 2. How computer work? - Department of Computer Science

advertisement
Lecture 2. How does the
computer work?
Prof. Sin-Min Lee
Department of Computer Science
• Practice, Practice, Practice!
Use casette tape recorder to listen, practice
Try videotaping
Seek feedback from friends
Use phrases, not sentences
Notes separate from slides (don’t read slide)
Pick appropriate font, size (~ 24 point to 32 point)
Estimate talk length
2 minutes per slide
Use extras as backup slides (Question and Answer)
Use color tastefully (graphs, emphasis)
Don’t cover slides
Use overlays or builds in powerpoint
‘Computer” of the day
Jacquard loom
late 1700’s
for weaving silk
“Program” on punch cards
“Microcode”: each hole
lifts a set of threads
“Or gate”: thread lifted if
any controlling hole punched
Card Punch
• Early “programmers” were well-paid (compared to loom operators)
Computer Architecture =
Instruction Set Architecture + Machine Organization + …
Instruction Set Architecture
• Instruction set architecture is the attributes of a
computing system as seen by the assembly
language programmer or compiler. This includes
– Instruction Set (what operations can be performed?)
– Instruction Format (how are instructions specified?)
– Data storage (where is data located?)
– Addressing Modes (how is data accessed?)
– Exceptional Conditions (what happens if something goes
wrong?)
• A good understanding of computer architecture is
important for compiler writers, operating system
designers, and general computer programmers.
Understanding Computer Basics
Computer Case- The part of a computer system that houses the microprocessor, the RAM
(Random Access Memory), and the Motherboard. This case also houses the disk drives.
CPU (Central Processing Unit) - A chip or circuit that interprets and executes programs by
processing a list of machine instructions which perform binary operations on data stored in
memory. The portion of hardware in a computer which interprets instructions and then
executes them. It is the heart of any computer system.
Memory-
The internal component that the computer uses to temporary store data and
programs . There are two kinds of computer memory: RAM (Random Access Memory) and
ROM (Read-Only Memory). RAM loses its data if the power is turned off; ROM retains its
information whether the computer has power or not. Users are unable to erase ROM. Not to be
confused with storage devices such as hard drives, floppy disks, or other such devices. Data is
processed in RAM memory; it is stored on a storage device.
Motherboard- The main circuit board in the computer.Every device is connected
to the Motherboard. Also called planar, system board, or backplane, depending on
the architecture of the board.
Aug. 31, 2004, 12:05AM
Big gain in small package
Intel test chip boasts technology to add to
speed
Intel, the world's biggest semiconductor maker, said Monday
it built a test chip with a new process that creates faster
circuits by packing 10 million transistors into an area the size
of the tip of a ballpoint pen.
Intel, based in Santa Clara, Calif., has made the first working
memory chip that uses so-called 65-nanometer technology to
shrink the circuits inside chips, Intel researcher Mark Bohr
said during a conference call.
Video Card –This card connects to the Motherboard and the computer monitor
connects to the videocard. That is how images are interpreted and displayed to the
monitor.
Network card- Device connected to the motherboard which is used for communicating
on a network to other computers, printers and other electronic devices (ex. Phones, cell
phones ect…)
Network Card- Device connected to the motherboard which is used for
communicating on a network to other computers, printers and other electronic devices
(ex. Phones, cell phones ect…)
Network Card Driver- A program that instructs the device on how to operate.
Hard Drive- A device that is connected to the motherboard and is used for storage of
data files. Usually this device is referred to as your c:\ drive. Storage capacity can be
measured in Kb, Mb, Gb and Tb.
Floppy Drive- A device that is also connected to the motherboard that allows you to
use a portable storage media called floppies;which are used to store data. The floppies
come 5 ¼’’(which are no longer popular) and 3 ½’’ sizes (which is still the most
widely used media up-to-date.). The floppies storage capacity is no where near the
storage capacity of a harddrive. ( Ex. 1Gb Harddrive can hold information that is on
695 floppies);Get the point?
Bit
so a k is...
k in computing is short for kb or kilobyte
where kilo means the same as anywhere else in our measurement system:
1000
so a k is 1000 bytes
how about Mb?
b for byte again, and M for mega: megabyte
big M for mega, small m means milli, or one thousandth, 1/1000
as in mm, thousandths of a metre
mega in our measurement system means one million, 1 000 000
or a thousand thousand, so a megabyte is a thousand kilobytes or one million
bytes
how about GB?
you can now buy hard disk drives in Gb, gigabytes, thousands of Mb or
thousands of millions of bytes, so a 5Gb HDD holds 5000 Mb of data
with some large computers storing up to Tb, terabytes...
yup, thousands of Gb...
so one terabyte (Tb) = 1000 gigabytes (Gb) = 1000 000 megabytes (Mb) =
1000 000 000 kilobytes (kb) = 1 000 000 000 000 bytes or one thousand
billion bytes of information
CD-ROM DRIVE- means Compact Disk - this drive uses a laser to read (read-only) the
information in the tiny but complex pattern stamped permanently onto computer compact disks.
Read Only Memory CD's are much tougher than floppies, and hold more than 600Mb of
information CD-writer drives are now available,so people can burn their own CDs, e.g. to backup
files permanently established computer shops or print shops now have their own CD-writers, and
will backup your files by burning them.You can also record your music CD.
What is a Computer?
•
•
•
•
•
•
Data
Primitive Operations
Sequence Control
Data Access
Storage Management
Operating
Environment
May be actual hardware
computer or softwaresimulated computer.
Most computers a
combination of the
two.
In mathematics you don't understand things. You just get
used to them.
John von Neumann
Typical Machine Layout
Two cycles:
•Fetch cycle - get instruction
•Execute cycle - do operation
Typical Machine Execution
Typical fetch cycle: (M(x) means contents of x)
1. M(IC)  MAR [Memory Address register]
2. IC +1  IC [Instruction Counter]
3. Read memory into MDR [Memory Data
Register]
4. MDR  IR [Instruction Register for
decoding]
Typical Machine Execution
(continued)
Typical execute cycle: (OP R,X, DISP is instruction)
1. IR decoded into OP R, EA
–
–
–
OP is operation code (e.g., 8 bits)
R is register (e.g., 4 bits -- 16 registers)
EA is effective address (e.g., 20 bits)
2. M(X)+DISP  MAR (EA  MAR)
3. Read memory into MDR
4. M(R)  ALU; M(MDR)  ALU
5. Do operation OP in ALU; ALU  R
For 500 MHZ: Each instruction 9-10 cycles (50 MIPS)
By overlapping fetch and execute cycles, get 60-70 MIPS
Typical Machine Translation
Instruction format:
Opcode
register, index, offset
load
R1, R2, 24
For example: As we see later, memory for data in blocks of storage
pointed to by a register:
X=Y+Z
could be translated as:
load R1, R2, 28
[Location of Y]
add R1, R2, 40
[Location of Z]
store
R1, R2, 24
[Location of X]
Ways to Construct a Computer
• Hardware Realization
– Any precisely defined algorithm or data
structure may be realized in hardware.
• Firmware Realization
– Microprogramming or emulation
• Virtual Machine
– Provided by a language environment
• Combination
Von Neumann Model of Execution
Instruction
Obtain instruction from program storage
Fetch
Instruction
Determine required actions and instruction size
Decode
Operand
Locate and obtain operand data
Fetch
Execute
Result
Store
Next
Instruction
Compute result value or status
Almost all Modern
Computers are
Von Neumann
machines
Deposit results in storage for later use
Determine successor instruction
Decimal system, base 10
•
•
•
•
•
•
•
History -- we have 10 fingers
253 means 2*100 + 5*10 + 3*1
1,10,100 (from R to L) are the “weights”
10 digits, values 0 through 9
After 9 comes 10 (double digits)
Grade school learn by rote 7*9 = 63
Nothing magic -- we are trained on it
Octal system, base 8
•
•
•
•
•
•
•
Mickey Mouse has 8 fingers
253 means 2*64 + 5*8 + 3*1
1, 8, 64 are the weights
8 digits, values 0 through 7
After 7 comes 10
Used to display memory addresses in some
older computers e.g., 177462
Hexadecimal system, base16
•
•
•
•
•
•
16 digits, values 0 - 9 and A-F
3B6 means 3*256 + B*16 + 6*1
1, 16, 256 are the weights
After F comes 10
Used to display memory addresses in most
modern computers e.g., 3C0F 95EA
Binary system, base 2
•
•
•
•
•
2 digits, values 0 and 1
1011 means 1*8 + 0*4 + 1*2 + 1*1
1, 2, 4, 8 are the weights
After 1 comes 10
Count 0 1 10 11 100 101 110 111 1000
Binary system, base 2
• Used to do calculations in all computers
• Used to store values in memory and on disk
• Not practical for people
•
100101011101 = 4701
Best way to use number systems
• Binary system inside the computer
• (storage and calculations reduce to simple
•
logic, the main subject of Comp 120)
• Input-Output done in decimal for user
• Software translates in both directions
Convert Binary to Decimal
• Binary Value 10101
• 1*16 + 0*8 + 1*4 + 0*2 + 1*1 = 21
•
•
•
•
Convert these:
1100 = ?
1001 = ?
0111 = ?
Convert Decimal to Binary
Given decimal value 53
53
64
21
32
1
18 = ?
31 = ?
5
16
1
8
0
4
1
2
0
1
1
1
Decimal notation with fractions
•
•
•
•
•
•
72.53 means:
7*10 + 2*1 + 5*.1 + 3*.01
The “.” is the decimal point
Weights are 100 10 1 “.” .1 .01 .001
This is not scientific notation
This is not floating point storage
Binary notation with fractions
•
•
•
•
•
•
•
110.10 binary means:
1*4 + 1*2 + 0*1 + 1*.5 + 0*.25 = 6.5 dec
The “.” is the binary point
Weights are 8 4 2 1 “.” 1/2 1/4 1/8
This is not scientific notation
This is not floating point storage
11.11 binary = ? decimal
Memorize dec, hex, binary counts
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
000
001
010
011
100
101
110
111
8
9
10
11
12
13
14
15
8
9
A
B
C
D
E
F
1000
1001
1010
1011
1100
1101
1110
1111
Convert Binary to Power 2 base
• Very easy -- convert digit-by-digit
• A27F <=> 1010 0010 0111 1111 (Hex-Bin)
• 327 <=> 011 010 111 (Octal-Binary)
• B4C5 = ?
• 1010 0110 1001 = ?
Download