The working of the CPU can be explained in the following four sections
1)Function of the CPU
The working of CPU on a smaller basis can be compare to that of a calculator, but the CPU much more powerful that that of the calculator. The primary functons that a CPU perorms are the arithmetic and logical operations on any data, which may be taken either from the memory or the data can also be any information which is entered by the use through some input devices like a keyboard, scanner, or joystick.
A computer program is nothing but a list of software instructions which are controlled by the CPU. Usually any kind of software instructions that enters the CPU, will originate in some form of memory storage device like that of a hard disk, floppy disk, CD-ROM, or magnetic tape.
After this step these instructions are then passed into the computer’s memory called as the random access memory (RAM).In the RAM,a memory location or a uniques address is usually given to the each instruction . This unique address is specified so that the CPU can access the required data in the RAM by jusst specifying the address of the data that is required by the CPU.
Now let us consider the next step of executing the program and whn it is executed,the data flow is from the RAM through the bus,which is an interface unit of wires and it connects the CPU and the RAM. Then the data are decoded by a processing which is called as "instruction decoder".The function of the instruction decoder is that it interprets and implements software instructions.
The data from the instruction decoder is then passed to the arithmetic/logic unit (ALU).The function of the ALU is that it performs calculations and comparisons.In the ALU the data may be stored temprorily in the temporary memory locations called as the registers so that it could be retrieved quickly.
Apart from this the ALU also performs operations like addition, multiplication, and conditional tests on the data and it is usually performed in its registers,and after that it sends the resulting data back to the RAM or it is stored in another register for any future use.During this process,a unit called "Program Counter" is mainly used to keep track of each successive instruction so as to ensure that the program instructions are followed by the CPU in a correct sequence.
2)Branching instructions
Usually the program counter present in the CPU advances sequentially through the instructions, i.e one istructions after other. But this is not the case always because some special instructions like branch or jump instructions are used and these allow the CPU to abruptly shift to an instruction location out of sequence.
Normally these branch instructions may be either conditional or unconditional.When we consider a conditional, it usually tests the result of a previous operation so as to check whether the branch should be taken or not.Consider for example,a branch should be taken only if the result of a previous subtraction produces a negative result.
Usually the data which are tested for conditional branching are stored Flags, which is a special locations in the. But in the case of unconditional branch, it always jumps to a new,and this is not in order and it is generally in out of order instruction stream.
3)Clock Pulses
The measure of the speed of a processoris called as the clock pulse.Usually, the CPU is driven by one or more repetitive clock circuits and these circuits send a constant stream of pulses throughout the CPU’s circuitry.With the help of these clock pulses, the CPU synchronize its operations.Any smallest increments of CPU work are completed between the sequential clock pulses.
But in the case of any complex task several clock periods are required to be completed.Generally the clock pulses are
measured in number of pulses per second or Hertz. For example,consider a 2-gigahertz processor.This processor has 2 billion clock pulses which passes through it in one second.
4)Numbers handled by the CPU
Generally most of the CPUs handle two different kinds of numbers, and these includes
i)Fixed-point numbers and
ii)Floating-point numbers.
In the case of the fixed-point numbers,on either side of the decimal point it has a specific number of digits and this
restriction limits the range of values which are possible for these numbers, but it also ensures the faster arithmetic
operation is perormed.
Floating-point numbers usually expressed in a scientific notation,where a number is represented as a decimal number which is multiplied by a power of ten. The reason why we use scientific notation is that it is a compact way for expressing very large or very small numbers and apart from this it also allows a wide range of digits before and after the decimal point.
This is very useful and essential for representing any graphics or scientific work.But one disadvantage of this floating-point arithmetic is that it is more complex and it usually takes a longer to complete and as a result we require many CPU clock periods for performing any operations.
So this naturally makes the CPU’s floating-point computation rate lesser than its clock rate.In some case, computers use a special floating-point processor,which is called as the coprocessor,and it works in parallel to the CPU so that it can increase the speed of the calculations using floating-point numbers.In many PCs, such as Intel's chip, this coprocessor has becomes standard one.