Fundamentals of Computing: Followinga Set Produces (Output)

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

CHAPTER

Fundamentals of Computing
"Conuters are uscless. Ther can onhv gie you answers. Pablo Picasso

0.1What is a Computer?
an advanced clectronic machine that takes raw data from the user as input, stores
Acomputer is
and processesit followinga
set of instructions that produces some result (output). Processing is
Jsne hy electronic processors which come in the form of micro-chips. A computer can work as
a some instructions stored in its memory that direct the processors.
a computer that we can touch and see, such as CPU (Central Processing
The physical parts of program
1init) Monitor. Keyboard, Mouse etc., are called Hardware. The instructions are called
or code or
software.

0.2 Hardware
Computer Architecture and Organization
Computer Organization is concerned with the way the hardware components are connected to
assumed to be in
form a computer system and the way they operate. The various components are
place and the task is to investigate the organizational structure to verify that the computer parts
operate as intended.
specifications of the various
The architecture of a computer system is concerned with the
functional modules, such as processors and memory units, and structuring them together into a
computer system.
According to von Neumann
The modern computers are based on von Neumann Architecture.
Architecture, the basic structure of a computer should consist of the following components.
Input/ Output Unit
Arithmetic Logic Unit (ALU)
Control Unit (CU)
Storage/ Memory Unit
Bus

Input Unit
Input unit takes data and instructions from the user to interact with the computer system. The
input devices are Keyboard, Mouse etc.
ofComput

