Mod1 Co&a Bec306c
Mod1 Co&a Bec306c
Mod1 Co&a Bec306c
Functional unit:
A computer consists of five functionally independent main parts input, memory, arithmetic
logic unit (ALU), and output and control unit.
Input device accepts the coded information as source program i.e. high level language. This
is either stored in the memory or immediately used by the processor to perform the desired
operations. The program stored in the memory determines the processing steps. Basically
the computer converts one source program to an object program. i.e. into machine language.
Finally the results are sent to the outside world through output device. All of these actions
are coordinated by the control unit.
Input unit: -
The source program/high level languages program/coded information/simply data is fed to
a computer through input devices keyboard is a most common type. Whenever a key is
pressed, one corresponding word or number is translated into its equivalent binary code
over a cable & fed either to memory or processor. Joysticks, trackballs, mouse, scanners
etc are other input devices.
To provide easy access to a word in memory, a distinct address is associated with each
word location. Addresses are numbers that identify memory location. Number of bits in
each word is called word length of the computer. Programs must reside in the memory
during execution. Instructions and data can be written into the memory or read out under the
control of processor.
Memory in which any location can be reached in a short and fixed amount of time after
specifying its address is called random-access memory (RAM).
The time required to access one word in called memory access time. Memory which is
only readable by the user and contents of which can’t be altered is called read only memory
(ROM) it contains operating system.
Caches are the small fast RAM units, which are coupled with the processor and are
often contained on the same IC chip to achieve high performance. Although primary storage
is essential it tends to be expensive.
2. Secondary Memory: - Is used where large amounts of data & programs have to be
stored, particularly information that is accessed infrequently.
Examples: Magnetic disks & tapes, optical disks (ie CD-ROM’s), floppies etc.,
The control and the ALU are many times faster than other devices connected to a
computer system. This enables a single processor to control a number of external
devices such as key boards, displays, magnetic and optical disks, sensors and other
mechanical controllers.
Output unit:-
These actually are the counterparts of input unit. Its basic function is to send the
processed results to the outside world.
Control unit:-
It effectively is the nerve center that sends signals to other units and senses their states.
The actual timing signals that govern the transfer of data between input unit, processor,
memory and output unit are generated by the control unit.
Load LOCA, R1
Add R1, R0
The first of these instructions transfers the contents of memory location LOCA into
processor register R1, and the second instruction adds the contents of registers RI and RO
and places the sum into RO.
Transfers between the memory and the processor are started by sending the address of
the memory location to be accessed to the memory unit and issuing the appropriate control
signals. The data are then transferred to or from the memory.
The fig shows how memory & the processor can be connected. In addition to the ALU &
the control circuitry, the processor contains a number of registers used for several different
purposes.
The instruction register (IR):- Holds the instruction that is currently being executed. Its
output is available for the control circuits which generates the timing signals that control
the various processing elements in one execution of instruction.
The Diversion may change the internal stage of the processor its state must be saved in
the memory location before interruption. When the interrupt-routine service is completed the
state of the processor is restored so that the interrupted program may continue.
Bus Structures:
To achieve a reasonable speed of operation, a computer must be organized so that all its units
can handle one full word of data at a given time. A group of lines that serve as a connecting
port for several devices is called a bus. Bus is defined as set of parallel wires used for data
communication. Each wire carries 1 bit of data.
There are 3 of buses, namely
1. Address bus
2. Data bus and
3. Control bus.
1. Address bus :
It is unidirectional.
The processor (CPU) sends the address of an I/O device or Memory device by means
of this bus.
2. Data bus
It is a bidirectional bus.
The CPU sends data from Memory to CPU and vice versa as well as from I/O to CPU
and vice versa by means of this bus.
3. Control bus:
This bus carries control signals for Memory and I/O devices.
It generates control signals for Memory namely MEMRD and MEMWR and control
signals for I/O devices namely IORD and IOWR.
It also generates special control signal to differentiate between Memory and I/O
device.
All the interconnected devices are not of same speed & time leads to a bit of a problem.
This is solved by using cache registers (ie buffer registers). These buffers are electronic
registers of small capacity when compared to the main memory but of comparable speed.
The instructions from the processor at once are loaded into these buffers and then the
complete transfer of data at a fast rate will take place.
Software:
System software is a collection of programs that are executed as needed to perform
functions such as,
During the time period t0 to t1, OS routine initiates loading the application program from
disk to memory, waits until the transfer is completed, and then passes execution control to
the application program. A similar pattern of activity occurs during period t2, to t3 and
period t4 to t5, when the operating system transfers the data file from the disk and prints
the results. At t5, the operating system may load and execute another application program.
Now, let us point out a way that computer resources can be used more efficiently if
several application programs are to be processed. Notice that the disk and the processor are
idle during most of the time period t4 to t5. The operating system can load the next
program to be executed into the memory from the disk while the printer is operating.
Sirnilarly, during t0 to t1, the operating system can arrange to print the previous program’s
results while the current program is being loaded from the disk.
Thus, the operating system manages the concurrent execution of several application
programs to make the best possible use of computer resources. This pattern of concurrent
execution is called multiprogramming or multitasking.
Performance:
The most important measure of the performance of a computer is how quickly it can
execute programs. The speed with which a computer executes program is affected by the
design of its hardware.
The total time required to execute the program is elapsed time is a measure of the
performance of the entire computer system. It is affected by the speed of the processor, the
disk and the printer. The time needed to execute an instruction is called the processor time.
Let us examine the flow of program instructions and data between the memory and the
processor. At the start of execution, all program instructions and the required data are
stored in the main memory. As the execution proceeds, instructions are fetched one by one
over the bus into the processor, and a copy is placed in the cache later if the same
instruction or data item is needed a second time, it is read directly from the cache.
The processor and relatively small cache memory can be fabricated on a single IC chip.
The internal speed of performing the basic steps of instruction processing on chip is very
high and is considerably faster than the speed at which the instruction and data can be
fetched from the main memory. A program will be executed faster if the movement of
instructions and data between the main memory and the processor is minimized, which is
achieved by using the cache.
The processor needs more time to read the data and instructions from main memory
because main memory is away from the processor.
Hence it slowdown the performance of the system. The processor needs less time to
read the data and instructions from Cache Memory because it is part of the processor.
Processor clock:
Processor circuits are controlled by a timing signal called clock. The clock designer the
regular time intervals called clock cycles. To execute a machine instruction the processor
divides the action to be performed into a sequence of basic steps that each step can be
completed in one clock cycle. The length P of one clock cycle is an important parameter
that affects the processor performance.
Processor used in today’s personal computer and work station has a clock rates that range
from a few hundred million to over a billion cycles per second.
To execute one instruction there are 3 basic steps namely
1. Fetch
2. Decode
3. Execute.
• To achieve high performance, the computer designer must reduce the value of T,
which means reducing N and S, and increasing R.
Pipelining:
Instructions are not necessarily executed one after another.
The value of S doesn’t have to be the number of clock cycles to execute one instruction.
In the below figure, while decoding ADD instruction fetching of SUB instruction
taking place.
Fig: Pipelining:
Compiler:
A compiler translates a high-level language program into a sequence of machine
instructions.
To reduce N, we need a suitable machine instruction set and a compiler that makes
good use of it.
Goal – reduce N×S
A compiler may not be designed for a specific processor; however, a high-quality
compiler is usually designed for, and with, a specific processor
Consider a 32-bit integer (in hex): 0x12345678 which consists of 4 bytes: 12, 34, 56, and 78.
Hence this integer will occupy 4 bytes in memory.
Assume, we store it at memory address starting 1000.
𝑅1 ← [𝐿𝑂𝐶 ]
Means that the contents of memory location LOC are transferred into processor register R1.
As another example, consider the operation that adds the contents of registers R1 and R2,
and then places their sum into register R3. This action is indicated as
𝑅3 ← [𝑅1 + 𝑅2 ]
This type of notation is known as Register Transfer Notation (RTN). Note that “the right-
hand side of an RTN expression always denotes a value, and the left-hand side is the
name of a location where the value is to be places, overwriting the old contents of that
location”.
Instruction Format:
Opcode Source operand, Destination operand
Where
Opcode stands for operation code, tells what operation to be carried out.
Operands may be register or Memory location.
Instructions are three types:
a) One address instruction
b) Two address instruction
c) Three address instruction
One address instruction:
Instruction Format:
Opcode Memory operand
Example: ADD A
Add the contents of memory location A to the contents of the accumulator register and place
the sum back into the accumulator.
Example: LOAD A
Example: STORE A
The Load instruction copies the contents of memory location A into the accumulator, and
the Store instruction copies the contents of the accumulator into memory location A.
Using only one-address instructions, the operation C ← [A] + [B] can be performed
by executing the sequence of instructions
Example: Add A, B
Which performs the operation B←[A]+[B]. When the sum is calculated, the result is sent
to the memory and stored in location B, replacing the original contents of this location. This
means that operand B is both a source and a destination.
Example: Move B, C
Move instruction that copies the contents of one memory location into another. Which
performs the operations C ← [B], leaving the contents of location B unchanged.
Branching:
Straight line sequencing program for adding n numbers.
The addresses of the memory locations containing the n numbers are represented as
NUM1,NUM2…..NUMn(i.e. NUM1 address includes first number).
The first number is stored into processor register R0. And every other number is added
to register R0. Finally, when the program ends (i.e. n numbers are added, the result is
placed in memory location SUM
Example:
32
0 00101000 001010. . . . 0
LTOL ( _ oto
.L010
J. 1r G*P[-^^"* Vrsis to10.
z:St[*..:|t: is C**t -."'{ ut * -*-Lov \t n-'r'nt
d-.,
*fUi3 t {o }\^i ' t't C'*iL"-l",^tr of s{^str
h
e"3te: .-C) _ 1,.000
- ttt ? Lot Q,*t\l.*.^i- I
l\t0
+t ? X{Ar^8 t hD otFgic\ ds
t ooo
K'q*.^J G .6 s..qDrd-(".,*u$iDcrl-
Bi^&>ny
tI'< Cs*y js
tt b, lYl
"tboi - ry")r
++ ++ ++
b.r:
r
-)O I \\
+6 +6 +6
o \ \ O
o \ o \
+f +g +s
+h +h
o \ o o +h
+f +1, +3
o o \ \
o o t 0 + + +)-
o o 0 \ J-[ +\ +t
o o O 0 #o J-o +0
t_g
t o O o .'_ O
-+
I 0 0 I
--L
t-- 6 -+
I 0 \ 0
-L
r:- .g -6
\ 0e
-\
I :\
h --5
-'
<h --- f h
\ \ OO
- -j
I 01 -f
-+
1
2_
t0 -.
I
I
I
I ll ,_ --6
_-+ -.0 -+
AJdiFtaq e+ o.t-ntur(
+
S+"jt:.-l-oJC-€ r.O.-I^- &UJ ^^t.ntot t.$o 'iu
C"*{
\t'.*"*
s F.{ t: *dd Lo vt^ .t^r'nL..,-3 "J c-t c"*'l
Jo 7"'*--o\t
t=Xn'ort '
0
el +2- s^J +1 b) +h t o \DO
+2_ c0\o +6+ +
O
\
\\a
+1 - -
+
oo\l r0\ 0
\ E
O l.o\ E
e) +h o100
€6 t rt0 - o0t
I
t
-
-o
-r\
coj /
+t
_1,
FCTO + \01-0
t
Js GY uf--
\
OT OO
:, + 't0t0
tq +h
3
'-G
I J'l-oEAnBwuY'
60
9nn r.+JI
-
.-Q ts ir tn*;
n "-[
rl -9 q^d -2.
-s- {-t0t t\9
--
ts*j
> rt- or0
I otO {_t
I
olr t tot t
r4
*Y Iror
l1
tro -t $110
\ t\
+t
r'! u3 \
+
LOTT +'
"+ --g
2
t LtL0
\-
Cn*g
"X -L
r'
E-L rS
4 F tot
ft rror
-+
-{--> / tl.tt **FF. ooo
=*-7 +L
tDo L t'r 001
-t
1-\qt
It 001-
bh +2- es.d +h
o roo E A.r\^)tx, ffi D
tr doro r'
+h ; o\oo o?x
+)_
Ir
+ otlo
.
+6
r-
+3 :- ooil
00\tE
J) -+ s^J tJ
-S
-? -? tttr -->
**f'
>t9
rF OCO
{-[
-S 4 4-0 L
-
I -- 00I -? t 001
It
L2'e
eD.--? !-- 0t" O
T +J'-
._ o L\ tott
. \l
{-ooI -
-
T Lo L1- tr
',Alnn^O
tnl't | L\/
).
I
.j rv
J \YI} 1.7I
lFct lI "RflRugt<
'"i-snsx
*TT>(. I-b
U
:A
fi-o
'.*, t \.,/\.> \g
A.u.eq"$€
\ | r\\\E \\ IttO
of s b:t cu)-cnL**
I *to a^d -g
+to --? 0toLp
js \ tr
-8 t t000 r4 ,.:_ 0 11\
+\
- Iogo I t-000
\i
r- o\o\o
I
\\ 000
0\0
-9ro \
t"\ \OD\O R...rr.orre
b) -\9 o"td -q
-\s {rrrl Js
c!{ -- co0c
- +t
.--\
+ tr00t \ooo1, *-i C-eoOt
I
lr
*f
L$ F 0lt0
+r
\ 1r r-
=-0 l\l--? to'J1\
arr
\
Iooot
, to 5-tt
ID
J v ' v rl5
**. \\o\o trnsr.er<