Chapter 01 Introduction To Computer
Chapter 01 Introduction To Computer
www.basiccomparch.com
Download the pdf of the book
videos
Computer Architecture
The view of a computer as presented to software
designers
Computer Organization
The actual implementation of a computer in hardware.
3
What is a Computer ?
4
How does it work ?
Information
Program
store
Computer
results
CPU
Hard disk
Memory
6
Memory Hard disk
Computer
Memory – Stores programs and data. Gets destroyed when
the computer is powered off
Hard disk – stores programs/data permanently
7
Let us make it a full system ...
Memory Hard
disk
Computer
Keyboard Monitor
Mouse Printer
8
Food for Thought...
9
Answer ...
10
Outline
Language of Instructions
Instruction Set Architecture
Features of an ISA – Complete, Concise, Generic, Simple
Completeness of an ISA
Turing Machines
Universal Machines
Single Instruction/Multi-Instruction ISA
Road Ahead
11
How does an Electronic Computer
Differ from our Brain ?
12
How to Instruct a Computer ?
compile execute
Program Executable Output
14
The Language of Instructions
Humans can understand
Complicated sentences
English, French, Spanish
Computers can understand
Very simple instructions
15
Features of an ISA
Example of instructions in an ISA
Arithmetic instructions : add, sub, mul, div
Logical instructions : and, or, not
Data transfer/movement instructions
Complete
It should be able to implement all the programs that
users may write.
16
Features of an ISA – II
Concise
The instruction set should have a limited size. Typically
an ISA contains 32-1000 instructions.
Generic
Instructions should not be too specialized, e.g. add14
(adds a number with 14) instruction is too specialized
Simple
Should not be very complicated.
17
Designing an ISA
Important questions that need to be answered :
How many instructions should we have ?
What should they do ?
How complicated should they be ?
RISC CISC
(Reduced Instruction Set (Complex Instruction
Computer) Set Computer)
18
RISC vs CISC
19
Summary Uptil Now ...
Computers are dumb yet ultra-fast machines.
Instructions are basic rudimentary commands used to
communicate with the processor. A computer can execute
billions of instructions per second.
The compiler transforms a user program written in a high level
language such as C to a program consisting of basic machine
instructions.
The instruction set architecture(ISA) refers to the semantics of
all the instructions supported by a processor.
The instruction set needs to be complete. It is desirable if it is
also concise, generic, and simple.
20
Outline
Language of Instructions
Instruction Set Architecture
Features of an ISA – Complete, Concise, Generic, Simple
Completeness of an ISA
Turing Machines
Universal Machines
Single Instruction/Multi-Instruction ISA
Road Ahead
21
Completeness of an ISA
Complete means :
Can implement all types of programs
For example, if we just have add instructions, we
cannot subtract (NOT Complete)
22
Completeness of an ISA – II
23
Answer
Let us look at results in theoretical computer science
Is there an universal ISA ?
The universal machine has a set of basic actions, and each such
action can be interpreted as an instruction.
24
The Turing Machine – Alan
Turing
Facts about Alan Turing
Infinite Tape
L R
26
Operation of a Turing Machine
There is an inifinite tape that extends to the left and right. It consists
of an infinite number of cells.
The tape head points to a cell, and can either move 1 cell to the left
or right
Based on the symbol in the cell, and its current state, the Turing
machine computes the transition :
Computes the next state
Overwrites the symbol in the cell (or keeps it the same)
Moves to the left or right by 1 cell
The action table records the rules for the transitions.
27
Example of a Turing Machine
$ 7 3 4 6 9 $
Tape Head
Start from the rightmost position. (state = 1)
If (state = 1), replace a number x, by x+1 mod 10
The new state is equal to the value of the carry
Keep going left till the '$' sign
28
More about the Turing Machine
29
Church-Turing Thesis
Definition:
Any computing system that is equivalent to a Turing machine is said to be
Turing complete.
30
Universal Turing Machine
For every problem in the world, we can design a Turing Machine
(Church-Turing thesis)
Can we design a universal Turing machine that can simulate any
Turing machine. This will make it a universal machine (UTM)
Why not? The logic of a Turing machine is really simple. We
need to move the tape head left, or right, and update the
symbol and state based on the action table. A UTM can easily do
this.
A UTM needs to have an action table, state register, and tape
that can simulate any arbitrary Turing machine.
31
Universal Turing Machine
32
A Universal Turing
Machine
Simulated State Register
Simulated Action Table Work Area
L R
Generic State Register Tape Head
33
A Universal Turing
Machine - II
Program
Counter
Simulated State(PC)
Register
Instruction
Simulated Action Table Work Area
Memory Data Memory
L R
Generic State Register Tape Head
Program
PC CPU
Generic Action Table
Computer Inspired from the Turing
Machine
Program
CPU
Program Control Arithmetic
Counter (PC) Unit Unit
Instruction
Program Data
Memory
35
Elements of a Computer
Memory (array of bytes) contains
The program, which is a sequence of instructions
The program data → variables, and constants
The program counter(PC) points to an instruction in a program
After executing an instruction, it points to the next instruction
by default
A branch instruction makes the PC point to another instruction
(not in sequence)
CPU (Central Processing Unit) contains the
Program counter, instruction execution units
36
Let us now design an ISA ...
1: sbn temp, b, 2
2: sbn a, temp, exit
37
Single Instruction ISA - II
Add the numbers – 1 … 10
Initialization:
one = 1
index = 10
sum = 0
exit
38
Multiple Instruction ISA
Arithmetic Instructions
add, subtract, multiply, divide
Logical Instructions
or, and, not
Move instructions
Transfer values between memory locations
Branch instructions
Move to a new program location, based on the values of some
memory locations
39
Outline
Language of Instructions
Instruction Set Architecture
Features of an ISA – Complete, Concise, Generic, Simple
Completeness of an ISA
Turing Machines
Universal Machines
Single Instruction/Multi-Instruction ISA
Road Ahead
40
Designing Practical Machines
CPU
ALU
Instruction
Data
memory Control memory
I/O devices
Harvard Architecture
41
Von-Neumann Architecture
CPU
ALU
42
Problems with Harvard/ Von-Neumann
Architectures
The memory is assumed to be one large array of
bytes
It is very very slow
Solution:
Have a small array of named locations (registers) that can
be used by instructions
This small array is very fast
43
Uses of Registers
44
Example of a Program in Machine
Language with Registers
1: r1 = mem[b] // load b
2: r2 = mem[c] // load c
3: r3 = r1 + r2 // add b and c
4: mem[a] = r3 // save the result
45
Machine with Registers
CPU
Registers
ALU
46
Outline
Language of Instructions
Instruction Set Architecture
Features of an ISA – Complete, Concise, Generic, Simple
Completeness of an ISA
Turing Machines
Universal Machines
Single Instruction/Multi-Instruction ISA
Road Ahead
47
Where are we ...
We have derived the structure of a computer from
theoretical fundamentals.
It has a CPU with a program counter & registers,
memory, and peripherals.
The Instruction Set Architecture (ISA) is the link
between hardware and software.
Instruction
Set
Architecture
48
Instruction Set Architecture
49
Roadmap of the Course
System design
Software interface Processor Design 10
50
THE END
51