Transcript Outline

บทนำสู่คอมพิวเตอร์
Outline
•
•
•
•
•
•
Computer Concepts
Computer Components
Software
OS
How to write a program?
Program development
Computer Concepts
• Computers
– Universal Computational Devices
• Given enough time and memory, all computers are capable
of computing exactly the same things (irrespective of speed,
size or cost).- Turing’s Thesis
– Level Categorization
Algorithm
Program/Software
Machine Architecture
Circuits
Devices
Application Software
OS
Devices
• Each Mother board is
composed by
Hundreds of ICs
(Integrated Circuits).
• Each IC could
composed by millions
of transistors.
• A CPU is also
composed by millions
of transistors.
• What is a transistor?
VIA pc3500 Mainboard
Devices - Transistors
Open switch:
no current flows
Closed switch:
current flows
• Similar to a light switch
• Opened/Closed status depends on voltage
provided
Devices - Transistors
• Symbolic Transistors (CMOS)
A
A
P
N
G
B
Open if gate is “on”
Closed if gate is “off”
G
B
Closed if gate is “on”
Open if gate is “off”
Devices - Transistors
• An OR Gate built from transistors
A
a
b
B
C
OR gate
D
c is 1 if either
a or b is 1
c
Logic Circuits
• Adder Logic Circuits built by logic gates
Computer Architecture
• Composed by CPU (Central Processing Unit), Memory,
and I/O.
• These three are connected by buses.
• When computing, data are fetched from memory to CPU.
CPU
Main Memory
I/O
buses
Computer Architecture - CPU
• Composed by ALU (Arithmetic & Logic Unit) and CU (Control Unit)
• ALU – computing
• CU – sequence control
ALU
CPU
CU
Main Memory
I/O
buses
Computer Architecture – Main Memory
•
•
•
•
•
•
2-based numbers, each called bit.
8 bits = 1 byte
1 kilobyte = 1024 bytes
1 megabyte = 1024 x 1024 bytes
1 gigabyte = 1024 x 1024 x 1024 bytes
1 terabyte = 1024 x 1024 x 1024 x 1024 bytes
1 byte
1 0 1 1 1 0 0 1
1 0 1 1 1 1 0 0
0 0 0 1 1 1 0 0
Main Memory
0 0 1 1 0 1 0 1
1 1 1 1 1 1 1 0
CPU
1 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
I/O
buses
Computer Architecture – I/O
• Input/Output Devices
• E.g. hard disk, CD/DVD reader, modem, wireless card,
keyboard, mouse, etc.
CPU
Main Memory
I/O
buses
OS
• OS - Operating System
• What are OSs?
– Programs that work between computer
hardware and application programs.
– [Computer] Resources Manager
• Resources including: CPU time, memory, I/O
devices
0 1 0 0 0 0 0 1
0 0 0 1 1 1 1 0
0 0 0 0 0 0 0 0
Main Memory
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 1 1 1 0 0 1
1 0 1 1 1 1 0 0
Data zone
• A Sequence bits of command
• E.g. if we want to calculate the
average value, we need to put
the commands: 0100 0001 then
0001 1110 which change the
following bits (0, 0), (1, 2), (2, 2),
(3,4) from 1 to 0, then change
(1, 1) and (1, 3) from 0 to 1,
then….
• We call such the sequence as a
program/software.
Instruction zone
Application Software
0 1 0 1 1 1 0 0
Main Memory
0 0 1 1 0 1 0 1
1 1 1 1 1 1 1 0
1 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
How can we write a program?
• Machine Code
1 0 1 1 1 0 0 1
1 0 1 1 1 1 0 0
0 1 0 1 1 1 0 0
• Assembly
ORG 80000
MOV A, #1
ADDA R0
How can we write a program?
• High-level Language
csum=0;
for i=1:10
a(i)=input('Enter a data entry:');
csum=csum+a(i);
end
avg=csum/10;
Program Development
•
•
•
•
•
Problem Formulation
Input/Output
Algorithm Development
Implementation
Analysis & Testing
• Requirement Specification
• Design
• Coding
• Debugging
• Installation
• Maintenance
Communicate with other
programmers?
• Flow chart
g==n
display ‘You got it.’
return
g>n
display ‘Less than this.’
display ‘Greater than this.’
Communicate with other
programmers?
• Pseudo code
Example: find max element of an array
Algorithm arrayMax(A, n)
Input array A of n integers
Output maximum element of A
currentMax  A[0]
for i  1 to n  1 do
if A[i]  currentMax then
currentMax  A[i]
return currentMax