Complete Notes of CA
Complete Notes of CA
BCA
Second Semester
Computer Architecture
Computer Architecture Sindhi college
Chapter-1
Digital logic circuits
―It is concerned with the structure and behavior of the computer as seen by the user .it
includes the information, formats, instruction set, addressing modes.‖
The architectural design of a computer system is concerned with the specifications of the
various functional modules, such as processors and memories and structuring them together into
a computer system
Harvard architecture
It uses separate store and signal pathways for their instructions and data.
The term originate from the Harvard mark-relay based computer, which stored
instructions on punched tape(24 bits wide) and data in relay latches(23 digits wide)
The CPU can read both an instruction and data from memory at same time ,even without
a cache, leading to double the memory bandwidth
Boolean algebra
Introduction
In 1854 George Boole introduced a systematic treatment of logic and developed for this
purpose an algebraic system known as symbolic logic, or Boolean algebra.
Boolean algebra is a branch of mathematics and it can be used to describe the
manipulation and processing of binary information or used in the design ,maintenance
and analysis of logical circuits in digital computers
Boolean algebra
Boolean algebra uses Boolean variables and Boolean operators.
Boolean variables are binary variables or symbol used to represent a logical quantity.
Some examples of Boolean variables are A, B, C, a, b, c, X, Y, and Z.
Boolean operators are logical operators There are three basic logical operators: AND,
OR, and NOT.
A Boolean expression is a combination of Boolean variables and Boolean operators.
There are many Boolean expressions that are logically equivalent to one another. There
are called equivalent expressions.
A Boolean function typically has one or more input variables and produces a result that
is based on these input values. The result can have a value of 0 or 1.
Truth Tables
A truth table is a useful visual tool for defining the input-output relationship of binary
variables in a Boolean function.
n
A function of n variables has 2 rows of possible input combinations, each row
specifying the value of the function for a different combination.
A truth table can be used to represent one or more functions.
Complement
It is the inverse of a variable and is indicated by a bar over the variable ex: A=>A‘
Literal:
It is a variable or the complement of a variable
Given a Boolean expression, the dual is formed by replacing AND with OR, OR with
AND, 0 with 1, 1 with 0.
The duality principle states that if two Boolean expressions are equal, then their duals are
also equal.
Ex:ab+ab‘=a Dual is (a+b).(a+b‘)=a
Commutative Laws
x+y=y+x xy=yx
Associative Laws
(x + y) + z = x + (y + z) = x + y + z
(x y) z = x (y z) = x y z = xyz
Distributive Law
x (y+z) = x y +x or x(y+z) = xy + xz
z
x+(y.z)=(x+y)(x+z)
Absorption Laws
x (x+y) = x x + xy = x
De Morgan’s Laws
(x+y)‘ = x‘ y‘
The complement of a sum of variables is equal to the product of the complements of the
individual variables
LHS RHS
X Y X' Y' X+Y (X+Y)' ( X'.Y')
0 0 1 1 0 1 1
0 1 1 0 1 0 0
1 0 0 1 1 0 0
1 1 0 0 1 0 0
(x y)‘ = x‘ + y‘
The complement of a product of variables is equal to the sum of the complements of the
individual variables
LHS RHS
X Y X' Y' X.Y (X.Y)' ( X'+Y')
0 0 1 1 0 1 1
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 1 0 0
Logic gates
A gate is simply an electronic circuit which operates on one or more input signals to
perform a particular logical function
The basic gates are AND gate, OR gate & NOT gate
NAND,NOR,EX-OR & EX-NOR gates are the other most widely used gates
AND gate:
Function:
The AND gate is a logic element having two or more input terminals and only one output
terminal
Its output is at logical 1(high) only when all of its inputs are at logical 1(high)
If any one or more of the inputs are low then output of the gates will be low
Logical expression: Y=AB
Truth table
INPUTS OUTPUT
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
OR gate:
Function:
The OR gate is a logic element having two or more input terminals and only one output
terminal
The output of an OR-gate is high(1) if any one or more of its inputs are high(1),the output
is low(0) only when all of its inputs are low
Logical expression: Y=A+B
Truth table
INPUTS OUTPUT
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
Function:
The NOT gate is having one input and one output terminal.
It is also called as an inverter as it inverts its input.
It performs the operation called inversion or complementation or negation
When a high is applied to an inverter, a low will appear on its output.
When a low is applied to its input, a high will appear on its output
Boolean expression: Y=A‘
Truth table:
INPUTS OUTPUT
A Y Y=A'
0 1 ON
1 0 OFF
NAND gate:
Function:
The NAND logical function is equivalent to AND followed by an inversion
The output of a NAND gate is low only when all of its inputs are high.othrewise its
output is high
NOR gate
Function:
The NOR logical function is equivalent to OR followed by an inversion
The output of a NOR gate is high only when all of its inputs are low.othrewise its output
is low
Boolean expression: Y= (A+B)‘
Truth table:
INPUTS OUTPUT
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
EX-OR gate
Function:
The exclusive-OR gate is a combinational circuit with two or more inputs and one output
The output of the EX-OR is high if one and only one input is high
When both the inputs are equal, then the output is also low
EX-NOR gate
Function:
The exclusive-NOR gate is a combinational circuit with two or more inputs and one output
The EX-NOR function is the complement of an EX-OR function, and hence its output is
high only when its inputs are equal
Boolean expression: Y= (A + B)‘ i.e., A‘B‘+AB
Truth table:
INPUTS OUTPUT
A B Y
0 0 1
0 1 0
1 0 0
1 1 1
UNIVERSAL GATE:
Logic gates that can be used to realize any of the basic logical operations like AND,OR
NOT,NAND ,NOR,EX-OR & EX-NOR is called universal gate EX:NAND & NOR gates are
universal gates
Logical functions:
SOP function:
SOP is two or more AND functions ORed together.
A product of two or more variables or their complements is simply the AND function of
those variables
EX: 1.ABC‘+D‘EF‘+FGH+AF‘G
2. AB+BCD
POS function:
It is two or more OR functions ANDed together. It is also known as the dual of the
SOP EX: 1.(A+B+C‘)(D‘+E+F)
2.(A+B)(C+D+E‘)
Standard SOP:
It is also SOP but each product should contain all variables that are in the Boolean expression
EX:ABC‘+A‘BC+AB‘C
In the above example it has got 3 product terms containing all the 3 variables (i.e.,A,B,C)
EX: f(A,B,C)=AB’C+ABC+ABC’+A’BC’+A’BC+A’B’C+A’B’C’
AB‘C=(101)2=(5)10
ABC=(111)2=(7)10
ABC‘=(110)2=(6)10
A‘BC‘=(010)2=(2)10
A‘BC=(011)2=(3)10
A‘B‘C=(001)2=(1)10
A‘B‘C‘=(000)2=(0)10
f(A,B,C)=sum of minterms(0,1,2,3,5,6,7)
Or
f(A,B,C)= (0,1,2,3,5,6,7)
where m indicates minterms(product terms)
Standard POS:
It is also POS but each sum function consists of all the variables that are in the Boolean
expression each such OR function/term is known as Max term
Eg:(A+B+C‘)(A‘+B+C)
Karnaugh map
Karnaugh map provides a systematic method for simplifying Boolean expression. The
simplified expression (SOP or POS) is called the minimum expression
K-map can be used to simplify Boolean expressions with two, three or four variables
The number of cells in a k-map is equal to the total number of possible input variable
combinations
n 2
For a 2 variable k-map the number of cells=2 =2 =4 .The variables are A&B
n 4
For a 4 variable k-map the number of cells=2 =2 =16.The variables are A, B, C&D
Cell adjacency
Cell adjacency is defined by a single variable change .cells that are differ by only one variable
are said to be adjacent so the order used in 00,01,11,10 to maintain “cell adjacency”
m
A sub-cubes or a group is a set of exactly 2 adjacent cells containing 1‘s
Single cell
For m=0 the sub-cubes consists of a single cell. No variables are reduced it is an
isolated 1
Pair
m 1
For m=1 a sub-cube consists of 2 =2 =2 adjacent cells
Since m=1 grouping two adjacent cells containing 1‘s result in elimination of one
variables
Quad
m 2
For m=2 a sub-cube consists of 2 =2 =4 adjacent cells
Since m=2 grouping four adjacent cells containing 1‘s result in elimination of two
variables
Octet
m 3
For m=3 a sub-cube consists of 2 =2 =8 adjacent cells
Since m=3 grouping eight adjacent cells containing 1‘s result in elimination of
three variables
Overlapping groups
The same 1 in a k-map cell may be used in more than one group so as to help in forming largest
group possible
Redundant group
A group whose 1‘s are all overlapped by other groups is called a redundant group
Example problem
Minimize the following standard SOP expression using k-map
AB‘C+A‘BC+A‘B‘C+A‘B‘C‘+AB‘C‘ or f(A,B,C)= ∑m(0,1,3,4,5) or f(A,B,C)=(m0,m1,m4,m5)
Solution:
Without using don‘t care term we can have 2 pairs. The resultant expression will be
A‘BD+A‘BC‘=>here one variable is eliminated
Using the don‘t care term we can have one group i.e. quad .The resultant expression will be A‘B
=>Here 2 variables are eliminated so it is advantageous to use don‘t care terms in simplifying
expression using k-map
Example problem
Use k-map to minimize the standard POS expression (X+Y‘+Z)(X+Y‘+Z‘)(X‘+Y‘+Z)(X‘+Y+Z)
or f(X,Y,Z)=∏M(3,4,5,6)OR f(X,Y,Z)=(M3+M4+M5+M6)
Solution:
Step 1: Mapping a standard POS expression
(X‘+Y+Z)=100
Combinational logic
Introduction
When gates are connected together to produce a specified output for certain specified
combinations of input variable with no storage involved the resulting circuit is called
combinational logic. In combinational logic the output variable are at all times dependent on the
combination of input variables.
A combinational logic circuit consists of input variables, logic gates and output variables. The
logic gates accept signals from the input variables and generate output signals. This process
transforms binary data information from the given input data to the required output data.
Fig below shows the block diagram of a combinational circuit..
This accepts n input binary variables and generates output variables depending on the logical
combination of gates.
The main function of combinational circuits is
Truth table,
Boolean expression and
logic diagram
Design procedure
The design of combinational circuit starts from the online of the problem statement and ends in a
logic circuit diagram or a set of Boolean functions from which the logic diagram can be easily
obtained.
Adders
Half adder
The function of a half adder is to add two binary digits producing a sum and a carry according to
binary addition rules.
Truth table
A B Sum carry
0 + 0 0 0
0 + 1 1 0
1 + 0 1 0
1 + 1 0 1
The block diagram truth table and the logic diagram of a half adder are given below.
As shown in the truth table if any one of the input is 1 but not both then the output on the S
(SUM) line will be 1.
If both inputs are 1, then carry line C will be 1 for all other states of input, there will be zero on
the carry line.
As per truth table
Logical expression
S=AB‘ + A‘B
S=A+B
C=AB
Hence sum output is generated by ex-or gate and carry output using AND gate.
Full adder
The arithmetic addition of 3 bits when adding two numbers you may have a carry from one
column to the next.
Eg:
ЀĀȀĀĀ ⸀Ā ᜀ The least significant column, 1+1=0, carry 1
ЀĀȀĀĀ ⸀Ā ᜀ The next column, 1+0+1(carry) therefore sum is 0, carry is 1
ЀĀȀĀĀ ⸀Ā ᜀ In the last column, we must again add 3 digits because of the carry 1+1+1=>S=1
C=1
Logical symbol
Truth table
Inputs Outputs
A B cin Sum carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Logical expression
Sum =A‘B‘C+A‘BC‘+AB‘C‘+ABC
=A‘(B‘C+BC‘)+A(B‘C‘+BC)
=A‘(B C)+A(B C)‘
Sum =A B C
Department of BCA Page 23
Computer Architecture Sindhi college
Carry =A‘BC+AB‘C+ABC‘+ABC
=C(A‘B+AB‘)+AB(C‘+C)
=C(A B)+AB(1)
Carry =C(A B)+AB
Logical diagram
To add binary numbers electronically we need a circuit that can handle 3 digits at a time, by
connecting two half adder and one OR gate we get a full adder a circuit that can add 3 digit at a
time.
FLIP FLOP
Flip flop is the basic memory element in a digital computer.
It is used to store one bit of information with a 0 or a 1.It is also called the binary or
toggle or latch.
D flip flop
The D flip flop is a flip flop with a sing le data input D and a clock input C.therfore it is
called data flip flop.
The D flip flop is also known as the delays flip flop. The word ―delay‖ describes what
happens. To the data at input 0.The data at D input is delayed by one clock pulse before it
gets to the output Q.
The D flip flop can be formed from a clocked RS flip flop by adding an inventor or NOT gate.
The D input is connected to S input of RS flip flop directly
The D input is connected to R input of RS flip flop through the inventor.
The typical commercial D flip flop contain two extra inputs PRESET (P) AND CLEAR (CLR).
1 1 _ 1 1 0 SET
1 1 _ 0 0 1 RESET
The preset and clear inputs are called asynchronous inputs as they act on the flip flop
independent of the clock.
The preset input is used to set the flip flop to 1.
The clear input is used to clear reset the flip flop to 0.
The bubble at these inputs that the active signal is 0.
The D input is called the synchronous input as it activates the flip flop only in
synchronism with the clock pulse.
Always the asynchronous inputs override the synchronous inputs.
D Q(t+1)
0 0 CLEAR TO 0
1 1 SET TO 1
Applications
D flip flop are widely used as temporary memory devices.
They are wired together to form shift registers and storage registers commonly used in digital
systems.
The J input is equivalent to the S input of SR flip flop and the K input is equivalent to the
R input of SR flip flop.
JK flip flop can be wired using RS flip flop
When J & K inputs are both 0, the data inputs have no effect on the outputs. The flip flop is
said to be in the hold state.
when J=0 & K=1, the flip flop is reset or cleared to 0, then it said to be in the reset state.
When J=1 & K=0, the flip flop I s set to 1. Then it is said to be in the set state.
When both J & K are 1, if the state of the flip flop was 0, applying clock pulse causes it to
change to 1 & vice versa called toggling.
Toggling
It is defined as the change of output in a JK flips flop alternatively b/w 0 to 1 for every clock
transition
Racing
It can be defined as toggling (change of 0 to 1 and 1 to 0 alternatively) more than once during
one clock cycle in JK flip flop.
Applications
JK flip flop are used in many digital circuits especially its toggle feature is used in
counters.
JK flip flop are also used as frequency divider.
T flip flop
It is also known as toggle flip flop
Logical symbol
This type of flip flop can be obtained from a JK flip flop when input J & K are connected to
provide a single input designated by T.
So the T flip flop has only two conditions
When T=0 (J=0, K=0) a clock transition does not change the state of the flip flop.
When T=1(J=1, K=1) a clock transition complements the state of the flip flop.
Truth table
T Q(t+1)
0 Q(t) No change
1 Q(t)' Complement
The first is the master, which responds to the positive edge of the clock. The second is the
slave, which responds to the negative edge of the clock. The output changes only during
the negative edge transition of the clock.
Logical symbol
This helps in avoiding the racing condition in JK flip flop where it can be triggered only once
within a clock cycle.
Since the output of the second flip flop follows that of the first JK flip flop, the names master and
slave are used.
Characteristics table
It specifies the next state when the inputs and the present state are known.
Excitation table
When we need to know the required transition from present state to next state and the input
conditions that caused the required transition, a table called excitation table.
Q(t) Q(t+1) S R
0 0 0 x
0 1 1 0
1 0 0 1
1 1 x 0
Q(t) Q(t+1) D
0 0 0
0 1 1
1 0 0
1 1 1
Q(t) Q(t+1) T
0 0 0
0 1 1
1 0 1
1 1 0
Q(t) Q(t+1) J K
0 0 0 X
0 1 1 X
1 0 X 1
1 1 X 0
Sequential circuit
State table
A sequential circuit is specified by a state table
A state table relates outputs and next states as a function of inputs and present states
The transition from present state to next state is activated by the present state to next state
is activated by the presence of a clock signal
The table consists of four sections
a. Present state-the states of flipflops at any given time t
It has one input variable X and one output variable Y and Z clocked D flip-flops
The AND gates, OR gates and inverter form the combinational logic part of the
circuit
The relationship between the gates in the combinational circuit can be simplified by a set
of Boolean expression
The set of Boolean expressions called flip flop input equations
DA=AX+BX
A & B->output
o X->input
DB=A‘X
Y=AX‘+BX‘
State table
The state table consists of 4 sections
a. Present state
b. Input
c. Next state
d. Output
Present State Input Next State Output
A B x A B Y
0 0 0 0 0 0
0 0 1 0 1 0
0 1 0 0 0 1
0 1 1 1 1 0
1 0 0 0 0 1
1 0 1 1 0 0
1 1 0 0 0 1
1 1 1 1 0 0
State diagram
The information available in a state table can be represented graphically using a state diagram
A state is represented by a circle
The transition between states is indicated by directed lines connecting the circle
The directed lines are labeled with two binary number separated by a slash
The present state is labeled first and the number after the slash gives the output during the
present state
The state diagram for the sequential circuit is shown in fig
If the directed line from state 00 to state 01 is labeled 1/0,it means that when the sequential
circuit is in the present state 00 & the input is 1,the output is 0 & so on
The combinational circuit so obtained together with the flip flops, constitutes the sequential
circuit
Flip flops are drawn and all their inputs and outputs are labeled
The combinational circuit is drawn from the Boolean expressions given by flip flop input
equations
The outputs of flip flops are connected to inputs in combinational circuit and outputs of the
combinational circuit are connected to flip flop inputs
The states of the circuit follow the binary count as long as X=1, If X=0,the state of the circuit
remains unchanged
1 1 1 0 0
Excitation table
If JK flip flop is used the columns are J & K inputs of each flip flop A & B.These are
denoted as JA, KA & JB,KB
The excitation table for JK flips flop
Q(t) Q(t+1) J K
0 0 0 X
0 1 1 X
1 0 X 1
1 1 X 0
The excitation table for the binary counter follows from the excitation table of JK flip
flop
The maps for the 4 flip flop inputs are shown below
JA=Bx KA=Bx
JB=X KB=X
The simplified flip flop input equations are derived as JA=BX KA=BX JB=X KB=X
Inputs J&K determine the next state of the counter when a clock signal occurs
If both J & K are equal to 0,a clock signal will have no effect
Answer the following questions:
Define computer organization.(1M,OCT/NOV 2012)
Define computer architecture.(1M,OCT/NOV 2011)
What is stored program concept? .(1M,OCT/NOV 2012)
Explain VON-Neuman architecture. .(5M,OCT/NOV 2011)
Explain Harvard architecture with a neat diagram. .(5M,OCT/NOV 2012)
Prove that(x+y)(x+z)=x+xz. .(1M,OCT/NOV 2011)
Given the function F=xy‘z+x‘y‘z+xyz.(3M,NOV/DEC 2010)
list the truth table of the function.
draw the logic diagram using only NAND gates.
Design half adder and full adder circuit?
Design a combinational logic circuit with 3 input x,y,z and the three output A,B,C.when
the binary input 0,1,2 or 3,the binary input is 4,5,6,or 7 the binary output is one less than
the input? .(3M,NOV/DEC 2010)
Explain the minimum SOP expresion using karnaugh map method using k-map simplify
f=∑(0,5,7,8,11,13,15) .(5M,OCT/NOV 2011)
Chapter-2
Integrated circuits and digital functions
Using advanced techniques a manufacturer can produce miniature circuits of the surface
of a small piece of semiconductor material called a chip. Such a circuit is called an
Integrated circuit(IC).
There are two basic techniques for manufacturing ICs are
Bipolar technique.
Metal oxide semiconductors (MOS) technique
A digital IC family is a group of compatible devices with the same logic leves and supply
voltages
Logic families
The IC technology usually depends on the following factors:-
Speed
Power description
Noise immunity
Input/output interface compatibility
Cost.
Compatibility
It means that we can connect the output of one device to the input of another.
Interfacing
It is defined as the design of the interconnections between circuits that shift the voltage levels
and current levels to make the compatible.
Fan in is the number of inputs a gate has like a 2 input AND gate has fan in of two ,a 3 input
NAND gate has fan in of three and so on
The number of gates that each gate can drive while providing voltage levels in the
guarantied range is called the standard load or fan out
The fan out really depends on the amount of electric current a gate can source or sink
while driving other gates
Noise margin
Noise margin refers to the maximum noise voltage that can be added to the generated signal
in a digital circuit before an undesirable change is caused in the circuit output
Applications
Characteristics
ECL is that the transistors are always in the active region.
It can be change state very rapidly.
It operates at very high speed.
The propagation time can be less than a nanosecond.
The large current requirement is approximately constant and does not depend
significantly on the state of the circuit.
Disadvantages
The circuit require a lot of power.
Most of this power is wasted as heat.
Usage
It is used in high speed application.
Older high and mainframe computers used ECL
It is used in systems such as supercomputers and signal processors where high speed is
essential.
The triple compound ―metal oxide semiconductor‖ is a reference to the nature of the
physical structure of the field effect transistors.
Characteristics
They have a very high input resistance.
They are compatible with one another.
They possess high noise immunity.
They have low static power supply drain.
CMOS allows a high density of logic functions on a chip.
Heat dissipation is low.
It is simple.
Sophisticate protection circuitry.
Usage
It is used in chips such as microprocessors, micro controllers, static RAM and other
digital logic circuits.
CMOS technology is also used for a wide variety of analog circuits such as image sensor,
data converts and highly integrated transrecievers for many types of communication.
Current IBM mainframes use CMOS.
They are also used in battery powered equipment such as pocket calculators, digital wrist
watches and portable computers.
Advantages
These devices dissipate less power.
Their operation speed is high.
Manufacturing costs are low.
Both low to high and high to low output transitions are flat.
Simpler processing techniques during fabrications
More economical operation.
High packaging density of circuit
Disadvantages
Power consumption increases rapidly with clock speed.
CMOS devices have higher noise.
Department of BCA Page 41
Computer Architecture Sindhi college
Register
A register is a group of flip flop with each flip flop is capable of storing one bit of
information.
An ‗n‘ bit register has a group of ‗n‘ flip flops and is capable of storing any binary
information of ‗n‘ bits
The flip flops hold the binary information and the gates control when and how new
information is transferred into the register.
The clock input is common to all the 4 D-flipflop.it triggers all flip flops on the rising edge of
each clock pulse, and the binary data available at the four D inputs are latched into the register
Register load:
The transfer of new information into a register is called loading a register
Shift register
A register capable of shifting its binary information in one or both directions is called a
shift register
A shift register consists of a series of flip flops cascaded together, with the output of one
flip flop connected to the input of the next flipflop.all flip flops receives common clock
pulses that initiate the shift from one stage to the next
Shift register can be of two types depending upon the direction of shift
Unidirectional
Bidirectional
The selection lines S1 and S0 control the mode of operation of the register according to the
function table
Binary counter
Counter
A counter is a device which stores the number of times a particular event or process
has occurred.
Usage
Counters are found in almost all equipment containing digital logic.
Binary counter
A counter that follows the binary number sequence is called a binary counter.
An ‗n‘ bit binary counter is a register of n flip-flops and associated gates that follows a
n
sequence of states according to the binary count of n bits, from 0 to 2 -1
A counter circuit will usually employ flip-flops with complementing capabilities .both T
and JK flip flops have this property.
Increment Or
Clock Clear Load Count Operation
↑ 0 0 0 No Change
↑ 0 0 1 Increment Count By 1
↑ 0 1 x Load Inputs I0 Through I3
↑ 1 x x Clear Outputs To 0
The four control inputs – Clear, Clock, Load, Count determine the next state
Clear input is asynchronous and when equal to 0, causes the counter to be cleared.
X symbolize don‘t care conditions for the other inputs.
With the Load and Count inputs both 0, the output do not change.
Decoder
A decoder is a combination circuit that converts binary information from the ‗n‘
n
coded inputs to a maximum of 2 unique outputs.
The decoder has ‗n‘ inputs and ‗m‘ outputs and is also referred to as n x m decoder.
2 to 4 line decoder
Logical diagram
2 to 4 line decoder
3 to 8 decoder
Logical diagram
Truth table
INPUTS OUTPUTS
X2 X1 X0 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
These are decoded into 8 outputs, each output representing one of the combinations of
the three binary input variables.
The 3 inverter provide the complement of the inputs.
Each of the eight AND gates generates one of the binary combination.
Enable input is use to control the operation of the circuit.
NAND gate decoder and Truth table of 2 to 4 line NAND gate decoder
The circuit operates with complemented outputs and enables input E is also complemented
to match the outputs of the NAND gate decoder
Decoder expansion
Decoder of large size may be required while there are only small size decoders are
available.
In order to obtain the required size decoder two or more decoders can be combined.
A 3x8 decoder constructed using 2x4 decoders.
When A2=0 upper decoder is enabled, while the lower is disabled. Thus, the outputs
of the upper decoder correspond to minterms D0 through D3.
When A2=0 upper decoder is disabled, while the lower is enabled. Thus, the outputs
of the upper decoder correspond to minterms D4 through D7
Encoder
An encoder performs the inverse operation of a decoder.
n
It has 2 inputs and n output lines.
INPUTS OUTPUTS
D0 D1 D2 D3 D4 D5 D6 D7 A2 A3 A1
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
A0=D1+D3+D5+D7----1
A1=D2+D4+D6+D7----2
A2=D4+D5+D6+D7----3
Using the equation 1, 2 and 3
We can construct the encoder using three OR gate with 8 datelines.
Multiplexer
A multiplexer is a combinational circuit that receives binary information from one of 2n
input data lines and directs it to a single output line.
n n
A 2 to 1 multiplexer has 2 input data lines and n input selection lines whose bit
combinations determine which input data are selected for the output.
The multiplexer is often abbreviated as MUX or MPX. It is also called as a data selector.
Eg: 4 to 1 line multiplex..
Select output
S1 S0 Y
0 0 I0
0 1 I1
1 0 I2
1 1 I3
Function table
E S Y
0 X ALL 0'S
1 0 A
1 1 B
When E=0 the outputs have all 0‘s whether s is 0 or 1.
When E=1 the unit is enabled.
If S=0 data present at A will be selected
o If S=1 data present at B will be selected
Application of multiplexer
Data routing
Parallel to serial conversion
Logic function generation
Call routing
Memory unit
The computer memory is defined as one or more sets of chips that store data/program
instructions either temporarily or permanently.
RAM
RAM is the central storage unit in a computer system.
RAM is said to be volatile. Since its contents are accessible only as long as the computer
is on.
The content of RAM is cleared once the computer is turned off.
Steps that must be taken from the purpose of transferring a stored word out of memory are as
follows:
Apply the binary address of the desired word into the address lines.
Activate the read input.
ROM
ROM is special type of memory which can only be read and contents of which are not
lost even when the computer is switched off.
ROM also stores an initial program called the ‗Bootstrap load‘ whose function is to start
the computer system operating, once the power is turned on.
ROM can be manufacturer programmed or user programmed.
Manufacturer programmed-ROMs have data burnt into the circuitry. User programmed
ROMs can have the user load and then store read only programs.
ROM does not need a read control line since any time. The output lines automatically
provide the n bits of the word selected by the address value.
ROM is internally constructed by using with decoder and a set of OR gates.
Applications
It is widely used in the design of digital systems.
It is also employed in the design of control units for digital computers.
It is used as a memory unit to store fixed programs that are not to be altered and for tables of
constants that are not subject to change.
Types of ROM
Mark programmed ROM
Mark programming is done during the last fabrication process of the unit.
Classic mark programmed ROM chips are integrated circuits that physically encode the
data to be stored and thus it is impossible to change their contents after fabrication.
Applications
It is used in storing current time and date in a machine.
It is also used for storing port status.
They are used for storing messages in a mobile phone.
They are used for storing photographs in a digital camera.
Department of BCA Page 57
Computer Architecture Sindhi college
Application
ROM is used in embedded systems. This governs everything from industrial robots to home
appliances and consumer electronics (MP3 player, set-top boxes etc.) all of which are designed
for specific functions.
Answer the following questions:
What is a multipler? Explain with a neat circuit diagram a 4-to-1 multiplexer .
(3M,NOV/DEC 2010)
Explain ROM with a neat block diagram and write a note on different types of ROM.
(3M,NOV/DEC 2010)
What is shift register?(1M,OCT/NOV 2011)
What is flash memory? (1M,OCT/NOV 2011) (1M,OCT/NOV 2012)
Compare TTL,ECL & CMOS logic families. (5M,OCT/NOV 2011) (6M,OCT/NOV 2012)
Explain synchronous binary counters.
Explain 4 bit shift register. (7M,OCT/NOV 2011)
Explain 4 to 1 line multiplexer. (8M,OCT/NOV 2011)
What is decoder? (1M,OCT/NOV 2012)
Explain 3 to 8 line decoder.
What is encoder? Explain the octal to binary encoder, with truth table, logical expressions and
circuit diagram.
Explain SSI,MSI,LSI,VSLI(5M,OCT/NOV 2012)
Compare RAM and ROM. (4M,OCT/NOV 2012)
Explain 4 bit register with parallel load with a neat diagram. (7M,OCT/NOV 2012)
Explain magnetic disk memory. (4M,OCT/NOV 2012)
Chapter-3
Number system
Number a quantity or value expressed by a word or a symbol is called Number
Number system a set of symbols & rules for representation of numbers is called Number
System
They are classified into two types they are
Positional number system
Non positional number system
In this type each symbol represents a definite value irrespective of the position in which they
appear
Base or radix
The total number of different digits or symbols available in the number system is called ―base
or radix‖
The positional number system are classified into four types they are
4 3 2 1 0 -1 -2 -3
…..10 10 10 10 10 . 10 10 10 ……
The symbols used in this system are 0,1 0 & 1 are called ―bits‖
Bit is an abbreviation for a binary digit
The radix or base of this number system is 2
Weight structure of this number system is
4 3 2 1 0 -1 -2 -3
…..2 2 2 2 2 . 2 2 2 ……….
The weights increases from right to left by a power of two for each bit
The left most bit is the MSB & right most bit is the LSB
1 1 1 1 0 1 1 1 1
MSB LSB
Conversions
In this conversion the given decimal number is repeatedly divide by 2 for integer part until the
quotient is 0 and for fraction successively multiplying by 2
Eg: Convert 28.3125(10)---- (?)2
Eg:1110.011(2)-- (?)10
3 2 1 0 -1 -2 -3
=1x2 +1x2 +1x2 +0*2 +0x2 +1x2 +1x2
=1x8+1x4+1x2+0x1+0x0.5+1x0.25+1x0.125
=8+4+2+0+0+0.25+0.125
1110.011(2)=14.375(10)
In this conversion the given decimal number is repeatedly divide by 8 for integer part until the
quotient is 0 and for fraction successively multiplying by 8
Eg: Convert 549.1325(10) ----- (?)(8)
Eg: Convert 763.375(8) ---------- (?)(10)
2 1 0 -1 -2 -3
7x8 +6x8 +3x8 +3x8 +7x8 +5x8
7x64+6x8+3x1+3x0125+7x0.0156+5x0.00195
448+48+3+0.375+0.1092+0.00975
763.375(8) = 499.49395(10)
Octal Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
Eg: 4632.51(8) -------- (?)2
4 6 3 2 . 5 1
100 110 011 010 101 001
4632.51(8) =100110011010101001(2)
The bits of the binary numbers are grouped into groups of 3 bits starting from LSB for
integer and from MSB for fraction
If the last group contains less than 3 bits then place 0 for those place
Convert each group into a octal equivalent digit
Eg:01111.1101011(2)->(?)8
1.
2.
3. 1 7 . 6 5 4
4.17.654(8)
01111.1101011(2) = 17.654(8)
In this conversion the given decimal number is repeatedly divide by 16 for integer part until the
quotient is 0 and for fraction successively multiplying by 16
Eg:Convert 512.625(16)----- (?)10
1. convert each digit of the Hexa decimal number to a 4 digit binary number
2. combine all the resulting binary groups into a single binary number
The bits of the binary numbers are grouped into groups of 4bits starting from LSB for
integer and from MSB for fraction
If the last group contains less than 4 bits then place 0 for those place
Convert each group into a Hexa decimal equivalent digit
Eg: 11100.01(2)=(?)16
1 C . 4
11100.01(2) = 1 C .4(16)
Complements
There are two basic types of complements for any number systems they are
True complement
Radix minus one complement
True complement
This is formed by subtracting each digit of the number from the radix minus one of the
number system and then adding 1 to the result of subtraction
This is formed by subtracting each digit of the number from the radix minus one of the
number system
They are
1‘s complement
2‘s complement
1’s complement
010100->1‘s complement
2’s complement
The 2‘s complement of a binary number is formed by taking the 1‘s complement of
the number and then adding 1 to LSB position
Eg: 101011
010100->1‘s complement
1
010101->2‘s complement
Numbers that contain a sign bit followed by magnitude bits are called ―sign
magnitude number‖
In this MSB always represents the sign whether +ve or –ve
The remaining bits represent magnitude which is the value of the number
The negative numbers are represented as sign magnitude,1‘s complement &
2‘s complement
Bit->0,1
Nibble->4 bits
Byte->8 bits
Word-.2bytes->16 bits
>mantissa r-.radix
p->exponent
S Exponent Mantissa
Normalization
―The number succeeding the floating point is a non-zero number is called normalization‖
9 7
Eg: 0.0047x10 is represented as 0.49x10
-7 -9
0.00236x10 is the normalized form is 0.236x10
Binary arithmetic
Binary arithmetic consists of the operations such as addition, subtraction, multiplication, division
Binary addition
0+0=0
0+1=1
1+0=1
Eg: 128 64 32 16 8 4 2 1
64 0 1 0 0 0 0 0 0
+32 0 0 1 0 0 0 0 0
+96 0 1 1 0 0 0 0 0
step-1 128 64 32 16 8 4 2 1
+32 0 0 1 0 0 0 0 0
-16 0 0 0 1 0 0 0 0
+16
step-2 0 0 0 1 0 0 0 0
1's
1 1 1 0 1 1 1 1 complement
1
2's
1 1 1 1 0 0 0 0 complement
step-3 0 0 1 0 0 0 0 0
1 1 1 1 0 0 0 0
1 0 0 0 1 0 0 0 0
step-1 128 64 32 16 8 4 2 1
20 0 0 0 1 0 1 0 0
-32 0 0 1 0 0 0 0 0
-12
step-2 0 0 1 0 0 0 0 0 =>32
1 1 0 1 1 1 1 1 1's complement
1
1 1 1 0 0 0 0 0 2's complement
step-3 0 0 0 1 0 1 0 0 =>20
1 1 1 0 0 0 0 0 =>2’s com of 32
1 1 1 1 0 1 0 0
sign
step 4 1 1 1 1 0 1 0 0
0 0 0 0 1 0 1 1 1's complement
1
0 0 0 0 1 1 0 0 2's complement
step-1 128 64 32 16 8 4 2 1
-32 0 0 1 0 0 0 0 0
-16 0 0 0 1 0 0 0 0
-48 Take 2's complement for 32
step-2 0 0 1 0 0 0 0 0
1 1 0 1 1 1 1 1 1's complement
1
1 1 1 0 0 0 0 0 2's complement
step-3 add
1 1 1 0 0 0 0 0
1 1 1 1 0 0 0 0
1 1 1 0 1 0 0 0 0
sign
Discard carry bit MSB is 1 i.e sign
step-4 bit=1
step-5 1 1 0 1 0 0 0 0
0 0 1 0 1 1 1 1 1's complement
1
0 0 1 1 0 0 0 0 2's complement
Binary subtraction
0-0=0
1-0=1
1-1=0
This is the simple method of subtraction of bits according to the rules of binary subtraction
Eg:
1 0 0 1
-0 1 0 1
0 1 0 0
1 1 0 . 1 0 1 1 1 0
-0 1 0 . 0 0 0 1 0 1
1 0 0 . 1 0 1 0 0 1
1 0 1 1 . 0 0 1
-0 1 1 1 . 1 0 1
0 0 1 1 . 1 0 0
Unsigned numbers
1 1 0 1 0 0 1 comprehend
1 1 0 0 minuend
1 1 0 1 0 1 comprehend
1 1 0 1 0 0 1 0 1 minuend
Signed numbers
Unsigned numbers
28 0 0 1 1 1 0 0 comprehend
step-5 There is no end around Carry so the result is to be again take 2‘s complement
0 1 0 1 0 1 0
1 0 1 0 1 0 1 1's complement
1
1 0 1 0 1 1 0 2's complement & final result
Signed numbers
step-4 There is no end around Carry so the result is to be again take 2‘s complement
1 1 1 0 0 0 0 0
0 0 0 1 1 1 1 1 1's complement
1
0 0 1 0 0 0 0 0 2's complement & final result
Digital codes
Alphanumeric code are used to represent numbers, letters, symbols and instructions
Weighted codes
It obeys the positional weighting principles. In weighted code, the bits are multiplied by the
weights indicated and the sum of the weighted bits gives the decimal digit
BCD uses the binary number system to specify the decimal number 0 to 9.it is composed
of four bits
The weights are assigned according to the position occupied by these digits
BCD code
Decimal 8421
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
=>9 6 . 4 2
=>[1001011001000010]BCD
Disadvantages of BCD
Only 10 possible combinations are used to represent decimal numbers. remaining six
combinations of 4 bits are wasted
It is difficult to obtain complements used in subtraction
A weighted code is the 2421 code. Here the weight 2 is repeated twice
Digit
code for complement
Decimal Excess-3 complement decimal
0 0011 1100 9
1 0100 1011 8
2 0101 1010 7
3 0110 1001 6
4 0111 1000 5
5 1000 0111 4
6 1001 0110 3
7 1010 0101 2
8 1011 0100 1
9 1100 0011 0
Gray code
The gray code is a non weighted code. It differs from the preceding number by a single bit. So it
is called the ―unit distance code‖. It is also called reflected code or cyclic code
The MSB in the gray code is same as the corresponding MSB in the binary number
Going from left to right each adjacent pair of binary code bits are added to get the next
gray bit. The carries generated are ignored
Eg:
The MSB in the binary is the same as the corresponding MSB in the gray code
Going from left to right each binary code generated is added to the gray code bit in the
next adjacent position .the carries generated are ignored
Eg:
Gray
Decimal Binary code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
It is used to check for odd or even parity on a 9 bit code. (1 bit parity+8 data bits). The
inputs are labelled an A to I.
When number of 1s on the inputs is even, even output is high and odd is low.
When number of 1s on the inputs is odd, an odd output is high and even is low.
Parity checker
When this device is used as an even parity checker, the number of input bits should
always be even. When a parity error occurs the ∑even output goes low and the ∑odd
output goes high.
When it is used as an odd parity checker the number of inputs bits should always be
odd. When a parity error occurs, the ∑odd output goes low and the ∑even output goes
high.
Parity generator
When this device is used as an even parity generator the parity bit is taken at the ∑odd
output because their output is a 0. If there is an even number of input bits and it is a 1 if
there is an odd number.
When used as an odd parity generator, the parity bit is taken at the ∑even output because
it is a 0 when the number of inputs is odd.
Parity bit
2. Odd parity
Even parity
If the total number of 1‘s is even in the code or number then it is called as even parity
Odd parity
If the total number of 1‘s is Odd in the code or number then it is called as Odd parity
Only single bit errors can be detected using this method if doesn‘t check for 2 bit errors
in a group
Hamming code
The hamming code is used not only to detect a bit error but also to identify the bit that is
in error so that it can be corrected
The hamming code uses a number of parity bits depending on the number of information
bits, located at certain position in the code group
The steps are
Number of parity bits
Placement of parity bits in code
Assignment of parity bit values
Detecting & correcting an error
The number of parity bits to be included with the information bits is to be determined by
the relationship
P
2 >=M+P+1
P->number of parity bits M-
>number of information bits
The information bits are known but parity bit are found by trial & error method until the
relationship is satisfy
The parity bits are placed in the position that are ascending power of 2(1,2,4,8…)
1 2 3 4 5 6 7
Bits P1 P2 M1 P3 M2 M3 M4
P1,P2,P3=>parity bits
M1,M2,M3 & M4=>message bits or information bits
Assignment of parity bit values
Bit designation P1 P2 M1 P3 M2 M3 M4
Bit position 1 2 3 4 5 6 7
Binary position 001 010 011 100 101 110 111
Information bits (Mn)
Parity bits(Pn)
The number of parity checks made depend on the number o parity bits in the error
correcting code
The method is as follows
Problem
1. Find single error correcting code for 1001 using even parity
Solution:
Bit designation P1 P2 M1 P3 M2 M3 M4
Bit position 1 2 3 4 5 6 7
Binary position 001 010 011 100 101 110 111
Information bits (Mn) 1 0 0 1
Parity bits(Pn) 0 0 1
The single error correcting code for information 1001 using even parity is 0011001
Problem 2
Suppose information transmitted is the code word 0011001 if it is received as 0010001, find the
error that has occurred in transmission if even parity is used
Bit designation P1 P2 M1 P3 M2 M3 M4
Bit position 1 2 3 4 5 6 7
Binary position 001 010 011 100 101 110 111
Transmitted code 0 0 1 1 0 0 1
Received code 0 0 1 0 0 0 1
character code
Where each X is a 0 or 1
From the table the ASCII code of the upper case letter ‗A‘ has a code 100 0001 whose
equivalent in decimal number is 65
The range of ASCII set is from 0 to 127
Chapter-4
Basic Computer Organization And Design
Computer Organization
The organization of the computer is defined by its internal registers, timings and the set of
instructions that it uses.
Program
A program is a set of instructions that specify the operations, operands and the sequence by
which processing has to occur.
Instruction
An instruction is a binary code that specifies a sequence of micro operations for the computer.
Instruction Codes
An instruction code is a group of bits that instruct the computer to perform a specific operation.
It is usually divided into parts:
Operation code or opcode
Operand
Operand:
The operand is the data on which the operation is to be performed and it is stored either in
processor register or in memory.
Ex:
ADD A, B
ADD is an opcode
A and B are operands.
Stored Program Organization
The simplest way to organize a computer is to have one processor register called Accumulator
(AC) and an instruction code format consisting of two parts:
Opcode: specifies operation to be performed.
Operand: specifies an address of the data in the memory.
The data read from the memory is operated together with the content of AC.
Instructions are stored in one section of memory and the data is stored in another section.
When the second part of an instruction code specifies an operand, the instruction is said to
have an immediate operand.
When the second part specifies the address of an operand, the instruction is said to have a
direct address.
When the second part of the instruction specifies an address of a memory word in which the
address of the operand is found, it is called indirect address.
Effective Address: The address that can be directly used without modification to access an
operand in computation type instruction, or as the target address for a branch type instruction.
S2 S1 S0 Register
0 0 0 X
0 0 1 AR
0 1 0 PC
0 1 1 DR
1 0 0 AC
1 0 1 IR
1 1 0 TR
1 1 1 Memory
The particular register whose LD (Load) input is enabled receives the data from the
BUS.
The memory receives the contents of the bus when its write input is activated.
The content of any register can be applied onto the bus and an operation can be
performed in the adder and logic circuit during the same clock cycle.
The clock transition at the end of the cycle transfers the content of the bus into the
designated destination register and the output of the adder and logic circuit into AC.
For example, the two micro-operations:
This can be done by placing the content of AC on the bus (with S2S1S0 = 100), enabling
the LD(load) input of DR, transferring the content of DR through the adder and logic
circuit into AC, and enabling the LD (load) input of AC, all during the same clock cycle.
The total number of instructions chosen for the basic computer is 25 as shown in Fig:
Instructions for moving information to and from memory and processor registers
LDA, STA
Program control instructions together with instructions that check status conditions
BUN, BSA, ISZ
CPU is partitioned into Arithmetic Logic Unit (ALU) and control unit (CU).
"The function of control unit is to generate relevant timing and control signals to
all Operations in the computer."
It controls the flow of data between the processor and memory and peripherals.
There are two major types of control organization: Hardwired control and micro Programmed
control.
For example:
Consider the case where SC is incremented to provide timing signals T0, Tl, T2, T3, and T4
in Sequence.
Initially, the program counter PC is loaded with the address of the first instruction in the
Program.
The Sequence counter SC is cleared to 0, providing a decoded timing signal T0.
After each clock pulse, SC is incremented by one, so that the timing signals go through T0,
Tl, T2, and so on.
The micro operations for the fetch phase can be specified by the following
Register transfer statement:
T0: AR ← PC
The address stored in PC is transferred to AR.
T1: IR ← M [AR], PC ← PC + 1
The instruction stored in memory address contained in AR is transferred to AR
and PC is incremented to point to the next instruction.
To provide the data path for the micro operation T0: AR←PC
The content of PC is placed onto the bus by making the bus selection inputs S2 Sl S0:010.
The content of the bus is transferred to AR by enabling the LD input of AR.
To provide the data path for the micro operation T1: IR←M [AR], PC←PC +1
The micro operations for the decode phase con be specified by the following
Register transfer statements:
If the-decoder output is D7:0 then the opcode in binary is must be one of the values from
to 110.
Then the instruction is memory reference instruction. Then
th
if the 15 bit I=0, it is direct address. Then if
th
the 15 bit I=1, it is indirect address.
.
This can be symbolized as follows:
D7'I T3: AR ← M [AR] D7'I'T3:
Nothing
D7 I' T3: Execute a register-reference instruction
D7I T3: Execute an input-output instruction
Register-Reference Instructions
The effective address of the instruction is in the address register AR and was placed there
during timing signal T2 when I = 0, or during timing signal T3 when I=1.
AND to AC
This is an instruction that performs the AND logic operation on pairs of bits in AC and the
memory word specified by the effective address.
D0T4: DR←M[AR]
D0T5: AC←AC +DR, SC←O
ADD to AC
This instruction adds the content of the memory word specified by the effective address to the
value of AC.
The sum is transferred into AC and the output carry Cout is transferred to the E
(extended Accumulator) flip-flop.
D1T4: DR ←M[AR]
D1T5: AC ← AC + DR, E ←Cout, SC ← 0
LDA: Load to AC
This instruction transfers the memory word specified by the effective address to AC. The
Micro operations needed to execute this instruction are
D2T4: DR ←M[AR]
D2T5: AC ← DR, SC ← 0
STA: Store AC
This instruction stores the content of AC into the memory word specified by the effective
address.
D3T4: M [AR] ← AC, SC ←0
“The BSA instruction performs the function usually referred to as a subroutine call.
The indirect BUN instruction at the end of the subroutine performs the function referred to
as a subroutine return.”
This instruction is useful for branching to a portion of the program called a subroutine or
Procedure.
When this instruction is executed, control goes to the indirect phase to read the effective
address at location 135, where it finds the previously saved address 21.
When the BUN instruction is executed, the effective address 21 is transferred to PC.
The next instruction cycle finds PC with the value 21, so control continues to
Execute the instruction at the return address.
The two control flags FGI and FGO are used to control the input and output transfer.
When a key is struck in the keyboard, an 8-bit alphanumeric code is shifted into INPR and
the input flag FGI is set to 1.
The computer checks the flag bit; if it is 1, the information from INPR is transferred in
parallel into AC and FGI is cleared to 0.
AC (0−7) ← INPR, FGI ← 0
The OUTR works similarly but the direction of information flow is reversed.
Initially, the output flag FGO is set to 1.
The computer checks the flag bit, if it is 1, the information from AC is transferred in parallel
to OUTR and FGO is cleared to 0.
Input and output instructions are needed for transferring information to and from AC register,
for checking the flag bits, and for controlling the interrupt facility.
Input-output instructions have an operation code 1111 and are recognized by the control
when D7 = 1 and I = 1.
The control functions and micro operations for the input-output instructions are listed
below:
D7 IT3 = p (common to all input-output instructions) IR(i) = Bi [bit in IR (6−11) that
specifies the instruction]
Interrupt Cycle
Instruction Cycle
During the execute phase of the instruction cycle IEN is checked by the control.
If IEN=0, it indicates that the programmer does not want to use the interrupt, so control
continues with the next instruction cycle.
If IEN = 1, control checks the flag bits FGI and FGO.
If both flags FGI=0 and FGO=0
It indicates that neither the input nor the output registers are ready for transfer of
information.
In this case, control continues with the next instruction cycle.
If either flag FGI or FGO is set to 1 while IEN = 1, flip-flop R is set to 1.
At the end of the execute phase, control checks the value of R, and if R=1, it goes to an
interrupt cycle instead of an instruction cycle.
Interrupt Cycle
The interrupt cycle is a hardware implementation of a branch and save return address
Operation.
The return address available in PC is stored in a specific location. Here we choose the
memory location at address 0 as the place for storing the return address.
M[0] ← PC
Then the address 1 is inserted into PC to branch to location 1.
PC ← 1
The IEN and R are cleared so that no more interruptions can occur until the interrupt
request from the flag has been serviced.
IEN ← 0 , R← 0
Example:
Suppose that an interrupt occurs and R is set to 1 while the control is executing the
instruction at address 255. At this time, the return address 256 is in PC.
The programmer has previously placed an input-output service program in memory
starting from address 1120 and a BUN 1120 instruction at address 1.
The content of PC (256) is stored in memory location 0, PC = 1, and R=0.
At the beginning of the next instruction cycle,
The instruction that is read from memory is in address 1 since this is the content of PC.
The branch instruction at address 1 causes the program to transfer to the input-output
service program at address 1120.
This program checks the flags, determines which flag is set, and then transfers the required
input or output information.
Once this is done, the instruction ION is executed to set IEN to 1 (to enable further
interrupts), and the Program returns to the location where it was interrupted.
Questions:
Define computer organization? (Nov-2012:1-Mark)
Explain BUN and LDA instructions? (Nov-2012:5-Marks)
What is program?
What is an instruction code?
Define opcode and operand? (Nov-2012:1-Mark)
Explain basic computer three instruction code formats. (Nov-2011:9-Marks)
What is immediate address?
Define direct and indirect address?
What is effective address?
What is BUS?
What are the 3 control inputs for registers in common bus system?
Mention the 4 steps of instruction cycle?
Explain LDA and STA instructions? (Nov-2011:5-Marks)
Give the micro operations for fetch and decode phase?
What is interrupt?
Define micro operation. Give example. (Nov-2012 & Nov:2011:1-Mark)
Define macro operation. Give example.
What is hardwired control unit?
What is register transfer and register transfer language? (Nov-2011:1-Mark)
Explain stored program organization of a basic computer with a neat diagram?
Explain the various registers of basic computer how the basic computer registers are
connected to a common bus? (Nov-2010:14-Marks)
Distinguish between hardwired and micro programmed control unit organization?
Explain the control signals generation in basic computer (hardwired control unit
organization)?
Explain BSA, AND, ISZ memory reference instructions? (Nov-2010:5-Marks)
Explain any five register reference instructions?
Explain input and output configuration with a neat diagram?
Explain interrupt cycle with a neat diagram?
Explain various input output instructions?
Chapter-5
Central Processor Organization
The output of each register is connected to two multiplexers (MUX) to form the two
buses A and B.
The selection lines in each multiplexer select one register or the input data for the
particular bus.
The A and B buses form the inputs to a common arithmetic logic unit (ALU).
The operation selected in the ALU determines the arithmetic or logic micro operation that
is to be performed.
The result of the micro operation is available for output data and also goes into the inputs
of all the registers.
The register that receives the information from the output bus is selected by a decoder.
The decoder activates one of the register load inputs, thus providing a transfer path
between the data in the output bus and the inputs of the selected destination register.
The control unit that operates the CPU bus system directs the information flow through
the registers and ALU by selecting the various components in the system.
Control Word
“Control word is a word whose individual bits represent the various control signals‖
Format:
3 3 3 5
SELA SELB SELD OPR
The 14-bit control word when applied to the selection inputs specify a particular
micro operation.
The encoding of register selection is specified in the following table:
When SELA or SELB is 000, the corresponding multiplexer selects the external
input data.
When SELD = 000, no destination register is selected but the contents of the output
bus are available in the external output.
The ALU provides arithmetic and logic operations. The encoding of the ALU
operations for the CPU is specified in Table.
The OPR field has five bits and each operation is designated with a symbolic name.
AC is the accumulator register and M[X] symbolizes the memory word located at
address X.
The number of address fields in the instruction can be reduced from three to two if
the destination register is the same as one of the source registers.
Thus the instruction ADD R1, R2 denote the operation R1 ← R1 + R2.
Stack organization:
Stack: A storage device that stores information in such a manner that the item stored last
is the first item retrieved (LIFO policy).
Stack pointer (SP): points at the top item in the stack
Push: Operation to insert an item into the stack.
Pop: Operation to retrieve an item from the stack.
―In this organization all the operands are implied to be in the stack and hence there is no need
to specify operands with an address field‖
Ex: The instruction ADD in a stack computer consists of an operation code only with no address
field.
There is no need to specify operands with an address field since all operands are implied to be in
the stack.
Instruction Formats
Types Of Instructions
Based on the number of address fields present in the instruction the instruction can be classified
into following types:
Advantages:
Results in short programs
Instructions becomes long
Addressing Modes
―Addressing mode specifies a rule for identifying the operand location‖.
Implied:
In this mode the operands are specified implicitly in the definition of the instruction.
Ex:
The instruction "CMA" is an implied-mode instruction because the operand in the
accumulator register is implied in the definition of the instruction.
Zero-address instructions in a stack-organized computer are implied-mode instructions
since the operands are implied to be on top of the stack.
EA=AC or EA=stack [sp]
Immediate Mode:
In this mode the operand is specified in the instruction itself.
Ex: ADD 5 -----add operand 5 to the contents of accumulator.
Address field=operand.
Direct Address Mode:
Department of BCA Page 113
Computer Architecture Sindhi college
In this mode the effective address is equal to the address part of the instruction.
The operand resides in memory and its address is given directly by the address field of the
instruction.
Ex: ADD A —Add contents of location A to accumulator.
EA = address field A
Indirect Address Mode: In this mode the address field of the instruction gives
the address where the effective address is stored in memory.
EA=M [A]
Register Mode: In this mode the operands are in registers that reside within the CPU.
EA=R
Ex: ADD [R] where register R contains the address of the operand
EA=M[R]
When the address stored in the register refers to a table of data in memory, it is necessary to
increment or decrement the register after every access to the table.
This can be achieved by using the auto increment or auto decrement mode.
Relative addressing:
EA=Address part of the instruction + Contents of some register
In this mode the content of the program counter is added to the address part of the instruction in
order to obtain the effective address.
Arithmetic Instructions
These instructions are used to perform arithmetic operations such as addition, subtraction,
multiplication, and division.
Shift Instructions
Shift operations are used to move the the bits of a word to the left or right.
Program Control
Instructions are stored in memory in consecutive locations.
When processed in the CPU, the instructions are fetched one by one from the memory
and are executed.
Program control instructions are used to alter the flow of execution of a program.
Unconditional branch:
Causes a branch to the specified address without any conditions.
Skip
This is a zero address instruction used to skip the next instruction if the condition is
met.
The bits are set or cleared as a result of an operation performed in the ALU.
1. Bit C (carry) is set to 1 if the end carry C8 is 1. It is cleared to 0 if the carry is 0.
Subroutine call: Transferring the control from main program to the subroutine is called
as subroutine call.
Subroutine return: Transferring the control from the subroutine back to the main
program is called subroutine return.
In assembly language subroutine call is performed using BSA instruction and subroutine return
is performed by placing BUN instruction at the end of the subroutine.
The most efficient way is to store the return address in a memory stack.
The advantage of using a stack for storing the return address is that:
When a succession of subroutines is called, the sequential return addresses can be pushed
into the stack.
The return from subroutine instruction causes the stack to pop and the contents of the top
of the stack are transferred to the program counter.
If another subroutine is called by the current subroutine, the new return address is pushed
into the stack and so on.
Department of BCA Page 120
Computer Architecture Sindhi college
The instruction that returns from the last subroutine is implemented by the micro operations:
PC←M [SP] Pop stack and transfer to PC
SP ←SP + 1 Increment stack pointer
Program Interrupt
―Program interrupt refers to the transfer of program control from a currently running program
to another service program as a result of an external or internal generated request.‖
Control returns to the original program after the service program is executed.
The interrupt procedure is, in principle, quite similar to a subroutine call except for
three variations
The interrupt is usually initiated by an internal or external signal rather than
from the execution of an instruction.
The address of the interrupt service program is determined by the hardware rather
than from the address field of an instruction. and
An interrupt procedure usually stores all the information.
The state of the CPU at the end of the execute cycle (when the interrupt is recognized) is
determined from:
The content of the program counter
The content of all processor registers
The content of certain status conditions
The collection of all status bit conditions in the CPU is sometimes called a program status word
or PSW.
The PSW is stored in a separate hardware register and contains the status information that
characterizes the state of the CPU.
Types Of Interrupts
There are three major types of interrupts that cause a break in the normal execution of
a program.
They can be classified as:
External interrupts
Internal interrupts
Software interrupts
External interrupts
External interrupts come from input-output (I/O) devices, from a timing device, from a
circuit
monitoring the power supply, or from any other external source.
Microprocessor Organization
An important aspect of computer architecture is the design of the instruction set for
the Microprocessor.
The instruction set chosen for a particular computer determines the way that machine
language programs are constructed.
CISC Characteristics:
Variable length instructions formats are used.
A large number of instructions—typically from 100 to 250 are provided.
Some instructions that perform specialized tasks and are used infrequently.
A large variety of addressing modes—typically from 5 to 20 are provided.
The Instructions provide direct manipulatio of operands residing in memory.
RISC Characteristics:
It has Relatively few instructions.
There are Relatively few addressing modes.
Memory access limited to load and store instructions.
All operations done within the registers of the CPU.
Instruction format is of Fixed-length.
Instructions easily decodable.
Instruction execution takes place in a Single clock cycle.
Hardwired control is used.
Compiler support for efficient translation of high-level language programs into
machine language programs.
A relatively large number of registers in the processor unit.
Efficient instruction pipeline.
CISC RISC
Emphasis is on hardware Emphasis is on Software
It includes Multi clock complex instructions It includes single clock reduced instructions
Memory-to-memory: Register to Register:
―LOAD‖ and ―STORE‖ incorporated in ―LOAD‖ and ―STORE‖ are independent
instructions instructions
Code size is small but complex Code size is large but simple
Transistors are used for storing complex More transistors are used for memory
instructions registers
Variable length instruction formats are used Fixed length instruction formats are used
Instruction decoding is complex Instruction decoding is easy
No instruction pipelining is used It uses instruction pipelining
Large number of instructions and addressing Relatively lower number of instructions and
modes are provided addressing modes are used
Ex:VAX,IBM 370 computer Ex:Alpha,ARC,ARM,SPARC,MIPS,SuperH
Questions:
Chapter-6
Input Output Organization
I/O Subsystem
The I/O subsystem provides the mechanism for communication between the CPU and the
outside world (I/O devices).
Input-Output Interface
Interface is a boundary across which two independent components communicate with
each other.
I/O Interface: is a special hardware component included between the CPU and
peripherals to supervise and synchronize all input and output transfers.
The purpose of the I/O interface is to resolve the differences that exist between the CPU
and peripherals.
Peripherals CPU
Peripherals are electro mechanical devices. CPU is an electronic device
The communication between processor and the peripheral takes place as follows:
In order to communicate with a particular device, the processor first places a device
address on the address lines.
Each interface attached to the I/O bus contains an address decoder that monitors the
address lines.
When the interface detects in 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.
The processor simultaneously provides a function code (I/O command) in the control
lines.
The selected interface responds to the function code and executes it.
Control Command:
A control command is issued to activate the peripheral and to inform it what to do.
Ex: A magnetic tape unit may be instructed to backspace the tape by one record, to
rewind the tape, or to start the tape moving in the forward direction.
Status command
A status command is used to test various status conditions in the interface and the
peripheral.
Ex: The computer may wish to check the status of the peripheral before a transfer is
initiated.
During the transfer, one or more errors may occur which are detected by the interface.
These errors are designated by setting bits in a status register that the processor can read
at certain intervals.
Data Output
A data output command causes the interface to respond by transferring data from the
bus into one of its registers.
Ex: with a tape unit. The computer starts the tape moving by issuing a control
command.The processor then monitors the status of the tape by means of a status
command.When the tape is in the correct position, the processor issues a data output
command.The interface responds to the address and command and transfers the
information from the data lines in the bus to its buffer register. The interface then
communicates with the tape controller and sends the data to be stored on tape.
Data Input
This command causes the interface to receive data from the peripheral and place it in the
buffer register.
When data is available (The processor checks if data are available by means of a status
command) the interface places the data on the data lines, which are accepted by the
processor.
There are three ways that computer buses can be used to communicate with memory and
I/O:
Independent I/O: Use two separate buses, one for memory and the other for I/O.
Isolated I/O: Use one common bus for both memory and I/O but have separate control
lines for each.
Memory mapped I/O: Use one common bus for memory and I/O with common
control lines.
Independent I/O
In this method, the computer has independent sets of data, address, and control buses,
one for accessing memory and the other for I/O.
This is done in computers that provide a separate I/O processor (IOP) in addition to
the central processing unit (CPU).
The memory communicates with both the CPU and the IOP through a memory bus.
The IOP communicates also with the input and output devices through a separate I/O
bus with its own address, data and control lines.
The purpose of the IOP is to provide an independent pathway for the transfer of
information between external devices and internal memory.
Isolated I/O
It uses one common bus to transfer information between memory or I/O and the
CPU.
The CPU has distinct input and output instructions, and each of these instructions is
associated with the address of an interface register.
When the CPU fetches and decodes the operation code of an input or output instruction, it
places the address of the I/O interface associated with the instruction into the common
address lines.
At the same time, it enables the I/O read (for input) or I/O write (for output) control
line.
This informs the external components that are attached to the common bus that the
address in the address lines is for an interface register and not for a memory word.
On the other hand, when the CPU is fetching an instruction or an operand from memory,
it places the memory address on the address lines and enables the memory read or
memory write control line.
So the isolated method isolates memory and I/O addresses such that memory addresses are not
affected by interface addresses as each one has its own address space.
2) Serial Transmission
Data is transmitted one bit at a time one after the other.
Therefore Asynchronous data transfer between two independent units requires that control
signals be transmitted between the communicating units to indicate the time at which data is
being Transmitted.
Procedure:
The source unit first places data on the data bus.
There is a brief delay to ensure that data settles to a steady value.
The source then activates the strobe pulse.
The data on the data bus and strobe pulse remain in active state for a certain period of time
The destination uses the falling edge of the strobe pulse to transfer the contents of data bus
into of its internal registers.
The source then disables the strobe pulse.
After a brief period, the source removes the data from the bus.
Procedure:
The destination unit activates the strobe pulse, informing the source to provide the data.
The source unit responds by placing the requested binary information on the data bus.
The data must be valid and be available on the bus for certain duration so that the
destination can accept it.
The destination register can be triggered by the falling edge of the strobe pulse.
The destination unit then disables the strobe.
The source removes the data from the data bus after a predetermined time interval.
Example: For a memory read operation, the strobe could be memory read control signal from
the CPU to a memory unit.The CPU (destination), indicates the read operation to inform the
memory unit (source) to place a selected word into the data bus.
Handshaking
Each data item being transferred can along with it have a control signal that indicates the
presence of data on the bus.
The unit receiving the data item responds with another control signal to acknowledge receipt of
the data. This type of agreement is called Handshaking.
Here,
The data bus is used for carrying data that is transferred.
The two handshaking signals are:
Data valid that is generated by the source unit and
Data accepted that is generated by the destination unit.
The timing diagram shows the exchange of signals between two units.
The 4 possible states in which the system can be set at any given time is as shown below:
Procedure:
i. The source unit initiates the data transfer process by placing the data on the data bus and
enabling its data valid signal.
The data from the bus is accepted by the destination unit.
The destination unit then activates the data accepted signal.
The source unit then disables its data valid signal which in turn removes the data on the bus.
The destination unit then disables its data accepted signal .This shows that the destination
unit is ready to accept the new data.
The system then goes into initial state.
The rate of data transfer is determined by the slowest unit.
The timing diagram shows the exchange of signals between the two units.
The four possible states in which the system can be at any given time is shown below:
Procedure:
i. When the destination unit is ready to accept data, it sends the control signal ready for data
to the source unit.
The source unit then place data on the bus and sends the control signal data valid to the
destination unit.
The destination unit accepts data from the bus and then disables the ready for data control
signal.
The source unit then disables data valid signal
It then invalidates the data on the data bus.
The system then goes into the initial state.
Start Bit- First bit, called start bit is always zero and used to indicate the beginning character.
Stop Bit- Last bit, called stop bit is always one and used to indicate end of characters. Stop bit is
always in the 1- state and frame the end of the characters to signify the idle or wait state.
Character Bit- Bits in between the start bit and the stop bit are known as character bits. The
character bits always follow the start bit.
I/O Processor
A processor with direct memory access capability that communicates with I/O devices.
The IOP is similar to a CPU except that it is designed to handle the details of I/O
processing. The IOP can fetch and execute its own instructions. IOP instructions are
specifically designed to facilitate I/O transfers.
Block diagram of
computer with
IOP
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 data needed in the solution of computation tasks.
The IOP provides a path for transfer of data between various peripheral devices and the
memory unit.
The CPU sends a test I/O instruction to IOP to test the IOP path.
The IOP path responds by inserting a status word in memory location.
The CPU refers to the status word in memory. If everything is in order, the CPU sends
the start I/O instruction to start the I/O transfer.
The IOP accesses memory for IOP program.
The CPU can now continue with another program while the IOP is busy with the
program.
Both programs refer to memory by means of DMA transfer.
When the IOP terminates the execution of its program, it sends an interrupt request to the
CPU.
The CPU then issues a read I/O instruction to read the status from the IOP.
The IOP transfers the status word to memory location.
The status word indicates whether the transfer has been completed satisfactorily or if any
error has occurred during the transfer.
Programmed I/O
Programmed I/O operations are the result of I/O instructions written in the computer
program. Each data item transfer is initiated by an instruction in the program.
Transferring data under program control requires constant monitoring of the
peripheral by the CPU.
Once a data transfer is initiated, the CPU is required to monitor the interface to see
when a transfer can again be made.
In the programmed I/O method, transfer from an I/O device to memory requires the
execution of several instructions by the CPU such as:
o input instruction to transfer the data from the device to the CPU, and
o a store instruction to transfer the data from the CPU to memory.
Other instructions may be needed to verify that o
The data are available from the device and
to count the numbers of words transferred.
An example of data transfer from an I/O device through an interface into the CPU is shown in
Fig.
When a byte of data is available, the device places it in the I/O bus and enables its
data valid line.
The interface accepts the byte into its data register and enables the data accepted line.
The interface sets a it in the status register that we will refer to as an F or ―flag‖ bit.
The device can now disable the data valid line, but it will not transfer another byte
until the data accepted line is disabled by the interface.
A program is written for the computer to check the flag in the status register to
determine if a byte has been placed in the data register by the I/O device.
This is done by reading the status register into a CPU register and checking the value
of the flag bit.
If the flag is equal to 1, the CPU reads the data from the data register.
The flag bit is then cleared to 0 by either the CPU or the interface, depending on how
the interface circuits are designed.
Once the flag is cleared, the interface disables the data accepted line and the device
can then transfer the next data byte.
A flowchart of the program that must be written for the CPU is shown in Fig.
It is assumed that the device is sending a sequence of bytes that must be stored in memory.
The transfer of each byte requires three instructions:
Read the status register.
Check the status of the flag bit and branch to step 1 if not set or to step 3 if set.
Read the data register.
DMA is a technique for transferring data from main memory to a device without
passing it through the CPU.
CPU is only involved at the beginning and end of the transfer and interrupted only
after entire block has been transferred.
Direct Memory Access needs a special hardware called DMA controller (DMAC)
that manages the data transfer between memory and I/O device.
DMA Controller
The unit communicates with the CPU via the data bus and control lines.
The DMA controller has three registers: an address register, a word count register, and a
control register.
Address register: contains an address to specify the desired location in memory.
Word count register: holds the number of words to be transferred.
Control register: specifies the mode of transfer
Ex: read/write, burst/stealing, I/O to memory, I/O to I/O, memory to memory etc.
The registers in the DMA are selected by the CPU through the address bus by enabling
the DS (DMA select) and RS (register select) inputs.
The RD (read) and WR (write) inputs are bidirectional.
When the BG (bus grant) input is 0, the CPU can communicate with the DMA registers
through the data bus to read from or write to the DMA registers.
When BG = 1, the CPU has relinquished the buses and the DMA can communicate
directly with the memory by specifying an address in the address bus and activating the
RD or WR control.
The DMA communicates with the external peripheral through the request and
acknowledge lines.
DMA Transfer
The DMA is first initialized by the CPU. After that, the DMA starts and continues to transfer
data between memory and peripheral unit an entire block is transferred.
The CPU initializes the DMA by sending the following information through the data bus:
The starting address of the memory block where data are available (for read) or
Where data are to be stored (for write)
The word count, which is the number of words in the memory block
Control to specify the mode of transfer such as read or write
A control to start the DMA transfer
The branch address of the service routine can be chosen in two different ways:
Vectored interrupt:
In vectored interrupt, the source that interrupts supplies the branch information to the computer.
This information is called the interrupt vector.
Priority Interrupt
Software:
Polling is the software method used to identify the interrupt source having the highest
priority.
Only one branch address is used for all interrupts.
The priority of each interrupt source determines the order in which it is polled.
The source with the highest priority is tested first, and if its interrupt signal is on,
control branches to a routine that services that source.
Otherwise, the source with the next lower priority is tested, and so on.
―Polling is like picking up your phone every few seconds to see if you have a call.
…‖
Hardware
A hardware priority interrupt unit functions as an overall manager in an interrupt
system environment.
The unit accepts interrupt requests from many sources, determines which request has
the highest priority, and issues an interrupt request to the computer based on this
determination.
To speed up the operation, each interrupt source has its own interrupt vector address
to access its own service routine directly.
The hardware priority function can be established by either a serial or parallel
connection of interrupt lines.
The serial connection is called the daisy chain method.
Daisy-Chaining Priority
In daisy chaining method all the devices are connected in serial. The device with the highest
priority is placed in the first position, followed by lower priority devices.
All devices that can request an interrupt are connected serially and in priority order with the
highest priority device placed first on the daisy chain, farthest from the CPU, and the lowest
priority device placed last and closest to the CPU.
First, any (or all) of the devices signal an interrupt on the Interrupt Request line.
Next, the CPU acknowledges the interrupt on the Interrupt Acknowledge line.
A device on the line passes the Interrupt Acknowledge signal to the next lower priority device
only if it has NOT requested service.
The first device on the priority chain requiring service asserts it interrupt vector address
(VAD) on the CPU data bus.
The CPU services the device
The Interrupt Acknowledge signal is passed to the next lower priority device and steps 2 – 6
are performed for the next lower priority device.
It has an interrupt register whose bits are connected to the interrupt request lines of
different devices in the system.
It also has a mask register whose bits can be used to control the status of each
interrupt request.
The mask register has the same number of bits as the interrupt register.
Each interrupt bit and its corresponding mask bit are applied to an AND gate.
Priority Encoder
The priority encoder is a circuit that implements the priority function. The logic of the
priority encoder is such that if two or more inputs arrive at the same time, the input having the
highest priority will take precedence. The truth table of a four-input priority encoder is given
below.
Inputs Outputs
I0 I1 I2 I3 x y IST
1 x x x 0 0 1
0 1 x x 0 1 1
0 0 1 x 1 0 1
0 0 1 1 1 1
0 0 0 x x 0
= I'0I'1
= I'0I'1 + I'0I'2
(IST) = I0 + I1 + I2 +I3
Questions:
Write short notes on Isolated and memory mapped I/O (Nov-2010:3-Marks)
Explain the working of a DMA controller with a neat block diagram.(Nov-2010:8-Marks)
What is DMA? (Nov-2011:1-Mark)
Define Baud rare (Nov-2011:1-Mark)
Explain DMA transfer in a computer system? (Nov-2011:7-Marks)
What are online devices? (Nov-2012:1-Mark)
Explain Daisy chaining priority method.(Nov-2012:5-Marks)
Explain CPLI-IOP communication in detail. (Nov-2012:7-Marks)
Explain l/o bus and interface modules in a computer system. (Nov-2012:8-Marks)
Asynchronous Serial Transmission. (Nov-2012:5-Marks)
Explain programmed I/O. (Nov-2012:5-Marks)
What is polling?
Explain different types of I/O commands.
15.Explain handshaking method of asynchronous communication.
16.Explain strobe control method.
17.What are peripheral devices?
Chapter-7
Memory Organization
Memory:
Memory is storage unit used to store data and programs in a computer.
Memory Hierarchy:
Memory hierarchy is the combination of various storage devices arranged from fastest to
slowest of their access times.
Memory Hierarchy is to obtain the highest possible access speed while minimizing the
total cost of the memory system.
At the bottom of the hierarchy are the slow magnetic tapes used to store removable
files.
Next are the magnetic disks that are used as backup storage.
Next is the main memory that directly communicates with CPU and also with
auxiliary memory through I/O processor.
Cache Memory
The cache memory is a high speed memory that is used to compensate for the difference
in speed between main memory and CPU.
Parts of the current program and the data are copied from the main memory into the high
speed cache memory.
When the CPU refers to an instruction, it is fetched from the cache if it is already there.
The cache memory would be 5 times faster than main memory.
Levels of Cache
There are two levels of cache:
Level 1(L1) cache: It is on the processor chip.
Level 2(L2) cache: It is external to the processor chip.
Main Memory
It stores programs and data for immediate access and use by the CPU during processing.
It is in the form of semiconductor integrated circuits.
A computer with memory word length s-bits and m-bit address has a memory capacity
of
m m
2 s-bits memory words giving a memory bit capacity of 2 -1.
RAM
The Read and write (R/W) memory of a computer is called RAM.
The User can write information to it and read information from it.
With RAM any location can be reached in a fixed (and short) amount of time after
specifying its address.
The RAM is a volatile memory; it means information written to it lost when the
computer is turned off.
Dynamic RAM
Loses its stored information in a very short time (for milli sec.) even when power
supply is on.
DRAM stores a bit of data using a transistor and capacitor pair, which together
comprise a memory cell.
A capacitor is like a small bucket that is able to store electrons.
The problem with the capacitor‘s bucket is that it has a leak.
In a matter of a few milliseconds a full bucket becomes empty.
Therefore, for dynamic memory to work, either the CPU or the Memory Controller
has to come along and recharge all of the capacitors holding it before they discharge.
To do this, the memory controller reads the memory and then writes it right back.
This refresh operation happens automatically thousands of times per second.
This refresh operation is where dynamic RAM gets its name.
It takes time and slows down the memory.
D-RAM‘s are cheaper & slower.
Dynamic RAM forms the larger system RAM space.
Programs and data written into ROM permanently during manufacturer is called
firmware.
EPROM:
An EPROM is an erasable PROM.
The stored data in EPROM‘s can be erased by exposing it to UV light for
about 20 min.
It‘s not easy to erase it because the EPROM IC has to be removed from the
computer and exposed to UV light.
The entire data is erased and not selected portions by the user. EPROM‘s are
cheap and reliable.
RAM Chip
A RAM chip can have one or more control inputs that select the chip only when needed.
This is best suited for RAM chip communication with the CPU.
Department of BCA Page 148
Computer Architecture Sindhi college
A Bidirectional data bus is used to allow transfer of data either from memory to CPU
during read operation or from CPU to memory during write operation.
A bidirectional bus is constructed with three state buffers.
A three state buffer output can be placed in one of three possible states.
o Signal at logic 1
o Signal at logic 0
o High impedance
The high impedance state behaves like an open circuit and so the signal has no significance.
The memory capacity of RAM chip is 128 words each of 8 bits.
It has an 8 bit bi directional data bus.
The read and write inputs specify the two memory operations.
Read operation:
During read operation the CPU reads from memory by asserting READ and the address
from which to read.
The memory system responds by loading the data lines with the data stored at address
and asserts completion signal.
Write Operation:
The CPU writes a word into memory by first placing address in MAR and the word in
MDR.
It then asserts the WRITE signal.
After the value in MDR is stored in memory with address, contained in MAR, the
memory asserts the completion signal.
The operation of the RAM chip can clearly be understood by the function table.
When CS1=1 and CS2 =0, the memory can be placed in a write or read mode.
When WR=1 , the memory stores a byte from the data bus into a location specified by the
address input lines.
When RD=1, the contents of the selected byte is placed into the data bus.
ROM Chip
The data bus can be only in output mode since ROM can only read.
The nine address lines in the ROM chip specify any one of 512 bytes stored in it.
The two chip select inputs must be CS1=1 and CS2 =0 for the operation.Otherwise,data
bus is in high impedence state.
Since each RAM chip is of 128x8 capacities, 4 RAM chips are required. (128x4=512)
Since ROM chip capacity is 512x8, only one ROM chip is required.
10 address lines are used.
The ‗X‘ indicates those lines that must be connected to the address input in each chip.
7
RAM chips have 128 bytes (2 ) and so required 7 address lines.
9
ROM chip has 512 bytes (2 ) and so required 9 address lines.
RAM and ROM chips are connected to a CPU through the data and address buses
The low-order lines in the address bus select the byte within the chips and other lines in
the address bus select a particular chip through its chip select inputs.
Each RAM receives the 7 lower bits of the address bus to select one of the 128 possible
bytes.
A specific RAM chip selection can be determined from lines 8 and 9 in the address bus.
This is done with 2x4 decoder whose output is connected CS1 inputs of each RAM chip.
When
00=RAM1 is selected.
01=RAM2 is selected
10=RAM3 is selected.
11=RAM4 is selected
The RD and WR outputs from the CPU are applied to the inputs of each RAM is to
selected or ROM is to be selected.
If line
10 =0, RAM is selected.
10=1, ROM is selected.
CS1 is connected to RD control line for the ROM chip to be enabled only during read
operation.
Address line 1 to 9 are applied to input address of ROM.
RAM addresses assigned are 0 to 511.ROM addresses are assigned are 512 to 1023.
Auxiliary memory
The most common auxiliary devices used in computer systems are: Magnetic disks and tapes.
Magnetic disk
Disks are made of magnetic material shaped as a thin circular disk and protected by
plastic cover.
A disk can store information on both the surfaces.
To increase the capacity disks are assembled into disk pack which may include many
disks and hence many surfaces.
Information is stored on a disk surface in concentric circles of small width called tracks
each having a distinct diameter.
For disk packs, the tracks with the same diameter on the various surfaces are called a
cylinder.
A track is divided into smaller blocks called sectors.
The division of track into equal sized disk blocks (sectors) is set by the Operating system
during disk formatting (initialization).
Blocks are separated by fixed size interblock gaps, which include specially coded
control information written during disk formatting.
Transfer of data between main memory and disk takes place in units of disk blocks.
The disk pack is mounted in disk drive that includes a motor that rotates the disks.
The read/write head is the actual hardware mechanism that reads/writes a block.
There are separate read /write heads used on both sides of the platter to read from or write
to disk by magnetically storing the information on the surface of the disk.
The read or write heads are mounted on arms that can move them towards the central
spindle or towards the edge.
The arms are mounted on a common actuator that moves the heads together horizontally
inwards and outwards.
Access time
It is the average time required to reach a storage location in memory and obtain its contents.
Seek time
It is the time required by the disk controller to mechanically position the read/write head on the
correct track given the address of a disk block.
Associative Memory
The memory unit accessed by content is called an associative memory or content addressable
memory (CAM).
In an associative memory, when a word is written, no address is specified.
An empty unused location is used to store the word.
To read a word from associative memory, the content of the word, or part of the word, is
specified.
The memory locates all words which match specified content and marks them for reading.
Advantages:
This is suitable for parallel searches. It is also used where search time needs to be short
Disadvantages:
This is expensive than RAM, as each cell must have storage capability and logical circuits for
matching its content with external argument
Key register -This specifies which part of the argument word needs to be compared with words
in memory. If all bits in register are 1, the entire word should be compared. Otherwise, only the
bits having k-bit set to 1 will be compared.
Match Register- This has one bit for each word in memory. The corresponding bit will be set to
1, if it is matching
Each word in memory is compared in parallel with the content of the argument register.
The word that matches the bits of the argument register set a corresponding bit in the
match register.
Those bits in the match register that have been set indicate that their corresponding words
have been matched.
A sequential access to memory for those words, whose corresponding bits in the match
register have been set, causes reading of words in memory.
The key register provides a mask choosing a particular field or key in the argument word.
Those bits in the argument that have 1‘s in their corresponding position of the key
register are compared.
Ex:
Let the argument register A have the bit configuration 101 111100
Let the key register K have the bit configuration 111 000000
Since K has 1‘s in three left most positions, only the three left most position bits of A are
compared with memory words.
Let the memory word be 100 111100. Since A has 101 in these positions and memory
word has 100, there is no match.
Consider another memory to be 101 000001. Since A has 101 in the three left most
positions, and also the memory word, there is a match.
Cache Memory
Cache is a fast small memory which stores the active portions of the program and data.
The performance of the cache memory is measured in terms of a quality called ―Hit
Ratio”.
When the CPU refers to memory and finds the word in cache, it produces a hit.
If the word is not found in cache, it counts it as a miss.
The ratio of the number of hits divided by the total CPU references to memory (hits +
misses) is the hit ratio.
The hit ratios of 0.9 and higher have been reported.
For example,
A computer with cache access time of 100ns, a main memory access time of 1000ns
and a hit of 0.9 produce an average access time of 200ns.
This is a considerable improvement over a similar computer without a cache
memory, whose access time is 1000ns.
The basic characteristic of cache memory is its fast access time.
Therefore, very little or no time must be wasted when searching for words in the
cache.
―The transformation of data from main memory to cache memory is referred to as a
―Mapping Process”.”
There are three types of mapping procedures are available.
Associative Mapping
Direct Mapping
Set – Associative Mapping.
Consider the following memory organization to show mapping procedures of the cache
memory.
Associative Mapping
The associative mapping stores both the address and content (data) of the memory word.
Direct Mapping
The 15-bit CPU address is divided into two fields.
The 9 least significant bits constitute the index field and the remaining 6 bits form
the tag fields.
The main memory needs an address but includes both the tag and the index bits.
The cache memory requires the index bit only i.e., 9 bits.
k n
There are 2 words in the cache memory & 2 words in the main memory.
e.g: k = 9, n = 15
Each data word is stored together with its tag and the number of tag – data items in
one word of cache is said to form a set.
Each index address refers to two data words and their associated tags.
Each tag requires 6 bits & each data word has 12 bits, so the word length is 2(6+12)
=36 bits.
An index address of 9 bits can accommodate 512 cache words. It can accommodate
1024 memory words.
When the CPU generates a memory request, the index value of the address is used to
access the cache.
The tag field of the CPU address is compared with both tags in the cache.
Virtual Memory
Virtual memory management is a memory management technique that allows the
execution of processes that is not completely in memory.
The main advantage of this scheme is that user programs can be larger than physical
memory.
Each address referenced by the CPU goes through an address mapping from virtual
address to a physical address in main memory.
A virtual memory system provides mechanism for translating program generated
addresses into correct main memory locations.
This is done with dynamically, while programs are being executed in the CPU.
The mapping is handled automatically by means of mapping table.
Memory space
The address in main memory directly accessible for processing is called a physical
address.
The set of such physical addresses is called Memory space.
With virtual memory concept, the address space is allowed to be larger than the memory
space.
Example:
Let main memory capacity be 32K words. (32X1024=32768)
15
Physical address requires 15 bits since 32K=2
Let auxiliary memory capacity be 1M words=1024K words.
20
The address requires 20 bits as 2 =1M.
Thus auxiliary memory has a capacity for storing information equivalent to the capacity
5
of 2 =32 main memories.(20-5=5 address bits).
The address space is N=1024 K and main memory space M=32K.
Programs and data are transferred between main memory and auxiliary memory based on
the demands of CPU.
If program 1 is currently being executed then program 1and associated data will be
moved from auxiliary memory into main memory.
The memory page table consists of 8 words, one for each page.
The address in the page denotes the page number and the content of the word gives the
block number where that page is stored in main memory.
The pages 1, 2, 5 and 6 are in main memory in blocks 3, 0, 1 and 2 respectively.
The presence bit in each location indicates whether the page has been transferred from
auxiliary memory to main memory.
If presence bit=1,
The block number read is transferred to the two high order bits of the MAR.
The line number from the virtual address is transferred into the 10 low order bits of
the MAR.
A read signal to memory, transfers the content of the word to the main memory
buffer register to be used by the CPU.
If presence bit=0,
Then the word referenced by virtual address is not in main memory.
A call to the operating system is generated to fetch the required page from auxiliary
memory and place it into main memory before resuming computation.
The page number bits in the argument register are compared with all page numbers in
the page filed of the associative memory.
If the page number is found the 5 bit word is read out from memory. The
corresponding block number, being in the same word, is transferred to the main
memory address register.
If no match occurs, a call to the operating system is generated to bring the required
page from auxiliary memory.
Page Replacement
When a program starts execution, one or more pages are transferred into main
memory and the page table is set to indicate their position.
The program continues executing from main memory until it attempts to reference a
page from auxiliary memory. This condition is called a page fault.
When page fault occurs, the execution of the present program is suspended until the
required page is brought into main memory.
The operating system assigns this task to the I/O processor.
Meanwhile, control is transferred to the next program in memory that is waiting to be
processed in the CPU.
When the memory block has been assigned and the transfer completed, the original
program can resume its operation.
When there is no space in main memory, it is necessary to remove a page and then
bring in a new page from auxiliary memory.
The page that is least likely to be referenced in the immediate future should be
removed.
FIFO algorithm
The FIFO algorithm selects for replacement, the page that has been in memory for the
longest period time.
Each time a page is loaded into memory, its identification number is punished into a
FIFO stack.
FIFO will be full whenever memory has no more empty blocks.
When a new page has to be loaded, the page least recently brought in is removed.
The page to be removed is easily determined because its identification number is at
the top of the FIFO stack.
Advantage:
It is easy to implement.
Department of BCA Page 163
Computer Architecture Sindhi college
Disadvantage:
Under certain circumstances, pages are removed and loaded from memory too frequently.
LRU algorithm
It can be implemented by associating a counter with every page that is in main memory.
When a page is referenced, its associated counter is set to zero.
At the fixed interval of time, the counter associated with all page presently in memory are
incremented by 1.
The least recently used page is the page with the highest count.
The counters are often called aging registers, as their count indicates their age, that is,
how long ago their associated pages have been referenced.
Advantage:
It is more attractive because least recently used page is a better candidate for removal.
Disadvantage:
It is difficult to implement
Questions:
Write short note on address space and memory space. (Nov-2010:3-Marks)
Explain ROM with a neat block diagram and write a note on different types
Of ROM.(Nov-2010:6-Marks)
Explain associative memory with a neat diagram (Nov-2010:7-Marks)
What is the flash memory? (Nov-2011:1-Mark)
What is multiprogramming? (Nov-2011:1-Mark)
Explain FIFO page replacement algorithm. (Nov-2011:5-Marks)
Write a note on cache memory. (Nov-2011:5-Marks)
What is cache memory (Nov-2012:1-Mark)
Explain virtual memory. (Nov-2012:5-Marks)
Compare RAM and ROM. (Nov-2012:5-Marks)
Explain magnetic disk memory. (Nov-2012:5-Marks)
What is Hit Ratio?
Write a note on memory address map.
15.What is refreshing of dynamic memory.
16.Explain different types of mapping procedures used in the organization of cache memory?
17.What is page fault?