Fundamentals {
2Cheries 0
Computing
Output Dnit cnptstion - the data and instructions to the usr
the reults of The
tprvsstes
are Montn Irinte

metic Logic Unit(ALU) calculations performed by ALU


are
Arith
Allthe
rathematcal andlogical
storage unit
When the
trasferredto the
doe. therut

Control Unit from ALUto storage unit andIback


flow of data andinstructions
t controkthe
Processing Unit
CPU Central together is called the Central
Arthrnet Logc unit and the Control unit Prco
The
acomputer!
(CP tn like the bramn of

Storage Unit intermediate results are ct.e


and instructions. Input data and
Ths unt holds the ata units:
categories of the storage or imemory
future use There are two man

RAM Random Access Memory.


When the computer is switched off the
This Is used for temporary storage of data.
there are different types of RAMasal.
Is lost RAM is used as primary storage. Also,
most pcrsonal
DRAM (Dynamic Random Access Memory), used in
cOmpulerS
and more volatilc that D?
SRAM (Static Random Access Memory), faster
but requires More power to operate.
Memorv), atype ot D.
SDRM (Synchronous Dvnamic Random Access
that has higher processing speed.

ROM Read Only Menmory


This is uscd for permanent storage of data. ROM is treated as secondary
devices afc Hard Disk, CD, DVD etc Usually, the secondary nenory
chrapet than the prmary memory.
Bus
Buscs alc thc connunicalion channcls (winng plus connectors) that connects the
broke) at
bus is
prmary slotage and nput output devices. Communication on a pertormanceotsbust
iscrele iransactions. Lach ransaction has asender and a receiver. The bundsdhlsometi
dcfncd by Iwo parancterS, the uanster
me, and the overall
Funda menta ls of Computing |3

Bandwidth, cxpresscdin units ofbits per second (bps), mcasures the capacity
called.throughput).
www.phy.ornl.gov/csep]
ofthe bus. (Source:
Computer Architecture
Big. 1: Block Diagram for
Storage Unit

Secondary
Storage

Output Information
Input Unit
Data Unit
Primary
Storage

Control Unit
(CU)

"ooooe Control Flow


Arithmetic
Data Flow
Logical Unit
(ALU)

Central Processing Unit


(CPU)

0.3 Software
to instruct the processors. But the processors do not
To make the computers to do their job means
programming languages evolved
understand human language. So, there are various computer or machine.
interact with the
which are compiled or translated or interpreted to
There are two major types of computer languages:
Low-level language
High-level language
extensive knowledge in
Low-level languages are closer to the way a machine works. VWe require
hardware and understanding of the configurations to deal with them. Low-level languages are
further divided into Assenbly language and Machine language.
f
Funda mentals o
4/Chapter
0.

a computer,
made of
Comput
logic
ing
processorsiN gates
oftwo kinds, let us say I (or
Theclectronic
signalshigh orlow.
So,the signals
when
and 0. switches) Can
fed into a
1100110. The
sequences of such
codes
computer,
it um eN
convertintoclectrical
0.3.1 Machine Language
signals. The clcctrical signals are necessary; for rwoecrokginngzS hsehc.
oi

Machine languagee code is basically some strings of0's and 1's. A


A
compilercomputcr
language. It does not
directlyunderstandthe Machine
language.
require a or oT aToac.
machine the
instructions are given through a
works faster. However, writing
know the details of the hardware
a
architecture. Also. for
computer can
code in machine language is difficult Teadily
as
the interpraet,
common users,
large code(all kinds of sequences of l's and 0's). It is difficult to fix
it is
any error that 8taota.
code. In computer terminology, the tiXing oI error is called 'debugging'
difprcoulgatti sa:
debugging is difficult for the machine language.

0.3.2 Assembly Language


Communications through our languages are full of digits and letters. In order
to
the machine language, Assembly language was constructed witha set of letters and improve ;:
'translator" program that converts an Assembly language into a Machine symbol..
'Assembler.It is thuscalled a second-generation language. The assembly language languageis isease :
understand and to handle by a programmer in compared to machine
language. But :
disadvantage lies in the fact that an assembly language is still machine dependent as it is w
following the specific hardware configurations of a machine. So, the
language writen for one computer might not work for other programs in asst
computers.
0.3.3 High Level
Language
For common users, it is
not always to have a deep knowledge about the compu
necessary
hardware. Therefore, high level languages are developed, which carry out instructionsgiven
English words following the logical steps. So, ahigh level computer language mainlyconNINSO
simple English words,
i 0, 0... numbers and some mathematical and other symbols (+,
The and
write as it is closer toadvantages of a high-level language are that it is Casyto architertu
understand
our human
language. It is independent of computer hardware
So, in terms of computer jargon, we can say, such alanguage is 'portable' (from one machine
another). The disadvantage is that it is slower as there must be acompiler orinterpcerl
"Iranslate' ahigh-level language to the machine language that the processors understand
bit

Computing |5
Funda mentals of

few high-levcl languages developed to suit


science, there have been a of levels intcrms of
history of Computer there arealso differcnces
o the purposcs. Among them, levcl languages.
orious kinds of worksor
not so and somc arc closcr to low
high; some arc
Some are very
lowand high.
Some high-levelLanguages:
Instruction Code), COBOL (Common Busincss
Allpurpose Symbolic PASCAL,
BASIC (Beginners FORTRAN (Formula Translation), C, C++, JAVA,
Oriented Language),
PEARL, PYTHON.
HASKELL, RUBY,
methods of instructions. Each has some
special kind of syntaxes and
Every such language has a However, once we understand the logic behind a
problem to solve,
advantages and disadvantages. syntaxes of a language.
program following the
we can write a
instead
0.4 Numbers
system of l'sand 0's, called binary (base 2),
computer runs on a
We now understand, the where all the mathematical calculations
implies base 10) system we use
of the Decimal ("Deci' binary numbers corresponding to
So we have the equivalent
9.
are done by 10digits: 0, 1, ...,
decimal number:
every
form a
notice the pattern, the way 0 and Icombine to
We may
Decimal Binary number. We can convert a decimal number
owN bigger and bigger
versa. Remember, in a decimal
into a binary number and vice
hundred ninety six),
number, such as 5896 (Five thousand eight
positions (Thousandth, Hundredth,
1 1
the digits occupy respective
10 number with base 10. For
tenth,..), where we can construct the
2
3 11
100 example, 6X1
5896 5x1000 + 8X100 + 9x10 +
101 101 + 6X 10
5
= 5x 103 + 8X 104 + 9x
6 110 sequence,
For a decimal fraction, we follow the similar
111 10-l + 6X 10-2
58.96 = 5X 10 + 8X 10 + 9x
1000
1001
Similarly, a decimal number can be constructed from a binary.
10 1010
Why Binary?
11 1011 "A single switch can be on or off, enabling the storage oflbit
12 1100
of information. Switches can be grouped together to store larger
13 1101
numbers. This is the key reason why binary is used in digital
14 1110 systems."
of(Cami

6/Chapter 00. Fun damentalss of Computing

(base2), wecan write.


integer
Fora binary t 1x21
+ 0x 2 = 8 + 4.
+ 1x2
1110 = 1x2 2 t
1110, = 1410

fraction,
Fora binary
=1x2' + 1x22 + 0X2' + 1x 2'+1 x2-1,+1x2-2
1101. 11,
number is important.
that the position of a digitin a Certain
diwegtignt Sig
It is obvious
in a number. Note that the right most position of a is
cach position of a digit in
called Least Significant Digit (LSD). The digit in a
lowest wejghtage and is
position has maximum weightage andis thus calledI Most Significant Digit (MSD).the
the urib:
extren.
binary number, theebit (0or 1) on the right
most position is called the Least Significa:
For a
(LSB) and the bit on the extreme left position is called the Most Significant Bit (MSB).

Decimal integer to Binary:


Inthe following, a decimal system is converted into a binary by dividing the decimal number .
2and collecting the remainders on cach stage. The quotient in one stage is taken for dni
the next stage.
Division Quotient Remainder
by 2
1410 =1110, 14/2 7 ISB
(Counting the remainders
7/2 3 1
from bottom totop)
3/2 1 1
1 MSB
1/2

Decimal fraction to binary:


Multiply Fraction Carry
0.687510 = 0.1011, by 2 part
MSB
0.6875X2 0.3750 1
(collecting the carries
from top to bottom) 0.3750X2 0.7500

0.7500x2 0.5000 1
LSB
0.5000x2 0.0000

and offintS
As said, Binary is the the oneverything
numbering system that computers use to represent level,
electronic circuits with this Ongates.
in computer is based onlogic and On' is I and'Off
Off paradigm. Theissignals
0. At the
prmary
verypass or don'tpass.
either
Funda mentaIs of Computing |7

follow a
to note that the binary numbers made with two digits I and 0,
Now, itis interesting known as Boolean Algebra.
diflerent kind of algebra. If is
Boolean Laws: = 1 (OR Gate)
0, 1, + 1 = 1, 1 + 0 = 0 + 1
0 +0 = (AND Gate)
1, 1.0 = 0.1 = 0
0.0 = 0, 1.1 = (NOT Gate)
1=0, 0 =1
that the computer processors are made of.
AND, OR, NOT are logic gates
values. So.
termed as 'A'. It is clear that A =1or 0, either of the two
Suppose asignal is A). That means, if A is True, A
(Complement of
symbolically, if we write A = 1, then A =0 complement)
and vice versa. A is NOT A. So, we can write, A = A. (Complement of
is False
the following generalBoolean
rules:
We can construct a truth table with A+ A = 4, A +A = 1
A +0= 4,
A+1= 1,
A.A = 0
A.1 = A, A.0 = 0,
basic laws of operations between digits. A binary number is a string of
So. the above are the binary numbers (such as 110 + 111) can
be
mathematical operations between
binary digits. The subtracting, and
with the above laws and there are some efficient ways of adding,
computed resources in
binary numbers. You can look up any Digital Electronics book or the
multiplying give detail here as that will be of no
direct
We will not
internet to get to know the details of that.
in this book.
use for our subsequent discussions

Bit & Byte


(0or 1) ina binary number is known as bit. A string of 8 digits (8 bits) is termed
Asingle digit
computer terminology, a 'byte' is commonly defined as a unit of computer memor,
as byte. In the
since a bit is too Small to use.

1, 11110011,...]
1 byte =Collection of8 bits [For example, 1100100
One byte can store one character, e.g., Xor'@', or M...

The 'byte' was first named in 1956, during the design of an IBM computer.
Information content in a byte
2° =
Let us think of one byte which consists of 8 digits (of two kinds: 0 and 1). So, there can be
256 different combinations. If we now consider acombination as a piece of information, then
we can have 256 different kinds of informationby a single byte!
8|Chapter 0. Fun damentals of

In a computer, a number is represented by or stored in a


patterns, We can represent 256 numbers from 0, 1,2, 3,
Comput
byte.
ing
So, by one
4...254, 255. bylc
Number Different Patterns wll?
of bits

0, 1

00, 01, 10, 11


3 000, 001, 010,
101, 110, 111 011, 100,
Thus a'byte' is a unit of f
informationstorage. For more storage, we
1KB (Kilobyte) 10 bytes
Use multiples of that:
2° wn practice it is 1024
1MB (Megabyte) 10° bytes bytes.]
1GB (Gigabyte) 10 bytes
1TB (Terabyte) 1012 bytes by tes
So. if we have a single
transistor that can handle an on/off switch per digit,
transistors process so much of information! But of
can imagine jus
course, modern day computers consist o
processors [Integrated Circuit ([C)chips] that can have a very large
number transistors.
of
0.4.1 Representation of Integers
With n-bits, the computer can encode 2
numbers, In decimal systems, we use + and- Sy
to denote positive and negative numbers. But
how do we
there are only two symbols0and 1? The left most bit is represent signed binary numueu
a
then reserved for the sign.
How can a binary number be represented on a 1-byte processor? For example, asan 8-bit (1 byte)
signed binary number,
+14
000o1 1 10
-14
1000 1||10
Funda mentals of Gmputing 9

to
left most position is used to represent a positive number and 1 is
convention, 0onthe binary number (positive or negative), the left most
Bv number. So, in a signed
representa negative magnitude.
for sign and the rest are for
bit is
done by
the additions and subtractions of binary number are efficiently
As
mentioned carlier,
l's or 2's compliment methods. We are not going to describe those
called
somespecialItechniques book on Digital Electronics for details.
here. Y'ou can consult any
nowadays have 32-bit or 64-bit processors. That
and laptops
Most Desktop Computers (PC) process a 32 bitor 64 bit long binary string at a time. So, to
can time
means, the computer processor bits. The number of bits that are processed at a
32 bits or 64
thecomputer. the word length is are the "letters for a computer word!
where the bits
iscalled a computer word,
bytes (32 bits)or 8 bytes (64 bits). For example, with 4
Integers are typically stored with either 4 numbers, counting from 0 to
4294967295, if
4294967296 diferent
bvtes, we can store 23 = and negative numbers both,
we can then store
accommodate positive
all positive. Since. we must
-2147483648 and 2147483647.
numbers between

can handle numbers between -2147483648 and


understand that a 32-bit processor
So, we can
32-bit processor handle a number beyond this limit?
2147483647. The question is, how does a
large number, when we run out of bits?
Or how does it behave for a
So, even ifwe
number a32-bit processor can handle is 2147483647.
The maximum positive -2147483648. the other end. This is called
Integer
goes to
add I more to it, the number
Overflow.

or Float
0.4.2 Floating Point Number
can be positive or negative. Numbers with decimal places
Integers are whole numbers and
or just '£loat' in computer teminology.
(tractional part) are called floating point numbers
-5.5 are all floating-point numbers.
For example. 0.5698, 1594.1237642,

represent a floating-point number, we used a dot (. ) which separated the fractional part from
To point. In case of decimal
we call this radix
the integer part. In mathematics and in computing, radix point equally applies
numbers that we usually use, it is known as decimal point. To note, this (,) is
countries, acomma
to binary numbers and it is called binarn point. [Note that in some
put on the baseline to denote a radix point.]
Comp#0
mentals o|
Funda
Z|Chapter 0,
ndstuc to the ue
dta
Output Unit lconputation- the
results of
It providesthePrintere:
are Monitor, When e
pertiwd by AU
Unit (ALU) cakulationsare
Arithmetic Logie
mathematical andlogical storage uit.
Allthe esult is transtemd to the
done, the
Ntoage mit and back.
Control Unit instruetions tion ALUo
of data and
It controlsthe tlow
Central
Central Processing
Unit
unit together is valled the
CPU: Control
Arithmetic Logic unit and the
The brain of a computer!
(CPU).It is like the
and intercdiate reNults are Ntod
Storage Unit Input d:ata
holdsthe data and instructions. storage Or memorY
units:
This unit main categories ofthe
future use. There are two
Memory. sIwitehed ofl, the dala
RAM: Random Access the computer is
of data. When
This is used for temporary storage Also, there are ditlerent (ypCs oRAM availablc
storage.
is lost. RAM is used as primary
(Dynamic Random Access Memory), used in nost persOnal
DRAM
computers
more volatile that DRAMI,
} SRAM (Static Random Access Memory), faster and
but requires more power to operate.
SDRM (Synchronous Dynamie Random Access Memory), a type of DRAM
that has higher processing specd.

ROM: Read Only Memory.


This is used for pernanent storage of data. ROM is treated as secondary nemory. The
devices are Hard Disk, CD, DVD etc. Usually, the secondary mennory is slower
cheaper than the primary menmory.
Bus
Buses are the communication channels (wiring plus
primary storage and input/output devices. conneetors) that conncets the proSs
nto
discrete transactions. Each transaction has a Communication on u bus is brokenbusiN
defincd by two parameters, the transfersender and a receiver. The pertomane ola
tinne, und the oveall bendwid1h (soe

You might also like