Basic Structure of Computer: 1.2. Functional Unit
Basic Structure of Computer: 1.2. Functional Unit
A computer consists of five functionally independent main parts input, memory, arithmetic logic unit (ALU), output
Input Output & Control units.
Input unit
Input device accepts the source program/high level language program/coded information/simply data is fed to a
computer through input devices keyboard is a most common type. Whenever a key is pressed, one corresponding
word or number is translated into its equivalent binary code over a cable & fed either to memory or processor.
Joysticks, trackballs, mouse, scanners etc are other input devices.
Output unit: Its basic function is to send the processed results to the outside world.
Examples : Printer, speakers, monitor etc.
Control unit
It is the nerve center that sends signals to other units and senses their states. The timing signals transfer of data
between input unit, processor, memory and output unit are generated by the control unit.
the compiler, machine instruction set and hardware in a co-ordinated way.The processor time depends on the
hardware involved in the execution of individual machine instructions. This hardware comprises the processor and
the memory which are usually connected by the bus as shown in the fig 4.
Let us examine the flow of program instructions and data between the memory and the processor. At the start
of execution, all program instructions and the required data are stored in the main memory. As the execution
proceeds, instructions are fetched one by one over the bus into the processor, and a copy is placed in the cache later
if the same instruction or data item is needed a second time, it is read directly from the cache.
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.
Let P = Length of one clock cycle,R = Clock rate. Relation between P and R is given by
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 T will be reduced by same factor as R is increased „.‟ S & N are not affected.
Instruction set CISC & RISC
SPEC rating = 50: The computer under test is 50 times as fast as reference-computer. The test is repeated for all the
programs in the SPEC suite.Then, the geometric mean of the results is computed.
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
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)/1X109 =(1000+2000+1050)/1*109= 4.05 μs.
Problem 5:
For the following processor, obtain the performance.
Clock rate = 800 MHz
No. of instructions executed = 1000
Average no of steps needed / machine instruction = 20
Solution:
Problem 7:
(a) Suppose that execution time for a program is proportional to instruction fetch time. Assume that
fetching an instruction from the cache takes 1 time unit, but fetching it from the main-memory takes
10 time units. Also, assume that a requested instruction is found in the cache with probability 0.96.
Finally, assume that if an instruction is not found in the cache it must first be fetched from the mainmemory
into the cache and then fetched from the cache to be executed. Compute the ratio of program
execution time without the cache to program execution time with the cache. This ratio is called the
speedup resulting from the presence of the cache.
(b) If the size of the cache is doubled, assume that the probability of not finding a requested
instruction there is cut in half. Repeat part (a) for a doubled cache size.
Solution:
(a) Let cache access time be 1 and main-memory access time be 20. Every instruction that is
executed must be fetched from the cache, and an additional fetch from the main-memory must
be performed for 4% of these cache accesses.
Therefore,
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.
• For example,
If the word length is 16(2 bytes), aligned words begin at byte-addresses 0, 2, 4 . . . . .
If the word length is 64(2 bytes), aligned words begin at byte-addresses 0, 8, 16 . . . . .
• Words are said to have Unaligned Addresses, if they begin at an arbitrary byte-address.
Accessing Numbers, Characters and Character Strings
A number usually occupies one word. It can be accessed in the memory by specifying its word address. Similarly,
individual characters can be accessed by their byte-address.
• There are two ways to indicate the length of the string:
1) A special control character with the meaning "end of string" can be used as the last character in the string.
2) A separate memory word location or register can contain a number indicating the length of the string in bytes.
1.12 MEMORY OPERATIONS
Both program instructions and data operands are stored in the memory. To execute an instruction, the processor
control circuits that word (or words) containing the instruction to be transferred from the memory to the processor.
Operands and results must also be moved between the memory and the processor. Thus, two basic operations involving
This type of notation is known as Register Transfer Notation (RTN). Note that the right- hand side of an RTN
expression always denotes a value, and the left-hand side is the name of a location where the value is to be places,
overwriting the old contents of that location.
Basic Instructions
The operation of adding two numbers is a fundamental capability in any computer. The statement
C=A+B
When the program containing this statement is compiled, the three variables, A, B, and C, are assigned to distinct
locations in the memory. We will use the variable names to refer to the corresponding memory location addresses. The
contents of these locations represent the values of the three variables.
Access to data in the registers is much faster than to data stored in memory-locations.
Access to data in the registers is much faster than to data stored in memory-locations.
• Let Ri represent a general-purpose register. 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 registers, the task
C<-[A]+[B] can be performed by the instruction sequence:
Move A,Ri
Move B,Rj
Add Ri,Rj
Move Rj,C
Fig7 C= [A]+[B]
1.4.5. Branching
Consider the task of adding a list of n numbers. Instead of using a long list of add instructions, it is possible to place a
single add instruction in a program loop, as shown in fig 8.
Program Explanation
• Consider the program for adding a list of n numbers (Figure 8).
• 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.