Computer Organization and Architecture: Prepared By: Dhvani Vyas
Computer Organization and Architecture: Prepared By: Dhvani Vyas
COMPUTER
ORGANIZATION AND
ARCHITECTURE
CS-09
Logic Gates
Binary information is represented in digital computers by physical quantities called signals. Electric
Signals such as voltages in a digital circuit are said to be at state 0 or state 1, depends on whether it
is 0V or 5V. Several other terms are used for the same like LOW, OFF, FALSE for 0 and HIGH, ON,
TRUE for level 1.
Digital Circuits are also called as Logic circuits, because each type of digital circuit obeys a certain set of
logic rules.
“Logic Gate, the fundamental building blocks of digital system, is an electronic circuit that manipulates the
binary information.”
Gate is the block of hardware that implements the logic operation like AND, OR, NOT and produces the 1
and 0 output signals depending on input signals supplied to them.
Logic Gates are digital circuits constructed using diodes, transistors and resistors in such a way that
their output is the result of a basic logic operation.
2. Universal Gate
NAND Gate
NOR Gate
3. Exclusive Gate
XOR Gate
XNOR Gate
Name
Graphic Symbol
Its operation can be described by means of an Algebraic Expression.
Truth Table
Truth Table
A table which lists all the possible combinations of the input variables and the corresponding outputs is
called Truth Table.
In Truth Table the input signals with all the possible input combinations are shown in the left column(s) of
the table and the output signals are shown in the right hand side column(s).
AND Gate
Graphic Symbol:
Algebraic Expression:
Truth Table:
Two Input AND Gate Truth Table Three Input AND Gate Truth Table
A B x A B C x
0 0 0 0 0 0 0
0 1 0 0 0 1 0
1 0 0 0 1 0 0
1 1 1 0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
OR Gate
Algebraic Expression:
x = A+B x = A+B+C
Truth Table:
Two Input OR Gate Truth Table Three Input OR Gate Truth Table
A B x A B C x
0 0 0 0 0 0 0
0 1 1 0 0 1 1
1 0 1 0 1 0 1
1 1 1 0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
Graphic Symbol:
Algebraic Expression:
x = A’ or x = Ā
Truth Table:
NAND Gate:
NAND means NOT AND, so the NAND gate is combination of AND gate and NOT gate
It is complement of AND gate.
If all the input signals are 1 then output signal is 0, otherwise the output is 1.
Graphic Symbol:
Algebraic Expression:
x = (AB)’ or x = AB
Truth Table:
Two Inp ut NAND Gate Tr uth Table Three Input NAND Gate Tru th Table
A B x A B C X
0 0 1 0 0 0 1
0 1 1 0 0 1 1
1 0 1 0 1 0 1
1 1 0 0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0
Graphical Symbol:
Algebraic Expression:
x = (A+B)’ or x = A+B
Truth Table:
Two Input NOR Gate Truth Table Three Input NOR Gate Truth Table
A B X A B C X
0 0 1 0 0 0 1
0 1 0 0 0 1 0
1 0 0 0 1 0 0
1 1 0 0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0
Exclusive Gate
Exclusive-OR Gate (XOR Gate)
If both the input signal are different then output signal is 1, otherwise output is 0.
XOR operation is an Odd Function, i.e. its output is 1 if an odd number of inputs are 1.
The graphic symbol of XOR Gate is similar to the OR gate except for the additional curved line
on the input side.
Graphic Symbol:
Algebraic Expression:
x =A B or x = A’B + AB’
Two Input XOR Gate Truth Table Three Input XOR Gate Truth Table
A B x A B C X
0 0 0 0 0 0 0
0 1 1 0 0 1 1
1 0 1 0 1 0 1
1 1 0 0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
Exclusive-NOR Gate (XNOR)
Graphic Symbol:
Algebraic Expression:
x =A B = A ⊙ Bor x =A’B’+ AB
Truth Table:
Two Input XOR Gate Truth Table Three Input OR Gate Truth Table
A B x A B C x
0 0 1 0 0 0 1
0 1 0 0 0 1 0
1 0 0 0 1 0 0
1 1 1 0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0
Boolean Algebra
Boolean Function is an expression formed with Boolean variables, Boolean operators like + (OR), *(AND),
‘(NOT), parentheses and equal sign (=). Value of Boolean function (F) is either 1 or 0.
F= x + y’zLogic
Diagram
A circuit diagram used to show logical operations of given Boolean function using Logic Gates is called
Logic Diagram.
F = x + y’z
If
x=1
OR => F=1
y’z=1
y’=1 AND z=1
y=0 AND z=1
x y Z F
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1
Logic Diagram
x
y y’ y’z F
z
The purpose of Boolean Algebra is to facilitate the analysis and design of digital circuits. It provides a
convenient tool to:
Axioms or Postulates
0.0=0 0+0= 0 0’ = 1
0.1=0 0+1= 1 1’ = 0
1.0=0 1+0= 1
1.1=1 1+1= 1
Proof:
Prove Prove
Associative Law
A(BC) = (AB)C A+(B+C) = (A+B)+C
Distributive Law
A(B+C) = AB+AC A+BC = (A+B)(A+C)
Proved Proved
Distributive Law
A+BC = (A+B) (A+C)
DeMorgan's theorem is very useful in dealing with NOR and NAND gates.
It allows ANDs to be exchanged with ORs by using inverters.
DeMorgan's Theorem can be extended to any number of variables.
Theorem 1:
(x + y)’ = x’.y’
The complement of the sum of two Boolean variables is equal to the products of the complements of
these two variables. Proved
x y x + y (x+y)’ x’ y’ x’ . y’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
Instead of representing a NOR gate with an OR graphic symbol followed by a circle, we can represent it
by an AND graphic symbol proceeded by circle in all inputs.
OR-Invert
Invert-AND
fig.1
Theorem 2:
(x y)’ = x’ + y’
The complement of the products of two Boolean variables is equal to the sum of the complements of
these two variables.
x y x.y (x.y)’ x’ y’ x’ + y’
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0
Instead of representing a NAND gate with an AND graphic symbol followed by a circle, we can represent
it by an OR graphic symbol proceeded by circle in all inputs.
AND-Invert
Invert-OR
fig.2
NOR gate that perform the (x + y)’ function is equivalent to the function x’.y’
Similarly, NAND gate can be expressed by (x y)’ or x’ + y’.
For this reason the NOR & NAND gates have two distinct graphics symbols as shown in figure
1 & 2.
Complement of a Function
In the Boolean Algebraic form, the complement of the function can be derived by means of DeMorgan’s
theorem.
F’ = (AB+C’D’+B’D)’
= (AB)’(C’D’)’(B’D)’
= (A’+B’)(C+D)(B+D’)
The expression may be simplified using the basic relations of Boolean Algebra.
However, this procedure is sometimes difficult because it lacks specific rules for predicting
each succeeding step in the manipulative process.
Karnaugh maps provide a useful method for simplifying an expression graphically.
This is important because more complex expressions can be much hard to simplify using the
theorems of Boolean algebra.
Karnaugh Map (K-map) is a very simple & straight forward method for simplifying Boolean
function.
A Karnaugh map is a pictorial arrangement of the truth table which allows an easy
interpretation for choosing the minimum number of terms needed to express the function
algebraically. Karnaugh map is also known as K-map.
Minterm
The standard product terms at which the output is 1 or maximum is called Minterm, e.g. ABC or A.B.C.
Maxterm
The standard sum terms at which the output is 0 or minimum is called Maxterm, e.g. A+B+C.
The maps for functions of Two, Three, Four variables are shown in the following figures:
B BC B
B 0 1 11 10
00 01
A A
0 1 0 1 3 2
0 A’B’ A’B 0 A’B’C A’B’C A’BC A’BC’
2 3 4 5 7 6
A1 A 1
AB’ AB AB’C’ AB’C ABC ABC’
4-Variable K – Map
C
CD 00 01 11 10
AB 0 1 3 2
00 A’B’C’D A’B’C’D A’B’CD A’B’CD’
01 4 5 7 6
A’BC’D’ A’BC’D A’BCD A’BCD’
B
11 12 13 15 14
ABC’D’ ABC’D ABCD ABCD’
A
8 9 11 10
10
AB’C’D’ AB’C’D AB’CD AB’CD’
D
Octet:-
The Octet is a group of eight 1’s that are horizontally or vertically adjacent.
First we must find octet.
Quad:-
A Quad is a group of four 1’s that are horizontally or vertically adjacent.
If octet is not possible then we have to find Quads.
Pair:-
A pair is a group of two 1’s that are horizontally or vertically adjacent.
If quad is not possible then we have to find Pair.
The minterms of adjacent squares in the map are identical except for one variable, which appears
complemented in one square and uncomplemented in the adjacent square.
According to this definition of adjacency, the squares at the extreme ends of the same horizontal row
are also to be considered adjacent.
The same applies to the top and bottom squares of a column. As a result, the four corner squares of a
map must also be considered to be adjacent.
A Boolean Function represented by a truth table is plotted into the map by inserting 1’s in those
squares where the function is 1.
The squares containing 1’s are combined in groups of adjacent squares.
These groups must contain a number of squares that is an integral power of 2. That is 1, 2, 4, 8,
16…….
Groups of combined adjacent squares may share one or more squares with one or more groups.
Each group of squares represents an algebraic term, and the OR of those terms gives the
simplified algebraic expression for the function.
The aim is to make minimum number of groups with maximum number of minterms.
Groups may wrap around the table. The leftmost cell in a row may be grouped with the
rightmost cell and the top cell in a column may be grouped with the bottom cell.
Example of K-Map
1. Simplify Boolean function by using K – Map in sum of product.
F(x, y)=∑(0, 2, 3)
y 1
x 0
0 1 F(x, y) = y’+x
1 1 1
B
BC 00 01 11 10
A 1 1 F(A, B, C)=C’ + AB’
0
1 1 1
A 1
C
3. Simplify Boolean function by using K – Map in sum of product.
F (w,x,y,z) =∑(0, 1, 2, 6, 8, 9, 10)
C
yz 00 01 11 10
wx 1 1 F (w, x, y, z) = x’z’ + x’y’ +w’yz’
1
00
01 1
B
11
A
10
1 1 1
=A’B’C’D+A’B’C’D’+AB’CD’+A’B’CD’+A’BCD’+AB’C’D+AB’C’D’
C
CD 00 01 11 10
AB 1 F (A, B, C, D)= B’D’ + B’C’ + A’BC’
1 1
00
1
01
B
11
A
10 1
1 1
In the Boolean Expressions the sums are OR terms and the product denotes the ANDing of these
terms which results in Product – of – Sums form.
The procedure for obtaining a Product – of – Sums expression follows from the basic properties
of Boolean Algebra.
The 1’s in the map represent the minterms that produce 1 for the function.
The squares not marked by 1 represent the minterms that produce 0 for the function.
If we mark the empty squares with 0’s and combine them into groups of adjacent squares, we
obtain the complement of the function, F’ in SOP form.
Taking the complement of F’ produces an expression for F in Product – of – Sums form.
C
Here for
CD 00 01 11 10 Minterm
AB 1 1 0 1 F(A, B, C, D) = ∑( 0, 1,
00 2, 5, 8, 9, 10)
Maxterm is given below,
01 0 1 0 0 Maxterm
F(A, B, C, D) = ∏(3, 4,
B
0 0 0 0 6, 7, 11, 12, 13, 14, 15)
11
D
A
0 1
10 1 1
Logic diagrams of the two simplified expressions are shown in the following figure:
B’ A’
D’ B’
F C’
C’ D’ F
A’
D D
Sum – of – Products can also be implemented with NAND gates as shown in the following Figure (a) and
the Product – of – Sums can also be implemented with NOR gates as in the following Figure (b).
B’ A’
D’ B’
F C’
C’ D’ F
A’
D D
In a K-map 1's and 0's are used to represent the minterms that make the function equal to 1 or
0.
There are occasions when it does not matter if the function produces 0 or 1 for the given
minterm. Since the function may be either 0 or 1, we say that we don't care what the output
of the function is for this minterms.
The minterms may produces either 0 or 1 for the function are said to be don't care conditions.
It is marked with 'X' in the K-map.
A 1 x 1
C
With don’t care condition simplified expression is,
F = A’ + BC’
F (A, B, C) = ∑ (0, 1, 2, 3, 6)
Universal Gates
Logic gates are used in the field of digital circuits, basic logic gates are AND, OR and NOT. It is
easy to prepare all the gates form NAND and NOR gates.
There are two Universal Gates.
o NAND gate.
o NOR gate.
Any digital circuit can be designed using only NAND or NOR gates. That is why ANAD and NOR
gates are known as Universal Gates.
In practice, this is advantageous since NAND and NOR gates are economical and easier to
fabricate and are the basic gates used in all IC digital logic families.
By using NAND gate, we can construct all other gate as per the following.
Y = ((AB)’. (AB)’)’
Y = ((AB)’)’
Y = AB
Y = (A’B’)’
Y = (A’)’ + (B’)’
Y=A+B
Y = (A.A)’
Y = A’
Y = Y = ((A’B’)’(A’B’)’)’
Y = ((A’B’)’)’
Y = A’B’
Y = (A + B)’
A A’
(A’B)’
B
Y = A B
A
(AB’)’
B B’
Y = ((A’B)’(AB’)’)’
Y = ((A’B)’)’ + ((AB’)’)’
Y = A’B + AB’
Y= AB
A A’
(A’B)’
B Y = A B
Y = A⊙ B
A
(AB’)’
B B’
By using NOR gate, we can construct all other gate as per the following.
Y = (A’ + B’)’
Y = (A’)’(B’)’
Y = AB
Y = (A +A)’
Y = A’
Y = ((A’+B)’+(A+B’)’)’
Y = (A’+B) (A+B’)
Y = A’A+ A’B’+ AB+ BB’
Y = A’B’+ AB ( X.X’ = 0)
Y=A⊙B
Synchronous Asynchronous
Sequential Circuits Sequential Circuits
Combinational Circuits
A combinational circuit is a connected arrangement of the logic gates with a set of inputs and outputs.
At any given time, the binary values of the outputs are the function of the binary combination of the
inputs, e. g. Decoders, Encoders, Multiplexer, De multiplexer, Adder Circuits, etc.
The n binary input variable come from an external source, the m binary output variable go to an external
destination and in between there is an interconnection of logic gates.
A combinational circuit transforms binary information from the given input data to the required output
data.
In digital computers the Combinational circuits are employed for generating binary control decisions and
for providing digital components required for data processing.
A combinational circuit can be described by a truth-table showing the binary relationship between the n
input variables & the m output variables.
Half Adder
The most basic digital arithmetic circuit is the addition of two binary digits.
A combinational circuit that performs the arithmetic addition of two binary bits is called a half adder.
Step 1:
A combinational circuit that performs the arithmetic addition of two-bit is called half adder.
Step 2:
The input variables of half adder are called the augends and addend bits whereas the output
variables produce the Sum and Carry bit.
The two input variables are x and y and two output variables are S (Sum) and C (Carry).
The block diagram of half adder is given below.
Step 3:
The truth table of half adder is given below :
Step 4:
The Boolean functions of two outputs Sum and Carry are obtained directly from the truth
table.
S = x’y + xy’ C = xy
=x y
Step 5:
The logic diagram of half adder is given below.
=xy
Full – Adder
Step 1:
A combinational circuit that performs the arithmetic addition of three bits is called full adder.
It consists of three input variables and two output variables.
Step 2:
Here we define the symbols for three input variables are x, y and z (Previous Carry)
respectively
Here we define the symbols for output variables are S (Sum) and C (Carry).
The binary variables S give the value of the least significant bit of the sum.
Step 3:
The truth tableof full adder is given below :
Step 4:
From the truth table of full adder,the output is 1 when the odd number of inputs are 1, S is an
ODD Function and represents the exclusive – OR relation of the three variables.
According to K-Map
C= xy+yz+xz ----------- (2)
Half Adder
Half Adder
Sequential Circuit
As shown in diagram, the combinational circuit block receives binary signals from external
inputs and from the outputs of flip-flops.
The output of the combinational circuit goes to external outputs and to inputs of flip-flops.
The gates in the combinational circuit determine the binary value to be stored in the flip-flop
after each clock transition.
The behavior of an asynchronous sequential circuit depends upon the order in which its input signals
change and can be attached at any instant of time. The memory elements used in asynchronous
sequential circuits are time – delay devices.
The synchronous circuit is a system whose behavior can be defined from the knowledge of its signals at
discrete instants of time.
These circuits employ signals that affect the storage elements only at discrete instants of time.
Synchronization is achieved by a timing device called a clock pulse generator that produces a periodic
train of Clock Pulse.
The pulses are distributed throughout the system in such a way that storage elements are affected only
with the arrival of synchronization pulse.
Synchronous sequential circuits that use clock pulses in the inputs of memory elements are called
clocked sequential circuits.
The memory elements used in clocked sequential circuits are called flip – flops.
Clock Pulse
In the synchronous systems, the exact time at which any output can change states are determined by a
signal commonly called the Clock.
Flop – Flops
The storage elements employed in clock sequential circuit are called Flip-Flops
A flip-flop is a binary cell capable of storing one bit of information. It has two outputs one for
normal value and one for the complement value of the bit stored in it (Q, Q’).
A flip-flop maintains a binary state until directly by a clock pulse to switch states.
SR Flip-Flop
Characteristic Table
S R Q (t+1)
0 0 Q(t) (No change)
0 1 0 (Reset)
1 0 1 (Set)
1 1 ? (Indeterminate)
Clocked SR Flip – Flop
D flip-flop
Characteristic Table
D Q (t + 1)
0 0 (Clear to 0)
1 1 (Set to 1)
Characteristic Table
Q(t) D Q (t + 1)
0 0 0
Clocked D Flip – Flop 0 1 1
1 0 0
1 1 1
The “no change” condition can be accomplished either by disabling the clock signal or by
feeding the output back into the input, so the clock pulses keep the state of the flip-flop
unchanged.
Clocked JK flip-flop
Characteristic Table
Q(t) J K Q (t+1) OR S R Q(t) Q (t+1)
0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0
0 1 0 1 0 1 0 0
0 1 1 1 0 1 1 0
1 0 0 1 1 0 0 1
1 0 1 0 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 0 1 1 1 0
The T (Toggle) flip flop is obtained from a J-K flip-flop, when both inputs J and K are
connected to provide a single input designated by T.
Characteristic Table
T Q (t + 1)
0 Q(t) (No Change)
1 Q’(t) (Complement)
Characteristic Table
Q(t) T Q (t + 1)
0 0 0
0 1 1
1 0 1
1 1 0
From the characteristic table
1) When T=0 output is Q(t) No Change
2) When T=1 output is Q’(t) Reset
The most common type of flip flop used to synchronize the state change during a clock pulse transition
is the edge triggered flip flop.
For achieving synchronization in a computer a timing device called a clock pulse generator is used, which
produces a periodic train of clock pulses.
The Fig – 1 shows a typical clock waveform. The clock waveform in Fig.1 (a) and Fig.1 (b)is called square
wave. The figure shows two important portions of a square wave: the Leading Edge or Rising Edge or
sometimes Positive – Going – Edge and the Falling Edge, or Negative – Going – Edge.
Most Flip – Flops respond to either (but not both) a Falling Edge or a Rising Edge. In effect, a system
which responds to Rising Edges of the clock ‘reset’ between such edges and changes state only when
such Positive – Going Edges occur.
Positive Going or
(a) Rising Edge of
the Signal
Negative Going
(b) (b) or Falling Edge
of the Signal
Fig. 1 Clock Waveforms
Since clock signals are used to initiate flip – flop actions, a clock input is included on most flip – flops.
This input is marked with a small triangle, as shown in the following figure (a). It indicates that a flip –
flop can respond to the positive – edge of the clock signal.
If the flip – flop responds to a negative – edge of a signal, a bubble (inverter) is placed at the clock input,
as shown in the following figure (b)
(a) (b)
S Q S Q
C C
This symbol is Q Q
This symbol is
used for R used for Negative R
Positive – going – going – edge
– edge clocked clocked flip -
flip - flop flop
It is important to understand the above convention because most clocked flip-flop actually responds to a
change in clock input level, not to the level itself. This is shown in following figure (a) and (b).
1. If the S and R inputs are 0’s when the clock edge occurs, the flip – flop does not change states
but remains in its present state.
2. If S = 1 and R = 0, when the clock pulse (Positive/ Negative edge) occurs, the flip – flop goes to
the 1 state.
3. If S = 0 and R = 1, when the clock pulse occurs, the flip – flop is cleared to the 0 state.
4. Both the S and R inputs should not be 1’s when the clock signal’s Positive/ Negative Edge occurs.
Of course, nothing happens to the flip – flop’s state between occurrences of the Positive/
Negative pulses.
Another type of flip flop used in some system is the master slave flip flop.
This type of circuit consists of two flip flops. The first is the master, which responds to the
positive level of the clock, and the second is the slave, which responds to the negative level of
the clock.
Master slave JK flip-flop contains two JK flip-flop one is called Master and the other is called
Slave.
The output of the first JK flip-flop is given to the input in the second JK flip-flop
When the clock pulse is high (positive transition), the master is active and give the output &the
slave is inactive.
The master Set or Reset according to the state of the input signals.
Since the slave is inactive during this period, its output remains steady at the previous state.
When clock pulse goes low (negative transition), the master flip-flop is inactive & the slave is
active.
The slave Set or Reset according to the state of the input signals.
The final output Q of a master-slave flip-flop is the result of the output of the slave flip-flop
And the output of the slave is available at the end of the clock pulse.
Two D flip-flops A and B, two inputs x and y, and one output y. the flip-flop input equations and the
circuit output are as follows:
DA = Ax + Bx
DB = A’x
y = x’(A + B)
Logic Diagram
The behavior of a sequential circuit is determinedfrom the inputs, the outputs, and the state of its flip-
flops.
Both the outputs and the next state are a function of the inputs and the present state.
Sequential circuit is specified by a state table that relates outputs and next states as a function of inputs
and present states.
In clocked sequential circuits, the transition from present state to next state is activated by the presence
of a clock signal.
State Diagram
The information available in a state table can be represented graphically in a state diagram. Here the
state is represented by a circle, and the transition between states is indicated by directed lines
connecting the circles.
The binary number inside each circle identifies the state of the flip-flops.
The directed lines are labeled with two binary numbers separated by a slash. The input value during the
present state is labeled first and the number after the slash gives the output during the present state.
Characteristics
Analog Signal Digital Signal
Analog signal is a continuous signal
Digital signals are discrete time signals
Signal which represents physical
generated by digital modulation.
measurements.
Waves Denoted by sine waves Denoted by square waves
Uses continuous range of values to Uses discrete or discontinuous values to
Representation
represent information represent information
Human voice in air, analog electronic Computers, CDs, DVDs, and other digital
Example
devices. electronic devices.
Can be used in analog devices only.
Best suited for Computing and digital
Uses Best suited for audio and video
electronics.
transmission.
Applications Thermometer PCs, PDAs
Cost Low cost and portable Cost is high and not easily portable
Figure
Characteristics
Analog Signal Digital Signal
Analog signal is a continuous signal
Digital signals are discrete time signals
Signal which represents physical
generated by digital modulation.
measurements.
Waves Denoted by sine waves Denoted by square waves
Uses continuous range of values to Uses discrete or discontinuous values to
Representation
represent information represent information
Human voice in air, analog electronic Computers, CDs, DVDs, and other digital
Example
devices. electronic devices.
Analog technology records waveforms Samples analog waveforms into a limited set
Technology
as they are. of numbers and records them.
Subjected to deterioration by noise
Data Can be noise-immune without deterioration
during transmission and write/read
transmissions during transmission and write/read cycle.
cycle.
Response to More likely to get affected reducing Less affected since noise response are
Noise accuracy analog in nature
Digital hardware is flexible in
Flexibility Analog hardware is not flexible.
implementation.
Can be used in analog devices only.
Best suited for Computing and digital
Uses Best suited for audio and video
electronics.
transmission.
Applications Thermometer PCs, PDAs
There is no guarantee that digital signal
Analog signal processing can be done
processing can be done in real time and
Bandwidth in real time and consumes less
consumes more bandwidth to carry out the
bandwidth.
same information.
Memory Stored in the form of wave signal Stored in the form of binary bit
Digital instrument drawS only negligible
Power Analog instrument draws large power
power
Cost Low cost and portable Cost is high and not easily portable
Impedance Low High order of 100 megaohm
Analog instruments usually have a
Digital instruments are free from
scale which is cramped at lower end
Errors observational errors like parallax and
and give considerable observational
approximation errors.
errors.
Levels of Integrations
There are following four different level of Integration depending on number of gates in a single package.
(m <= 2n)
2 – to – 4 line decoder
A 2 – to – 4 line decoder with an enable input is constructed with AND Gates.
The circuit operates when E equal to 1.
From the truth-table, when E equal to 1 only one output is equal to 1 at any given time the other
outputs are equal to 0.
The output whose value is equal to 1 represents the equivalent binary number in A1 and A0.
The circuit is disabled when E is equal to 0, regardless of the values of the other two inputs.
Truth Table
Enable Inputs Outputs
E A1 A0 D0 D1 D2 D3
0 X X 0 0 0 0
1 0 0 1 0 0 0
1 0 1 0 1 0 0
1 1 0 0 0 1 0
1 1 1 0 0 0 1
Logic Diagram
Truth Table
Application
Decoder is used whenever an output or a group of outputs is to be activated only on the
occurrence of a specific combination of input levels.
Decoder is used to respond to the address code that is from central processor to activate the
memory storage location.
Truth Table
Enable Inputs Outputs
E A1 A0 D0 D1 D2 D3
1 X X 1 1 1 1
0 0 0 0 1 1 1
0 0 1 1 0 1 1
0 1 0 1 1 0 1
0 1 1 1 1 1 0
Logic Diagram
The least significant bit (A0, A1) of input are connected to both decoders.
The most significant bit (A2) is connected to the enable input of one decoder and through an
inverter to the enable input of the other decoder.
It is assume that each decoder is enable when its E input is equal to 1, When E is equal to 0, the
decoder is disable and all its output are in the 0 level.
When A2 = 0, upper decoder is enabled and lower decoder is disabled. The lower decoder
output becomes inactive with all outputs at 0.
The output of the upper decoder generate outputs D0 through D3, depending on the values of
A1 and A0 (while A2=0).
When A2 = 1, upper decoder is disabled and lower decoder is enabled. The lower decoder
generates outputs D4 through D7, depending on the values of A1 and A0.
ENCODER
An Encoder is a device whose inputs are decimal digits and/ or alphabetic characters and whose
outputs are the coded representation of those inputs.
An encoder is combinational logic circuit that performs reverse operation of decoder.
Encoding is exactly opposite process of decoding. it’s a process of converting familiar numbers
into a coded format.
An encoder has 2n (or less) inputs lines and n output lines.
The output lines generate the binary code corresponding to the input value.
An example of encoder is the octal-to-binary encoder.
Decoders has numbers of output lines and at a time only one output of line is high while
encoder has numbers of input lines & only one of its activated (High) input at a given time.
(m <= 2n)
Block diagram of Encoder
Truth Table
Inputs Outputs
D0 D1 D2 D3 D4 D5 D6 D7 A2 A1 A0
1 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 1 0 0
0 0 0 0 0 1 0 0 1 0 1
0 0 0 0 0 0 1 0 1 1 0
0 0 0 0 0 0 0 1 1 1 1
From the truth table, output A0=1 if the input octal digit is 1 or 3 or 5 or 7.These condition can be
expressed by the following Boolean function.
Output A0 = 1,if input octal is high i.e. 1, 3, 5 and 7, then A0 = D1+D3+D5+D7
Output A1 = 1,if input octal digits are 2, 3, 6 and 7, then A1 = D2+D3+D6+D7
Output A2 = 1,if input octal digits are 4, 5, 6 and 7,then A2 = D4+D5+D6+D7
Logic Diagram
D0
D1
D2
D3
D4
D5
D6
D7
A0 A1 A2
3 x 8 line ENCODER
4 × 1 Multiplexer
In 4 X 1 multiplexer, four data input I0 to I3 is applied to one input at an AND Gate. And the two
selection inputs S1 and S0 are decoded to select a particular AND Gate.
The o/p at the AND Gate are applied to a single OR Gate to provide the single output.
Selection input { S0
S1
4X1
l0 MUX Y
l1
l2
l3
Logic Diagram
A truth table describing the circuit needs 64 rows since six input variable can have 26 binary
combination this is excessively long table and will not be shown here.
A more convenient way to describe the operation of multiplexer is by means of function table.
The Multiplexer is also called a Data Selector, since it selects one of many data inputs and steers the
binary information to the output.
Application
As in decoders, multiplexers may have an enable input to control the operation of the unit.
The enable input is useful for expanding two or more multiplexers to a multiplexer with a larger
number of inputs.
The selection and the enable inputs in multiple unit construction are usually common to all
multiplexers.
The block diagram of a Quadruple 2 – to – 1 line multiplexer is shown in the following figure.
Enable E
Select S
A0 Quadruple
A1 2X1 Y0
A2 Multiplexers Y1
A3 Y2
Y3
B0
B1
B2
B3
The circuit has four multiplexer, each capable of selecting one of two input lines.
Output Y0 can be selected to come from either input A0 or B0.
Output Y1 may have the value of A1 or B1, and so on.
One input selection line S selects one of the lines in each of the four multiplexers.
1 × 4 Demultiplexer
The input data line (D) goes to all the AND Gates.
The two select lines S1 and S0 enable only one gate at a time, & the data appearing on the input
line will pass through the selected gate to the associated output line.
Logic Diagram
Function Table
INPUT OUTPUT
S1 S0 Y0 Y1 Y2 Y3
0 0 D 0 0 0
0 1 0 D 0 0
1 0 0 0 D 0
1 1 0 0 0 D
From the truth table it is clear that when D =0, the outputs are zero regardless the values of
input S0 & S1.
When D =1 & selection lines S1S0=00 then AND gate associated with Y0 gives high output and
Y1, Y2, & Y3 gives low output.
When D =1 & selection lines S1S0=01 then AND gate associated with Y1 gives high output.
When D =1 & selection lines S1S0=10 then AND gate associated with Y2 gives high output.
When D =1 & selection lines S1S0=11 then AND gate associated with Y3 gives high output.
REGISTER
Register consists of group of flip-flop and gates, where the flip-flop hold the binary information
& gates control when and how new information is transferred into the register.
Register is a group of flip-flop with each flip-flop capable of storing 1 bit of information.
An n-bit register has a group of n number of flip-flop and is capable of storing any binary
information of n bits.
In addition to flip-flop, register may have combinational gates that perform data processing
tasks.
Data may be available in parallel form or in serial form
o Multi-bit data is said to be in parallel form when all the bits are available
simultaneously.
o The data is said to be in serial form when the data bits appear sequentially i.e. one after
the other, at a single terminal.
Register may output data either in serial form or in parallel form.
Register Load
The transfer of new information into a register is referred to as Loading the register.
Serial Loading
In serial loading, data is transferred into the register in serial form, i.e. one bit at a time.
Parallel Loading
If all the bits of the register are loaded simultaneously with a common clock pulse transition, we say
that the loading is done in parallel.
A simplest register is one that consists of only flip-flop without any external gates.
The following figure shows such a register constructed with four D type flip- flop.
The common clock input triggers all flip – flops on the rising edge of each pulse, and binary data
available at the four inputs (I0 through I3) are transferred into the 4-bit register.
The four outputs can be sampled at any time to obtain the binary information stored in the
register.
The clear input goes to a special terminal in each flip – flop. When this input goes to 0, all flip –
flops are reset asynchronously.
l0 D Q A0
Clock
C
l1 D Q A1
C
l2 D Q A2
C
l3 D Q A3
C
Clear
The clock pulse input, enable all the flip–flop & the inputs of the register load all four inputs I0
through I3 in parallel.
In this configuration, the clock must be inhibited from the circuit in the content of the register
must be left unchanged.
The master clock acts like a pump that supplies a constant beat to all parts of the system.
A separate control signal must be used to decide whether the next pulse will accept new
information or leave the information in the register as it is.
When the separate control signal, the load input is 1 then I inputs are transferred into the
register on the next clock pulse.
When the load input is 0 the circuit input I0, I1, I2, I3 are inhibited & D inputs of the flip-flops are
connected to their outputs, thus maintaining the content of the register.
The feedback connection in each flip flop is necessary when a D type of flip flop is used because
D flip flop does not have nochange input condition.
To leave the output unchanged, it’s necessary to make D input equal to the present Q output in
each flip flop.
A register is capable of shifting its binary information in one or both directions is called
shift register.
The register capable of shifting its binary information in one direction only is called
unidirectional shift register.
The logical configuration of a shift register consists of chain of flip- flop in cascade with the
output of one flip flop connected to the input of the next flip flop.
The entire flip flop receives common clock pulse that causes the shift from one stage to the
next.
4 – bit unidirectional shift (Right) register
These flip flops are connected in a cascade manner performing shift right operation.
As shown above, it has four flip flop, thus it can store up to four bits of data that is applied
at the D input of the first flip flop.
The Q output of the first flip flop is connected to the D input of the second flip flop , the Q
output of the second flip flop is applied to the input(D) of the 3rd flip flop & the Q o/p the
3rd flip flop is connected to the D input of the fourth flip flop.
The clock is common to all the flip flops.
The serial input determines what goes into the leftmost position during the shift.
The serial o/p is from right most flip flop.
These flip flops are connected in a cascade manner performing shift right operation.
The serial input determines what goes into the rightmost position during the shift.
The Q output of the 4th flip flop is connected to the D input of the 3rd flip flop , the Q
output of the 3rd flip flop is applied to the input(D) of the 2nd flip flop & the Q o/p the 2nd
flip flop is connected to the D input of the 1st flip flop.
The serial o/p is from left most flip flop.
Application
Time Delay, Serial/ Parallel Data Conversion, Ring Counters, Universal Asynchronous Receiver
Transmmiter (UART)
S0 S0
S1 D A0
S1
4X1 Q
MUX
Serial
Input
0
1
I0 2
S0
D A1
S1
4X1 Q
MUX
0
1
I1 2
S0
D A2
S1
4X1 Q
MUX
0
1
I2 2
S0
D A3
S
01 Q
4X1
1
MUX
2
Serial
Input
I3
Clock
4 – bit Bidirectional shift register with parallel load
The register capable of shifting its binary information in both the directions (right & left)
is called bi-directional shift register.
Most general shift register has all the capabilities listed below:
1. An input for clock pulses to synchronize all operations.
2. A shift-right operation and a serial input line associated with the shift-right.
3. A shift-left operation and a serial input line associated with the shift-left.
4. A parallel load operation and n input lines associated with the parallel transfer.
5. N parallel output lines.
6. A control state that leaves the information in the register unchanged even though
clock pulses are applied continuously.
The above diagram consists of 4-D flip flop & 4X1 multiplexer.
The two selection inputs S1 & S0 select one of the multiplexer data input for the D flip Flop
The selection lines control the mode of operation of the register according to the following
function table.
Mode Control
S1 S0 Register Operation
0 0 No change
0 1 Shift Right(down)
1 0 Shift left(up)
1 1 Parallel load
Circuit operations
When the mode control S1S0 = 00, data input 0 of each multiplexer is selected. The condition
forms a path from the output of each flip-flop into the input of the same flip-flop. The next clock
transition transfers into each flip-flop the binary value it held previously and no change of state
occurs.
When the control mode S1S0 = 01, the terminal marked 1 in each multiplexer has a path to the D
input of the corresponding flip-flop. This causes a shift-register operation, with the serial input
data transferred into flip-flop A0 and the content of each flip-flop Ai-1 transferred into flip-flop
Ai for i = 1, 2, 3.
When the control mode S1S0 = 10, a shift left operation results, with the other serial input data
going into flip-flop A3 and the content of flip-flop Ai+1 transferred into flip-flop Ai for i = 0, 1, 2.
When the control mode S1S0 = 11, the binary information from each input I0 through I3 is
transferred into the corresponding flip-flop, resulting in a parallel load operation.
Note
The way the diagram is drawn, the shift-right operation shifts the contents of the register in the down
direction while the shift left operation causes the contents of the register to shift in the upward
direction.
COUNTER
A register that goes through a predetermined sequence of states upon the application of
input pulses called a counter.
In short, it’s a register capable of counting the number of clock pulses that had arrived at
its clock input.
Counters are used for counting number of occurrence of an event & also useful for the
generating timing signals to the control the sequence of operations in digital computers.
A counter that follows the binary number sequence is called a binary counter.
An n bit binary counter is a register of n flip flop & associated gates that follows a
sequence of states according to the binary count of n bit from 0 to 2n -1.
Up Counter
A counter that is capable of counting in upward direction is known as Up Counter, it counts from 0 to
2n-1.
Down Counter
A counter that is capable of counting in downward direction is known as Down Counter, it counts from
2n-1 to 0.
Counter A B C D
Enable
Time a b c d e f g h i j k l m n o p
Every time there is a negative clock transition, flip-flop A will change states. Thus at ‘a’ on time
line, A goes high, at point ‘b’ it goes back low, at ‘c’ it goes back high and so on. Notice that the
wave form at the output of flip-flop A is one-half the clock frequency.
Since A acts as the clock for B, each time the wave form at A goes low, flip-flop B will toggle.
Thus at point ‘b’ on the time line, B goes high it then goes low at point ‘d’ and toggles back high
again at point ‘f’. Notice that the wave forms at the output of flip-flop B is one-half the
frequency of A and one-fourth the clock frequency.
Since B acts as the clock for C, each time the wave form B goes low, flip-flop C will toggle. Thus C
goes high at point ‘d’ on time line and goes back low again at point ‘h’. The frequency of the
wave form at C is one-half that at B, but it is only one-eighth the clock frequency.
Since C acts as the clock for D, each time the wave form C goes low, flip-flop D will toggle. Thus D
goes high at point ‘h’ on time line and goes back low again at point ‘p’. The frequency of the
wave form at D is one-half that at C, but it is only one-sixteenth the clock frequency.
Application
Digital Clock, frequency Counter
Modulus
Defines the number of states through which a counter can progress. E.g. A 3 – bit binary counter is also
called MOD – 8 counter.
Integer Representation
When an Integer binary number is positive the sign is represented by 0 and the magnitude by a
positive binary number.
When the number is negative, the sign is represented by 1. But the rest of the number may be
represented in one of the following three ways:
Signed Magnitude Representation
Signed - 1’s Complement Representation
Signed - 2’s Complement Representation
The signed magnitude representation of a negative number consists of the magnitude and
negative sign. In other two representation, the negative number is represented in either 1’s or
2’s Complement of its positive value.
Example: - Consider the signed. Number 14 stored in an 8 bit register. +14 is represented by a
sign bit of 0 in the left most position followed by the binary number equivalent of +14: 0
0001110.
Note that each of the eight bits of the register must have a value and therefore 0’s must be
inserted in the most significant positions following the sign bit.
There are three different ways to represent - 14 with eight bits.
In signed magnitude representation 1 0001110
In signed - 1’s complement representation 1 1110001
In signed - 2’s complement representation 1 1110010
The signed magnitude representation of -14 is obtained from +14 by complementing only the
sign bit.
The signed - 1’s complement representation of -14 is obtained by complementing all the bits of
+12, including the sign bit.
The P (odd) bit is chosen in such a way as to make the sum of 1’s (in all four bits) is odd.
The P (even) bit is chosen in such a way as to make the sum of 1’s (in all four bits) is even.
The even - parity scheme has the disadvantage of having a bit combination of all 0’s, while in the
odd parity there is always one bit that is 1.
Note that the P (odd) is the complement of the P (even)
During the transmission of information from one location to another location the parity bit is
handled as follows :
At the sending end, the massage is applied to a parity generator, where the required parity bit is
generated. The message, including the parity bit is transmitted to its destination.
At the receiving end, all the incoming bits are applied to a parity checker that checks the proper
parity adopted (odd or even)
An error is detected if the checked parity does not conform to the adopted parity.
Parity generator and parity checker networks are logic circuits constructed with exclusive OR
functions.
An odd function is a logic function whose value is binary 1 if and only if an odd number of
variables are equal to 1.
According to the above definition, the P (even) function is the exclusive OR of X, Y and Z because
it is equal to 1 when either one or all three of the variable are equal to 1.
Example
Consider the 3 - bit message to be transmitted with an odd parity bit.
The part of computer that perform the bulk of data processing operation is called Central
Processing Unit which is referred a CPU.
CPU is a brain of computer
Although its main function lies in executing programs, it’s also controls input devices, output
devices and other components of a computer.
Under its control, programs and data are stored in memory and displayed on the screen.
Register set
Control
unit (CU)
Arithmetic and
logic unit (ALU)
Register Set
Register set consist of one or more register used for storing intermediate data during the
execution of information.
After store entire information, register set redirect the stored information into the ALU.
It performs the several operations after performing the operation.
The memory locations are needed for storing pointers, counters, returns addresses, temporary
results and partial products during the multiplication, division or any arithmetic operation.
Having to refer to memory location for such applications is time consuming because memory
access is most time-consuming operation in computer.
It is more convenient and more efficient to store this intermediate values in processor register.
When a large no. of registers is included into the CPU, It is most efficient to connect through a
common bus.
The registers communicate with each other not only for direct data transfer but also while
performing micro operation.
Hence it is compulsory provide common unit that perform all arithmetic and logical operation.
A general organization of seven CPU register is shown in given below figure which have the other
component like Multiplexer, Decoders and Arithmetic & Logical Unit (ALU).
R1
R2
R3
R4
R5
R6
R7
L oad
(7 lines) SEL A MUX MUX SEL B
3 x 8
decoder A bus B bus
SEL D
output
In above figure the output of each register is connected to two multiplexer (MUX) to form the
two buses a bus and B bus.
The selection lines of each multiplexer selects one register or input data for the particular bus.
The A-bus and B-bus from the input are given to a common ALU.
The operation selected in ALU decides the arithmetic or logic micro operation that is to be
performed
The result of the micro operation is available for output and also goes into the input of all the
register.
The register that receives the information from the output bus is selected by a Decoder.
Output line of the Decoder is connected with the Load line of each register (D1 connected to R1
load, D2 connected to the R2 load and so on.).
PREPARED BY:DHVANI VYAS Page 2
COMPUTER ORGANIZATION AND ARCHITECTURE
The decoder activates one of the register load inputs and providing the transfer path between
the data in the output bus and the input of the selected destination register.
To understand the processing of this register organizations consider the following example.
R1 R2 + R3
In the above example R2 and R3 are the input register and R1 is the output register which give
processed value of R2 and R3.
The control unit provides the binary selection variables to the following selector inputs:
o MUX A Selector (SELA): Multiplexer A is used to place the value of R2 into the bus A.
o MUX B Selector (SELB): Multiplexer B is used to place the value of R3 into the bus B.
o ALU operation selector (OPR): to provide arithmetic addition of A bus and bus B, that
holds the value of R2 and R3 respectively.
o Selector D (SELD): specifies the destination to transfer the contents of output bus into
the register R1.
Control word
There is 14-bit binary selection input in the unit and their combine value specifies a control
word.
The figure of 14-bit control word is as given below.
There are 14-bit control words which define in above figure which consist of four fields.
The first three fields contain three bit in each field and the fourth field contain 5-bits.
The first field is SELA, which contains 3-bits.
The second field is SELB, which contains 3-bits.
The third field is SELD, which contains 3-bits.
The fourth field is OPR, which contains 5-bits.
The 3-bits of SELA select a source register for the A input of the ALU.
The 3-bits of SELB select a source register for the B input of the ALU.
The 3-bits of SELD select a destination register using the decoder and its seven load outputs.
The 5-bits of OPR select one of the operations in the ALU.
The 14-bits control unit is applied to the selection input to specify a particular micro-operation.
Selection (encoding) of a specified register is done by referring the following table.
The register selected by fields SELA, SELB, and SELD is the one whose decimal number is
equivalent to the binary number in the code.
When SELA or SELB is 000 the corresponding multiplexer selects the external input data.
R1R2 – R3
The Binary Control Word:
Arithmetic and Logical Unit is major component of CPU system which accepts and redirects the
information from register set after completing the operation.
ALU can perform arithmetic and logical operation on a accept instruction format.
The following logical diagram describes block diagram of 4 bit Arithmetic and Logic Unit.
Input A Input B
A4 A3 A2 A1 B4 B3 B2 B1 S2 Mode Select
Out S1
(Output Function
4 - bit ALU S0 select
carry)
F4 F3 F2 F1 C (Input carry)
Output line
ALU
Accumulator
Register
Output
Block diagram of processor with AC Register
Some processor unit has separate register from all other register. This separate register is
known as Accumulator Register, abbreviated as AC.
AC Register’s initial value is 0.
Generally, AC Register is used to perform arithmetic operation, but sometimes AC Register is
used to perform multipurpose task in the processor.
AC Register can perform all the digital function found in ALU.
All operations are performed with an implied accumulator register.
In this mode, the operations are specified implicitly in the definition of the instruction. For
example, the instruction “CLEAR Accumulator” is an implied-mode instruction because the
operand in the accumulator register is implied in the definition of the instruction.
In above logic diagram input B is supply from the external source, this information come from
either processor register or memory unit.
Input B is controlled by selected B control signal.
From the AC Register other input is passed to ALU.
This input AC represents the previous result of the previous operations.
The sum of two number stored in processor register using AC Register is describe as per
following:
AC 0 ------------- Clear State
AC AC + R1 ------------- Add R1 to AC
AC AC + R2 ------------- Add R2 to AC
Processor Registers
Stack Pointer (SP)
It holds the address of the word that is currently on the top of the stack.
Address Register (AR)
It points at an array of the data.
Program Counter (PC)
It holds the address of the next instruction in the program.
Data Register (DR)
It holds the binary data to be written into or read out of the stack.
A useful feature that is included in the CPU of most computers is stack or Last-In-First-Out
(LIFO) list.
A stack is a storage device that stores information in such a manner that the item stored last is
the first item retrieved.
The operation of a stack can be compared to a stack or trays.
The last tray placed on top of the stack is the first to be taken off.
Stack Pointer
The stack in digital computers is essentially a memory unit with an address register that
can count only.
The register that holds the address for the stack is called a Stack Pointer (SP) because its
values always points at the top item in the stack.
Operations
The two operation of stack are insertion and deletion of items which are given below:
Push: The process of inserting an item into the stack is known as Push and is done by
incrementing stack pointer.
POP: The process of deleting an item from the stack is known as POP and is done by
decrementing stack pointer.
Application
When Recursive Functions are called.
To evaluate the Arithmetic Expression.
Register stack
PUSH:
Initially SP is cleared to 0. EMPTY is set to 1 and FULL is cleared to 0, So that SP points to
the word at address 0 and stack is marked empty or not full.
If the stack is not full (if FULL=0), a new item is inserted with a push operation.
If the stack is full and user try to insert a new value in the stack, then it is called Stack
Overflow error.
The push operation is implemented, with the following sequence of micro-operations :
SP SP –1 Decrement SP
The top item is read from the stack into DR the stack
The stack pointer is then decremented.
If its value reaches zero, the stack is empty, so EMPTY is set to 1. And FULL is set to 0.
Note: An erroneous operation will result if the stack is pushed when FULL = 1 or popped
when EMTY = 1.
Memory stack
A stack can exist as a standalone unit or it can be implemented in RAM (Random Access
Memory) attached to CPU.
The implementation of a stack in CPU is done by assigning a portion of memory to a stack
operation and using a processor register as a stack pointer.
Figure shows a portion of computer memory partitioned into three segments.
o Program
o Data
o Stack
The Program Counter (PC) points at the address of the next instruction in the program.
The Address Register (AR) points at an array of data.
The Stack Pointer (SP) points at the top of the stack.
The three register are connected to a common address bus.
PC is used during fetch phase to read an instruction.
AR is used during the execute phase to read an operand.
SP is used to push or pop item into or from the stack.
As shown in figure the initial value of SP is 4001 and stack grows with decreasing addresses.
The first item stored in the stack is at address 4000, the second item is stored at 3999 and the
last address that can be used for the stack is 3000.
The items in the stack communicate with the data register DR.
The new item is inserted with the PUSH operation as given below:
PUSH:
SPSP-1
M [SP]DR
POP:
DRM [SP]
SPSP+1
The Top item is read from the stack into DR.
The stack pointer is then incremented to point at the next item in the stack.
Stack Limits:
Most computers do not provide hardware to check for stack overflow (Full Stack) or underflow
(Empty Stack).
The stack limits can be checked by using two processor register: one to hold the upper limit and
the other to hold the lower limit.
After the push operation, SP is compared with the upper-limit register and after a pop operation,
SP is compared with the lower-limit register.
Advantage:
A stack pointer is loaded with an initial value i.e. the bottom address of an assigned stack in memory.
The advantage of a memory stack is that the CPU can refer to it without having to specify an address,
since the address is always available and automatically updated in the stack pointer.
1. Infix Notation :
The common arithmetic expressions are written in infix notation with each operator
written between the operands.
Consider the simple example
A*B
The multiplication is placed between two operands an A and B.
The plus is between two products.
2. Prefix Notation:
The polish mathematician showed the arithmetic expression can be represented in
prefix notation.
This representation often referred to as polish notation, places the operator before
the operands.
Consider the example in polish notation - * A B
3. Postfix Notation :
The postfix notation referred to as Reverse Polish Notation (RPN), places the operator
after the operands.
Consider the example in polish notation - A B *
The RPN is in a form suitable for stack manipulation.
The expression
A*B+C*D
AB * CD * +
Conversion to RPN
To convert from infix notation to reverse police notation we first perform all arithmetic
operations inside inner parentheses, then inside outer parenthesis, and do multiplication and
division operation before addition and subtraction operations.
Consider the expressions
(A + B) * [C * (D + E) + F]
First we perform the arithmetic operation inside the parentheses (A + B) and (D + E).
Next multiplication of C * (D + E) must be done prior to the addition of F since multiplication has
precedence over addition.
Last operation is the multiplication of parenthesis and brackets.
The converted expressions
AB + DE + C * F + *
Reverse Polish Notation, combined with stack arrangement of registers, is the most efficient way
known for evaluating arithmetic expressions.
The procedure consists of first converting the arithmetic expression into its equivalent Reverse
Polish Notation.
The operands are pushed in to the stack in the order in which they appear.
The following micro operations are executed with the stack:
o The two topmost operands into the stack are used for the operation.
o The stack is popped and the result of the operation replaces the lower operand.
By pushing the operands into the stack continuously and performing the operations, the
expression is evaluated in the proper order and the final result remains on top of the stack.
For Example
(3 * 4) + (5 * 6)
In RPN, it is expressed as,
34*56*+
Stack Operations
In the following figure each box represents one stack operation and the arrow always points to
the top of the stack.
Executing from left to right first the number 3 is pushed into the stack, then the number 4.
The next symbol is the multiplication operator *.
This causes a multiplication of the two topmost items in the stack. The stack is then popped and
the product is placed on the top of the stack, replacing the two original operands.
Next 5 and 6 are pushed in to the stack. Again next symbol is the multiplication operator *, that
6
4 5 5 30
3 3 12 12 12 12 42
Most computers just store the Program Counter and the PSW
In some cases there exist two sets of processor registers within the computer, one for each CPU
mode.
Interrupt Cycle
Interrupt procedure is similar to the execution of the subroutine call instruction.
The state of the CPU is pushed into the memory stack and the beginning address of the service
routine is transferred to the program counter.
A new PSW is loaded into the status register.
The beginning address of the service routine is determined by the hardware.
o Some computers assign one memory location where interrupts are always transferred.
The service routine must then determine what caused the interrupt and proceed to
service it.
o Some computers assign a memory location for each possible interrupt. Sometimes, the
hardware interrupt provides its own address that directs the CPU to the desired service
routine.
Types of Interrupt
They can be classified as:
Internal interrupts
External interrupts
Software interrupts
Internal Interrupt:
It arises from illegal or erroneous use of instruction or data.
Examples of interrupts caused by internal error condition are register overflow, attempt to
divide by zero, an invalid Operation code and stack overflow.
This condition usually occurs as a result of premature termination of an instruction.
The service programs that process the internal interrupt determine the corrective measure to be
taken.
Internal interrupts are synchronous with the program. If the program is rerun, the internal
interrupts will occur in the same place each time.
External Interrupt:
External interrupts come from some external devices such as an input-output (I/0) devices when
data needs to be transferred.
External interrupt also occur when some time out has occurred, from a timing device, from a
circuit monitoring the power supply or from any other external source.
Example that causes external interrupts are I/O device requesting transfer of data, I/O device
finished transfer of data, elapsed time of an event, or power failure.
The external interrupts are asynchronous. It depends on external conditions that are
independent of the program being executed at the time.
Software Interrupt:
It is initiated by executing an instruction.
It can be used by a programmer to initiate an interrupt procedure at any desired point in the
program.
Software interrupt take place when an application program called a supervisor program such as
operating system.
It occurs under such condition when a user program request the operating system for handling
some special operation such as complex input output transfer procedure.
Input-Output Interface
Input-output interface provides a method for transferring information between internal storage
and external I/O devices.
Peripherals connected to a computer need special communication links for interfacing them
with the CPU.
The purpose of the communication link is to restore the differences that exist between the
central computer and each peripheral.
The major differences are:
o Peripherals are electromechanical and electromagnetic devices and their manner of
operation is difference from the operation of the CPU and memory, which are electronic
devices. Therefore, a conversion of signal values may be required.
o The data transfer rate of peripherals is usually slower than the transfer rate of the CPU,
and as a result, a synchronization mechanism may be needed.
o Data codes and formats in peripherals differ from the word format in the CPU and
memory.
o The operating modes of peripherals are different from each other and each must be
controlled so as not to disturb the operation of other peripherals connected to the CPU.
To resolve the differences, computer system includes special hardware components between
the CPU and peripherals to synchronize all input and output transfer.
These components are called interface units because they interface, between the processor bus
and the peripheral device.
To communicate with a particular device, the processor places a device address on the address
lines.
Each interface attached to the I/O bus contains an address decoder that monitors the address
line.
When the interface detects its own address it activates the path between the bus lines and the
device that it controls.
All peripherals whose address does not correspond to the address in the bus are disabled by
their interface.
Buses
A Bus is a collection of wires through which data is transmitted from one part of a computer to
another.
You can think of a bus as a highway on which data travels within a computer. When used in
reference to personal computers, the term bus usually refers to internal bus. This is a bus that
connects all the internal computer components to the CPU and main memory.
Buses can transmit information line data, address, special instructions and others.
Information is transmitted on buses as a serials or series of electrical pulses. Each pulses
represented as a binary number 1 or 0.
There are five types of buses available in a computer system:
o External Bus: This bus is placed outside the processor. It is used to transfer data between
one device to another device of computer.
o Internal Bus: This bus is placed inside the processor. It is used to transfer information
between processor register and internal components of processor.
o System Bus: This bus which is used to connects processor and main memory is called
System Bus.
o Instruction Bus: This bus is “Special data bus” which used to fetch instruction from the
main memory.
o Memory Bus: The memory bus is the set of wires that is used to carry memory addresses
and data to and from the system RAM.
Memory Bus
Memory and I/O devices are connected to the CPU through a group of lines called a bus.
These lines are meant to carry information.
The memory bus is the set of wires that is used to carry memory addresses and data to and from
the system RAM.
The memory bus in most PCs is also shared with the processor bus, connecting the system
memory to the processor and the system chipset.
The memory bus is further divided into the three buses:
Data Bus: The portion of the memory bus that carries the actual data to and from the
memory is known as the data bus. The function of the bus speed and width describes how
much data can flow over the bus and is known as bandwidth. Data buses are bidirectional.
Address Bus: An address bus carries the address of memory location that the CPU wants to
access. The width of the address bus defines how much memory the processor could
potentially address. The address bus is unidirectional.
Control Bus: Control bus is bidirectional because the signals can flow in either direction from
CPU to memory or memory to CPU. Example of control signals are: RD (Read line), WR
(Write line), etc.
ADDRESS BUS
DATA BUS
Memory
CPU OR
I/O
CONTROL BUS
2. Memory-Mapped I/O
The transfer of data between fast storage device such as magnetic disk and memory is often
limited by speed of CPU. Removing the CPU from the path and letting the peripheral device
manage memory bus directly would improve the speed of transfer. This Transfer technique is
called Direct Memory Access (DMA).
During DMA transfer the CPU is idle and has no control of memory buses.
A DMA controller takes over the buses to manage the transfer directly between I/O devices and
memory.
The CPU may be placed in an idle state in variety of ways. One common method extensively
used in microprocessor is to disable to buses through special control signals.
Below figure shows two control signals in the CPU that facilitate the DMA transfer.
When the DMA takes the control of the bus system it communicates directly with the memory. The
transfer can be made in several ways.
Burst Transfer
In burst transfer, a block sequence consisting of a number of memory words is transferred in a
continuous burst while the DMA controller is master of the memory buses.
This mode of transfer is needed for fast devices such as magnetic disks, where data cannot be
stopped or slowed down until an entire block is transferred.
Cycle Stealing
This technique allows the DMA controller to transfer one data word at a time, after which it
must return control of the buses to the CPU.
The CPU merely delays its operation for one memory cycle to allow the direct memory I/O
transfer to “steal” one memory cycle.
DMA Controller
Unlike the DMA controller that must be set up entirely by the CPU, the IOP can fetch and
execute its own instructions.
The block diagram of a computer with two processors is given above.
As shown in figure the memory unit occupies a central position and can communicate with each
processor by means of direct memory access.
The CPU is responsible for processing the data for computational task.
The communication between CPU and IOP may take different forms, depending on the particular
computer considered.
In most cases the memory unit acts as a message center where each processor leaves
information for the other.
The sequence of operations may be carried out as shown in the above flow chart.
The status word indicates whether the transfer has been completed or if any errors occurred
during the transfer.
From the inspection of the bits in the status word, the CPU determines if the I/O operation was
completed satisfactorily without any errors.
The IOP takes care of all data transfer between several I/O units and the memory while the CPU
is processing another program.
The IOP and CPU are completing for the use of memory, so the number of devices that can be in
operation is limited by the access time of the memory.