Module 03 Bk
Module 03 Bk
Module -03
Basic Structure of Computers: Basic Operational Concepts, Bus Structures,
Performance – Processor Clock, Basic Performance Equation, Clock Rate,
Performance Measurement.
Machine Instructions and Programs: Memory Location and Addresses,
Memory Operations, Instructions and Instruction Sequencing, Addressing
Modes .
Computer Organization
It describes the function of and design of the various units of digital computer that store and
process information.
• Input device accepts the coded information as source program i,e high level language. This
is either stored in the memory or immediately used by the processor to perform the desired
operations.
• The program stored in the memory determines the processing steps.
• Basically, the computer converts source program into object program (machine language).
Page 1
BCS302 | Digital Design and Computer Organization |
• Finally, the result is sent to outside world through output device. All these actions are
coordinated by the control unit.
Page 2
BCS302 | Digital Design and Computer Organization |
Processor components
Figure shows in detail how processor and memory are connected. Processor contains several
registers along with ALU and timing unit.
The processor contains ALU, control-circuitry and many registers.
Page 3
BCS302 | Digital Design and Computer Organization |
Interrupt: Normal execution of programs may be preempted if some device requires urgent
servicing. An interrupt is a request signal from an I/O device for service by the processor. The
processor provides the requested service by executing an appropriate interrupt service routine.
Page 4
BCS302 | Digital Design and Computer Organization |
Advantages:
1. Low cost.
2. Very flexible for attaching peripheral devices
• Buffer Registers
→ are included with the devices to hold the information during transfers.
→ prevent a high-speed processor from being locked to a slow I/O device during data transfers.
Performance – Processor Clock, Basic Performance Equation, Clock Rate,
Performance Measurement.
Page 5
BCS302 | Digital Design and Computer Organization |
1.3 Performance –
• The most important measure of a computer is how quickly it can execute programs.
Figure shows cache memory as part of the processor unit. The processor and a relatively small
cache memory can be fabricated on a single integrated circuit chip.
o Let us examine the flow of program instructions and data between the memory and the
processor. At the start of execution, all program instructions and the required data are stored in
the main memory. o As the execution proceeds, instructions are fetched one by one over the
bus into the processor, and a copy is placed in the cache later if the same instruction or data
item is needed a second time, it is read directly from the cache.
Page 6
BCS302 | Digital Design and Computer Organization |
• The term “million” is denoted by the prefix Mega(M) and “billion” is denoted by the prefix
Giga(G)
Write the basic performance equation. explain the role of each of the parameters in the equation
on the performance of the computer.
1.3.2 Basic Performance Equation
Let T = Processor time required to executed a Program.
N = Actual number of instruction executions.
S = Average number of basic steps needed to execute one machine instruction.
R = Clock rate in cycles per second.
Page 7
BCS302 | Digital Design and Computer Organization |
• The program selected range from game playing, compiler, and data base applications to
numerically intensive programs in astrophysics and quantum chemistry. In each case, the
program is compiled under test, and the running time on a real computer is measured.
• The same program is also compiled and run on one computer selected as reference.
• The „SPEC‟ rating is computed as follows.
If the SPEC rating = 50 Means that the computer under test is 50 times as fast as the ultra sparc
10.
This is repeated for all the programs in the SPEC suit, and the geometric mean of the result is
computed .
Where n is the number of programs in the suite
Geometrical mean= Is defined as the nth root of the product of n numbers
Problem 1:
List the steps needed to execute the machine instruction:
Load LOCA, R0
Solution:
1. Transfer the contents of register PC to register MAR.
2. Issue a Read command to memory. And, then wait until it has transferred the requested word
into register MDR.
3. Transfer the instruction from MDR into IR and decode it.
4. Transfer the address LOCA from IR to MAR.
5. Issue a Read command and wait until MDR is loaded.
6. Transfer contents of MDR to the ALU.
7. Transfer contents of R0 to the ALU.
8. Perform addition of the two operands in the ALU and transfer result into R0.
9. Transfer contents of PC to ALU.
10. Add 1 to operand in ALU and transfer incremented address to PC.
Page 8
BCS302 | Digital Design and Computer Organization |
Problem 2:
List the steps needed to execute the machine instruction:
Add R1, R2, R3
Solution:
1. Transfer the contents of register PC to register MAR.
2. Issue a Read command to memory. And, then wait until it has transferred the requested word
into register MDR.
Problem 3:
(a) Give a short sequence of machine instructions for the task “Add the contents of memory-
location A to those of location B, and place the answer in location C”.
Instructions:
Load Ri,
LOC and
Store Ri, LOC
are the only instructions available to transfer data between memory and the general purpose
registers.
Is it possible to use fewer instructions of these types to accomplish the task in part (a)? If
yes, give the sequence.
Solution:
(a)
Load
A, R0
Load
B, R1
Add
Page 9
BCS302 | Digital Design and Computer Organization |
R0, R1
Store R1, C
(b) Yes;
Move
B, C
Add
A, C
Problem 4:
A program contains 1000 instructions. Out of that 25% instructions requires 4 clock cycles,40%
instructions requires 5 clock cycles and remaining require 3 clock cycles for execution. Find the
total time required to execute the program running in a 1 GHz machine.
Solution:
N = 1000
T = (N*S)/R=
=(250*4+400*5+350*3)/1X109
=(1000+2000+1050)/1*109
= 4.05 μs.
Problem 5:
Solution:
Problem 6:
Page 10
BCS302 | Digital Design and Computer Organization |
(a) Program execution time T is to be examined for a certain high-level language program. The
program can be run on a RISC or a CISC computer. Both computers use pipelined instruction
execution, but pipelining in the RISC machine is more effective than in the CISC machine.
Specifically, the effective value of S in the T expression for the RISC machine is 1.2, bit it is only
1.5 for the CISC machine. Both machines have the same clock rate R. What is the largest
allowable value for N, the number of instructions executed on the CISC machine, expressed as a
percentage of the N value forthe RISC machine, if time for execution on the CISC machine is to
be longer than on the RISC machine?
(b) Repeat Part (a) if the clock rate R for the RISC machine is 15 percent higher than that for
the CISC machine.
Solution:
(a) Let TR = (NR X SR)/RR & TC = (NC X SC)/RC be execution times on RISC and CISC
processors.
Then Equating execution times and clock rates, we have 1.2NR = 1.5NC
1.2NR/1.15 = 1.5NC/1.00
Then
NC/NR =1.2/(1.15 X 1.5) = 0.696
Each group of n bits is referred to as a word of information and n is called the word length. The
memory of a computer can be schematically represented as a collection of words as shown in fig.
Modern computers have word lengths that typically range from 16 to 64 bits. If the word length of
a computer is 32 bits, a signal word can store a 32 bit 2‟s complement number or four ASCII
characters, each occupying 8bits, as shown in figure.
A unit of 8bit is called a byte. To retrieve information from memory, either for one word or
one byte (8-bit), addresses for each location are needed. A k-bit address memory has 2k memory
locations, namely 0 – 2k-1, called memory space. 24-bit memory: 224 = 16,777,216 = 16M
(1M=220)
32-bit memory: 232 = 4G (1G=230) , 1K(kilo)=210 , 1T(tera)=240
32 bits
Page 12
BCS302 | Digital Design and Computer Organization |
A byte is always 8 bits, but the word length typically ranges from 16 to 64 bits.
Page 13
BCS302 | Digital Design and Computer Organization |
Consider a 32-bit integer (in hex): 0x12345678 which consists of 4 bytes: 12, 34, 56, and
78. Hence this integer will occupy 4 bytes in memory.
Assume, we store it at memory address starting
1000. On little-endian, memory will look like
Address Value
1000 78
1001 56
1002 34
1003 12
On big-endian, memory will look like
Address Value
1000 12
1001 34
1002 56
1003 78
Page 14
BCS302 | Digital Design and Computer Organization |
Word Alignment
Words are said to be aligned in memory if they begin at a byte address that is a multiple of the
number of bytes in a word.
• 16-bit word: word addresses: 0, 2, 4,….
• 32-bit word: word addresses: 0, 4, 8,….
• 64-bit word: word addresses: 0, 8,16,….
o The store operations transfer an item of information from the processor to specific memory
location, destroying the former contents of that location.
• Steps for Store operation are:
1) Processor sends the address of the memory-location where it wants to store data.
2) Processor issues „write‟ signal to memory to store the data.
3) Content of register(MDR) is written into the specified memory-location.
Page 15
BCS302 | Digital Design and Computer Organization |
(LOC, R0,…)
• Contents of a location are denoted by placing square brackets around the name of the location
(R1←[LOC], R3 ←[R1]+[R2])
Example: consider the operations that adds the contents of register R1 and R2, then places
their sum into register R3.
R3 ← [R2] + [R2]
This type of notation is known as Register Transfer Notation (RTN).
• The possible locations in which transfer of information occurs are:
1) Memory-location 2)
Processor register & 3)
Registers in I/O device.
Page 16
BCS302 | Digital Design and Computer Organization |
Same in high level language statement requires the action to takes place in the computer
C ← [A] + [B]
i) In fetch phase, the instruction is fetched from the memory location (whose address is in the
PC) and placed in the IR (Instruction register) of the processor.
ii) In execute phase, the contents of IR(Instruction register) is examined to determine which
operation is to be performed. The specified operation is then performed by the processor.
Page 17
BCS302 | Digital Design and Computer Organization |
Program Explanation
• The Address of the memory-locations containing the n numbers are symbolically given as
NUM1, NUM2…..NUMn.
• Separate Add instruction is used to add each number to the contents of register R0.
• After all the numbers have been added, the result is placed in memory-location SUM.
Page 18
BCS302 | Digital Design and Computer Organization |
Branching
• Consider the task of adding a list of „n‟ numbers (Figure ).
• Number of entries in the list „n‟ is stored in memory-location N.
• Register R1 is used as a counter to determine the number of times the loop is executed.
• Content-location N is loaded into register R1 at the beginning of the program.
• The Loop is a straight line sequence of instructions executed as many times as needed.
The loop starts at location LOOP and ends at the instruction Branch>0.
• The instruction Decrement R1 reduces the contents of R1 by 1 each time through the loop.
• Then Branch Instruction loads a new value into the program counter. As a result, the
processor fetches and executes the instruction at this new address called the Branch
Target.
Page 19
BCS302 | Digital Design and Computer Organization |
Fig : (a) A st-line program for adding n nos. (b) Using loop to add n Numbers.
Condition Code:
The processor keeps track of information about the results of various operations for use by
subsequent conditional branch instructions. This is accomplished by recording the required
information in individual bits, often called conditional codes flags. These flags are usually
grouped together in a special processor register called the condition code register or status
register.
Individual condition code flags are set to 1 or cleared to 0, depending on the outcome of the
operation performed. Four commonly used flags are
• N (Negative) Set to 1 if the result is –ve otherwise cleared to 0.
• Z (zero) Set to 1 if the result is 0, otherwise cleared to 0.
• V (Overflow) Set to 1 if the arithmetic overflow occurs otherwise cleared to 0.
• C (Carry) Set to 1 if a carry out results from the operations otherwise cleared to 0.
Functions of different flags are as follows
N and Z flags
i. Indicate whether the result of arithmetic or logic operations is negative or zero.
Page 20
BCS302 | Digital Design and Computer Organization |
ii. Affected by instructions that transfer data, such as Move, Load and Store. iii. To
cause a branch based on the sign and value of the operand that was moved.
iv. Test instruction that examines a value in a register to in the memory and sets or clears the
N and Z flags.
V flag
i. Indicates whether overflow has taken place.
ii. Overflow occurs when the result of an arithmetic operation is outside the range of
values that can be represented by the number of bits available for the operands
C flag
i. If it set to 1 then it indicates carry occurs from the most significant bit position during
a arithmetic operation.
ii. This flag allows to-perform arithmetic operation on operands that are longer than the
word length of the processor.
Programmers use organizations called data structures to represent the data in computations. These
include lists, linked lists, array, and queues and so on. Translating high-level language to assembly
language requires compiler to use constants, local global variables, pointers and arrays to facilitate
with instruction set of the computer in which the program will be run.
“The different ways in which the location of an operand is specified in an instruction are referred
to as addressing modes.”
Page 21
BCS302 | Digital Design and Computer Organization |
2) Register Mode
• The operand is the contents of a register.
• The name (or address) of the register is given in the instruction.
• Registers are used as temporary storage locations where the data in a register are accessed.
• For example, the instruction
Page 22
BCS302 | Digital Design and Computer Organization |
Figure : (a) Through General Purpose Register (b) Through memory locations
Page 23
BCS302 | Digital Design and Computer Organization |
Program Explanation
i. In above program, Register R2 is used as a pointer to the numbers in the list, and the operands
are accessed indirectly through R2.
ii. The initialization-section of the program loads the counter-value n from memory-location N
into R1 and uses the immediate addressing-mode to place the address value NUM1, which is
the address of the first number in the list, into R2. Then it clears R0 to 0.
iii. The first two instructions in the loop implement the unspecified instruction block starting at
LOOP.
iv. The first time through the loop, the instruction Add (R2), R0 fetches the operand at location
NUM1 and adds it to R0.
v. The second Add instruction adds 4 to the contents of the pointer R2, so that it will contain the
address value NUM2 when the above instruction is executed in the second pass through the
loop.
Page 24
BCS302 | Digital Design and Computer Organization |
• To find EA of operand:
• An alternative use is illustrated in fig(b). Here, the constant X corresponds to a memory address,
and the contents of the index register define the offset to the operand. In either case, the effective-
address is the sum of two values; one is given explicitly in the instruction, and the other is stored
in a register.
Page 25
BCS302 | Digital Design and Computer Organization |
8) Relative Mode
• This is similar to index-mode with one difference:
The effective-address is determined using the PC in place of the general purpose register Ri.
Page 26
BCS302 | Digital Design and Computer Organization |
• Since the addressed-location is identified "relative" to the PC, the name Relative mode is
associated with this type of addressing.
• This mode is used commonly in conditional branch instructions. An instruction such as
Branch > 0 LOOP
;Causes program execution to go to the branch target location identified by name LOOP
if branch condition is satisfied.
Page 27
BCS302 | Digital Design and Computer Organization |
Page 28