Dd&Co III MODULE
Dd&Co III MODULE
MODULE 3 :
BASIC SRUCTURE OF COMPUTERS
1. FUNCTIONAL UNITS
1) Input
2) Memory
3) ALU
4) Output & Input unit
5) Control units.
VANDANA R
DD&CO
VANDANA R
DD&CO
VANDANA R
DD&CO
VANDANA R
DD&CO
1) The address off instruction (to be executed) gets loaded into PC.
2) The contents of PC (i.e. address) are transferred to the MR & control-unit issues Read
signal to memory.
3) After certain amount of lapsed time, the first instruction is read out of memory and
placed into MDR.
4) Next, the contents of MDR a e transferred to IR. At this point, the instruction can be decoded &
VANDANA R
DD&CO
executed.
5) To fetch an operand, its address is placed into MAR & control-unit issues Read signal. As
a result, the operand is transferred from memory into MDR, and then it is transferred from
MDR to ALU.
6) Likewise required number of operands is fetched into processor.
3. BUS STRUCTURE
• A bus is a group of lines that serves as a computer path for several devices.
• A bus may be lines or wires.
• The lines carry data or address or control signal
1) There are 2 types of Bus structures: 1) Single Bus structure and 2) Multiple Bus s ructure
2) Single Bus Structure
► Because the bus can be used for only one transfer at a time, only 2 units can actively use
the bus at any given time.
►Bus control lines a e used to arbitrate multiple requests for use of the bus.
► Advantages:
VANDANA R
DD&CO
► Systems that contain multiple buses achieve more con currency in operations.
► Two or more transfers can be carried out at the same time.
Advantage: Better performance.
► Disadvantage: Increased cost.
• The devices connected to a bus vary widely in their speed of ope ration.
• To synchronize their op rational-speed, buffer-registers can be used.
• Buffer Registers
_ are included with the devices to hold t he information during transfers.
_ prevent a high-speed processor from being locked to a slow I/0 device during data transfers.
4. PERFORMANCE
1. Processor clock
2. Basic performance equation
3. Clock rate
4. Performance measurement
• The most important measure of performance of computer is how quickly it can execute program
• The speed of a computer is affected by the design of
1) Instruction-set.
2) Hardware & the technology in which the hardware is implemented
3) Software including the operating system .
• Because programs are usually written in a HLL, performance is also affected by the compiler
that translates programs into machine language. (HLL High Level Language).
• For best performance, it is necessary to design the compiler, machine instruction set and hardware
in a co ordinated way.
VANDANA R
DD&CO
• Let us examine the flow of program instructions and data between the memory & the processor.
• At the start of execution, all program instructions are stored in the main-memory.
• As execution proceeds, instructions are fetched into the processor, and a copy is placed in the cache.
• Later, if the same instruction is needed a second time, it is read directly from the cache.
• A program will be executed faster
if movement of instruction/data between the main-memory and the processor is minimized
which is achieved by using the cache.
PROCESSOR CLOCK
• Processor circuits are controlled by a timing signal called a Clock.
• The clock defines regular time intervals called Clock Cycles.
To execute a machine instruction, the processor divides the action to be performed into a
sequence of basic steps such that each step can be completed in one clock cycle.
R=1/P
VANDANA R►
DD&CO
t
r.
This reduces the time needed to compute a basic step. (ICintegrated c rcuits).
This allows the clock period P to be reduced and the clock rate R to be increased.
2) Reducing the amount of processing done in one basic step also reduces the clock period P.
• In presence of a cache, the percentage of accesses to the main-memory is small.
Hence, much of performance-gain expected from the use of faster technology can be realized.
The value of Twill be reduced by same factor as R is increased,,." S & N are not
affected.
Problem 1:
List the steps needed to execute the machine instruction
add Ro, LOC
in terms of transfers between the components processor and some simple control commands. Assume that
the address of the memory-location containing this instruction is initially in register PC.
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.
VANDANA R
DD&CO
Problem 3:
A program contains 1000 instructions. Out of that 25% instructions requires 4 clock cycles,40% instructions
require 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
25% of N= 250 instructions require 4 clock cycles.
40% of N =400 instructions require 5 clock cycles. 35% of
N=350 instructions require 3 clock cycles.
T = (N*S)/R= (250*4+400*5+350*3)/1X10 9 =(1000+2000+1050)/1*109= 4.05 µs.
RISC CISC
Simple instructions taking one cycle com intructions taking multiple cycle.
Instructions are executed by hardwired control Instructions are executed by microprogrammed
unit. control unit.
Few Instructions Many instructions.
Fixed format instructions. Variable format instructions.
Few addressing modes and most instructions Many addressing modes.
have register to register addressing mode.
Multiple register set . Single register set.
Highly pipelined. No pipelined or less pipelined.
VANDANA R
DD&CO
1. Byte addressability
2. Big Endian & Little-Endian assignments
3. Word alignment
4. Accessing Numbers, Characters, Character string
VANDANA R
DD&CO
VANDANA R
DD&CO
• Consider a 32-bit integer (in ex): 0x12345678 which consists of 4 bytes: 12, 34, 56, and 78.
►Hence this integer will occupy 4 bytes n memory.
Assume, we store it at memory address starting 1000.
WORD ALLIGMENT
• Words said to be Aligned in memory if they begin at a byte-address that is multiple e o f the number
of bytes
Example
6. MEMORY OPERATION
• The Store operation transfers the information from the register to the specified
memory- location. This will destroy the original contents of that memory-
location.
• Steps for Store operation are:
1) Processor sends the address of the memory-location where it wants to store data.
2) Processor is use,, write" signal to memory to store the data.
3) Content of register(MDR) is written into the specified memory-location.
2 types of notation :
1. RTN
2. ALN
VANDANA R
DD&CO
• Access to data in the registers is much faster than to data stored in memory-locations.
• Let Ri represent a generate. The instructions: Load A,Ri
Store Ri,A
Add A,Ri
are generalizations of the Load, Store and Add Instructions for the single-accumulator case, in
which register Ri performs the function of the accumulator.
In processors, where arithmetic operations as allowed only on operands that are in register task
• C<-[A]+[B] can be performed y the instruction sequence:
Move A,Ri
Move B,RJ
Add Ri,Rj
Move Rj,C
VANDANA R
DD&CO
Program Explanation
• Consider the program for adding the content of A & B
• Separate Add instruction is used to add each number to the contents of registers .
• After all the content of A & B are transferred to register C.
VANDANA R
DD&CO
BRANCHING
Program Explanation
• Consider the program for adding a list of n numbers (Figure 2.9).
• The Address of the memory-locations containing then numbers are symbolically given as
NUMl, NUM2 NUMn.
• Separate Add instruction is used to add each number to the contents of register RO.
• After all the numbers have been added, the result is placed in memory-location SUM.
VANDANA R
DD&CO
CONDITIONL CODES
• The processor keeps track of information about the results of various operations. This is
accomplished by recording the required I nformation in individual bits, called Condition Code
Flags.
• These flags are grouped together in a special processor-register called the condition code register
(or statue register).
• Four C ommonly used flags are:
1) N (negative) set to 1 if the result is negative, otherwise cleared to 0.
2) Z (zero) set to 1 if the re ult is 0; otherwise, cleared to 0
3) V (overflow) set to 1 if arithmetic overflow occurs; otherwise, cleared to 0.
4) C (carry) set to 1 if a carry-out results from the op ration; otherwise cleared to 0.
VANDANA R
DD&CO
8. ADDRESSING MODES
1. Implementation of variable and constant
2. Indirection and pointers
3. Indexing and Arrays
4. Base with index mode
5. Relative mode
6. Additional addressing mode
• Registers are used s temporary storage locations where the da a in a register are accessed.
• For example, the instruction
Move R , R2 ;Copy content of register Rl into register R2.
Absolute (Direct) Mode
• The operand is in a memory-location.
• The address of memory-location is given explicitly in the instruction.
• The absolute mode can represent global variables in the program.
• For example, the instruction
Move LOC, R2 ;Copy content of memo y-location LOC into register R2.
Immediate Mode
• The operand is given explicitly in the instruction.
• For example, the instruction
Move #200, RO ; Place the value 200 in register R
• Clearly, the immediate mode is only used to specify the value of a source-operand.
• To execute the Add instruction in fig 2.11 (a), the processor uses the value which is in register Rl,
as the EA of the operand.
• It requests a read operation from the memory to read the contents of location B. The value read is the
VANDANA R
DD&CO
desired operand, which the processor adds to the contents of register RO.
• Indirect addressing through a memory-location is also possible as shown in fig 2.ll(b). In this
case, the processor first reads the contents of memory-location A, then requests a second read operation
using the value Bas an address to obtain the operand.
Program Explanation
• In above program, Register R2 is used as a pointer to the numbers in the list, and the operands
are accessed indirectly through R2.
• he initialization-section of the program loads the counter-value n from memory-location N into Rl
and uses the immediate address ng-mode to place the address value NUMl, which is the address of
the first number in the list, into R2. Then it clears RO to 0.
• The first two instructions in the loop implement the unspecified instruction block starting at LOOP.
The first time through the l oop, the instruction Add (R2), RO fetches the operand at location
NUMl and adds it to RO.
• 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
• A different kind of flexibility for accessing operands is useful in dealing with lists and arrays.
Index mode
• The operation is indicated as X(Ri)
where X=the constant value which defines an offset(also called a displacement).
Ri=the name of the index register which contains address of a new location.
• The effective-address of the operand is given by EA=X+[Ri]
• The contents of the index-register are not changed in the process of generating the
effective- address.
• The constant X may be given either
--+ as an explicit number or
--+ as a symbolic-name representing a numerical value.
VANDANA R
DD&CO
• Fig(a) illustrates two ways of using the Index mode. In fig(a), the index register, R1, contains the
address of a memory-location, and the value X defines an offset(also called a displacement) from this
address to the location where the operand is found.
• To find EA of operand: Eg:
Add 20(R1), R2
EA=>1000+20=1020
• 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.
Example
VANDANA R
DD&CO
• This added flexibility is useful in accessing multiple components inside each item in a record,
where the beginning of an item is specified by the (Ri, Rj) part of the addressing-mode. In other
words, this mode implements a 3-dimensional array.
RELATIVE MODE
• This is similar to index-mode with one difference:
The effective-address is determined using the PC in place of the general purposes register Ri.
• The operation is indicated as X(PC).
• X(PC) denotes an effective-address of the operand which is X locations above or below the cu
rent contents of PC.
• 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 o go to the branch target location
identified by name LOOP if branch condition is satisfied.
VANDANA R