1 HowComputerWorks

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

 

                  Computer Programming for Engineers 

How does a computer work? 
What is a computer?
Computer
A computer is a general purpose device that can be
programmed to carry out a set of arithmetic or logical
operations automatically. (Wikipedia)
Computer = Hardware + Software

• “Hardware” refers to the 
physical components of 
the computer 
• “software” refers to the 
code that runs on the 
computer 
Like piano and a piano score
Computer Hardware consists of
the IPO (Input, Processing, Output)
Structure

Input Processing Output


CPU (Central Processing Unit)

• Serves as the brain of the computer


• Performs simple operations
• e.g. Add two numbers, compare two
values, jump to a location
• Computer can run 2 billion operations per
second
RAM (Random Access Memory)

• Access means to read or write


• A temporary, working storage
• "volatile", not "persistent", the stored
information is lost if power is out
Persistent
Storage

• Persistent storage
 "Non volatile" .. Stored information is preserved when
the power is out
• Hard disk drive (HDD) - stores bytes as a magnetic
pattern on a spinning disk
• Flash drive - stores bytes as electrons in a chip -SD
card, flash chips built into a phone or tablet
3학년 과목 “전자재료”에서 자세하게 다룸.
Chips and Transistors
• Computers use tiny electronic components (i.e., chip)
which can be etched on silicon
• A Chip (or an integrated circuit) can contain billions
of transistors
• A Transistor is a semiconductor device used to
amplify and/or switch electronic signals and
electrical power
  On: 1, Off: 0

2~3학년 과목 “반도체소자”에서 자세하게 다룸.


Analog and Digital 
• Analog 
– Continuous values such as sound, voltage, electrical 
current, temperature, speed, and pressure 
• Digital 
– Discrete values which can only take on one of a finite 
number of values 
Bitmap Image 
• Bitmap images are made up of pixels. Each pixel represents a color. 
• The number of pixels in an image is called resolution 
• 1 is black and 0 is white, then a simple black and white picture can be 
created using binary. 
Bitmap Image 
• Bitmap images are made up of pixels. Each pixel represents a color. 
• The number of pixels in an image is called resolution 
• 1 is black and 0 is white, then a simple black and white picture can be 
created using binary. 
Bitmap Color Image 
• Instead of using one bit for each pixel, using more bits allow 
an image to use more colors 

2 bit 
00  01  10  11 

8 bit gray‐scale 
00000000 11111111
10101000
24 bit Red‐Green‐Blue (RGB) 

Red  Green  Blue 


Represent Numbers in Binary 
• For  representing  numbers  in  base  2,  there  are  two  possible 
digits (0, 1) in which each column value is a power of two:   
Bits and Bytes 
• Each binary digit is referred to as a bit.   
• A group of 8 bits is called a byte.  
• The  range  of  integers  that  can  be  represented  depends  on  the 
number of bits used 

Number of bits Number of Bytes Formula Range


8 1 28 - 1 0 - 255
16 2 216 - 1 0 - 65,535
24 3 224 - 1 0 - 16,777,215
32 4 232 - 1 0 - 4, 294,967,295
Sound 
• Sound needs to be converted into binary for computers to be 
able to process it. To do this, 
1. A microphone captures 
sound. 
2. Sampling: to convert a sound 
wave to a sequence of 
samples, where a sample is a 
value at a point in time. 
3. Quantization: the samples 
are converted to binary, being 
recorded to the nearest 
whole number. 
Time sample 1 2 3 4 5 6 7 8 9 10
 
Decimal 8 3 7 6 9 7 2 6 6 6
 
Binary 1000 0011 0111 0110 1001 0111 0010 0100 0110 0110
 
Software (or Program) 
• A series of instructions that directs a computer to 
perform specific tasks or operations (Wikipedia) 
• A program is text that is written following a set of 
certain rules. i.e., a programming language 
• 2 Types of programming languages 
– High‐level languages 
• Human readable 
• Needs translation to be executed 
– Low‐level languages 
• Consists of binary values 
• Specific to CPU and can be executed directly 
20
Software (or Program) 
• A series of instructions that directs a computer to perform specific tasks 
or operations 

• Encoding is the process of converting analog signal (e.g., letters, 
characters, and other symbols) to digital formats 
• Decoding is the process of converting digital signal to the original analog 
signal 
 
– Number 
– Text 
– Sound 
– Image 
Text 
• ASCII code table 
– ‘A’ would become 65 
– ‘a’ would become 97 
– ‘0’ ~ ’9’ would become 
48 ~ 57 in base 10 numbers 
Text 
• When  any  key  on  a  keyboard  is  pressed,  it  needs  to  be 
converted into a binary number 
Alan Turing is called “the father of
computer science” (1936)
Compiler 
• Transforms a high‐level source code directly 
into machine code 
– C, C++, Java 
– E.g., Compiler takes in Firefox C++ source code, 
produces Firefox.exe 
firefox.exe

1) Translate

2) Run 25/35
Interpreter 
• An Interpreter is a program which "runs" other code 
• The interpreter carries out a single line of the source 
code while reading it and proceeds to the next line 
– Python, Javascript 

A=1234
B=4321 translates
C=A+B Translate and Run  
line by line 

26/35
A program example 
• Programs for adding 1234 and 4321 

A=1234
B=4321
C=A+B

Python Assembly Machine code

27/35
http://www.dspguide.com/ch4/5.htm

You might also like