3 Elements Of ComputersEvery Computer contains the following components:-A processor able to interpret and execute programs.A memory for storing the programs and data they process.Input/Output equipment for transferring information between the computer and the outside world.
4 MAIN COMPONENTS OF MACHINE COMPUTATIONS Central Processing unitInstructionsMAIN MEMORYProgram ControlInput –OutputequipmentArithmetic LogicUnitdata
5 A computer has Several key components :- Main Memory corresponds to the paper used in the manual calculations. Its purpose is to store instructions and data.Computers brain is its Central Processing unit (CPU).It contains a Program Control Unit (also called as instruction unit) whose function is to fetch instructions from memory and interpret them.An Arithmetic Logic Unit(ALU) of Part CPU’s data-processing or execution unit, carries out the instructions.
6 NOTE:- ALU is so called because many instructions specify either arithmetic operations or various nonnumerical operations that corresponds to logical reasoning and decision making.
7 DIGITAL COMPUTERSDigital computer is a digital system that perform various computational tasks. The word “digital” implies that information in the computer is represented by variables that take a limited number of discrete values.These values are processed internally by components that can maintain a limited number of discrete states.DIGITAL COMPUTERS function more reliably if only two values states are used.It is not practical to build computers to handle symbolic or decimal data directly.Computers process data in binary form i.e, two symbols 0 and1 called bits (binary digits) .
8 “off ” implies ‘0’ and “on” implies ‘1’. Because of the fact that Computers are built from electric switches that have two natural states : “off ” and “on”.“off ” implies ‘0’ and “on” implies ‘1’.The internal language of computers comprises of group of bits such asTo provide communication between a computer and human users ,a means of translating information between human and machine (binary) formats is necessary.
9 COMPUTER ORGANIZAION :- Is concerned with the way the hardware components operate and the way they are connected together to form the computer system.Components assumed to be in place and task is to investigate the organizational structure to verify that the computer parts operate as intended.
10 COMPUTER ARCHITECTURE :- Is concerned with the structure and the behavior of the computer as seen by the user.It includes the information formats, instruction set (IO, Data transfer), and techniques for addressing memory.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.
11 Evolution of Computers Calculating machines capable of performing the elementary operations of arithmetic (Addition, subtraction, multiplication and division) appeared in 16th century.These were mechanical devices constructed from gears, levers etc.After that, various attempts were made to build general-purpose programmable computers from the same mechanical devices.
12 A mechanical computer has two serious drawbacks: Its computing speed is limited by the inertia of its moving parts.The transmission of digital information is quite unreliable.Now the development was the introduction of Electronic Computers in the mid-20th century.In an electronic computer the moving parts are electrons which can be transmitted and processed reliably.First electronic computer was ENIAC (Electronic Numerical Integrator and Calculator) stored their programs and data in separate memories.ENIAC had a set of electronic memory units called accumulators with a combined capacity of twenty 10-digit decimal numbers.Entering or altering the programs was a tedious task.
13 STORED PROGRAM CONCEPT Illustrates that the Idea of storing programs and data in same high-speed memory.Next EDVAC (Electronic Discrete variable Computer) – (Von Neumann Model) Stored program concept Besides facilitating the programming process, enables a program to modify its own instructions.It Stored and processed numbers in true binary form.It had two types of memory: fast main memory and slower secondary memory.It had defined Instruction format: A1 A2 A3 A4 OPTo minimize hardware costs, data was processed serially, or bit by bit.After that, A new stored-program electronic computer referred as IAS computer (Institute for Advanced Studies).
14 The General structure it had – A CPU for executing instructionsA main memory for storing active programsA secondary memory for backup storageMiscellaneous Input-Output equipments.The IAS machine processes all bits of a binary number simultaneously or in parallel.Earliest Computers had their instructions written in a binary code known as machine language.Improvement in machine language by allowing the operations and operand addresses to be expressed in symbolic format, referred to as assembly language.
15 IAS design have two key aspects: CPU contains a small set of high-speed storage devices called registers which serves as implicit storage locations for operands and results.A program’s instructions are stored in main memory in approximately the sequence in which they are executed. Hence, the address of the next instruction is usually that of the current instruction plus one.One of the two main parts of CPU is responsible for fetching instructions from memory and interpreting them, this part is known as program control unit (PCU) or I-unit (instruction unit).
16 Program control unit (PCU) Instruction decoder Control signals ……. AddressM(0)M(1)IRARM(2)M(3)IBRPCM(4)Data Processing unit DPUDRFjdhgdjhGkjfhjkjhArithmetic- Logic unitM(4,094)M(4,095)ACMQOrganization of CPU and main memory of IAS computer
17 PCU (Program Control Unit) Major components of PCU are: The second major part of the CPU is responsible for executing instructions and is known as data processing unit , the datapath, or the E-unit (execution unit).PCU (Program Control Unit)Major components of PCU are:Instruction register (IR), which stores the opcode that is currently being executed.Program counter (PC) which automatically stores and keeps track of the address of the next instruction to be fetched.Legend
18 PCU has circuits to interpret opcodes and to issue control signals to the DPU, main memory and other circuits involved in executing instructions.PCU can modify the instruction execution sequence when required to do so by branch instructions.PCU has 12-bit address register (AR) that holds the address of a data operand to be fetched from or sent to main memory.IAS has feature of fetching two instructions at a time from main memory, it contains a second register, the instruction buffer register (IBR) ,for holding a second instruction.
19 DPU (Data Processing Unit) Main components of DPU are the ALU, contains the circuits that perform addition, subtraction, multiplication etc. as required by opcodes.DPU contains the Data registers (DR) to store data words temporarily during program execution.IAS has two general-purpose 40-bit data registers :AC (Accumulator)Data register (DR)DPU contains a Special-purpose data register MQ (Multiplier-quotient) intended for use by multiply and divide instructions.
20 IAS fetches, decodes and executes the instruction in several steps that form an instruction cycle . IAS fetches two instructions in each instruction cycle. One instruction has its opcode placed in IR and its address field placed in AR.The other instruction is transferred to IBR register for possible later execution.Whenever the next instruction needed by the CPU is not in IBR, the program counter is incremented to generate the next instruction address.As the desired instruction has been loaded into CPU its execution phase begins.PCU decodes the instruction’s opcode.
21 The contents of the memory location specified by the address register AR are transferred to the data register DR.Contents of DR and the accumulator AC are executed via the DPU’s arithmetic-logic unit and the result is placed in AC.♣ PROGRAM COUNTER:¤ There is 1 register in the computer called the program counter or PC that keeps track of the instructions in the program stored in memory.¤ PC holds the address of the instructions to be executed next and is incremented each time an instruction is fetched from memory.¤ The decoding of the instruction is done in the next step tells which operation is to be performed, the addressing mode of the instruction, and the location of the operands.¤ The computer then executes the instruction and returns to the step1, i.e. to fetch the next instruction.
22 FLYNN’S CLASSIFICATION OF COMPUTERS A processor as CPU operates by fetching instructions and operands from memory executing the instructions and placing the final result in memory.The instructions from an instruction stream flowing from memory to processor while the operands from another stream data stream, flowing to and from the processor.The sequence of instructions read from memory constitutes an instruction stream.The operations performed on the data in the processor constitutes a data stream.InstructionProcessorPMemoryMStreamDataStream
23 Flynn has proposed a broad classification based on the number of simultaneous instruction streams and data streams seen by the processor during program execution.SISD (Single Instruction Stream, Single data stream)SIMD (Single Instruction Stream, Multiple data stream)MISD (Multiple Instruction Stream, Single data stream)MIMD (Multiple Instruction Stream, Multiple data stream)SISD represents the organization of a single computer containing a CU, a processor unit & a memory unit.SIMD represents an organization that includes many processing units under the supervision of a common control unit.MIMD refers to a computer system capable of processing several programs at the same time.
24 Classification of processors based on Instruction set (J.P. Hayes 194) The primary objective of processor designer is to improve performance.Performance is defined as the amount of work that the processor can do in a given period of time.Different instructions perform different amount of work.To increase performance ,either have the processor that execute many instructions in less time (inc. the clock speed of the processor) ,or make each instruction to execute more work (inc. the power & complexity of each instruction).
25 CISC stands for COMPLEX INSTRUCTION SET COMPUTER. CISC & RISCCISC stands for COMPLEX INSTRUCTION SET COMPUTER.RISC stand for REDUCE INSTRUCTION SET COMPUTER.RISC is the generic name given to processors that use a small number of simple instructions, to try to do less work with each instruction but execute them much faster.
26 RISC INSTRUCTIONSRISC processor is restricted to the use of LOAD & STORE instructions when communicating b/w memory & CPU.Most RISC instructions involve only register-to-register operations that are internal to CPU.
27 RISC CHARACTERISTICSSIMPLE INSTRUCTION SET:-The instruction set contains simple, basic instruction, from which more complex instructions can be composed.SAME LENGTH INSTRUCTIONS:- Each instruction is of the same length, so that it may be fetched in a single operation.1 MACHINE CYCLE INSTRUCTIONS:-Most instructions complete in one machine cycle, which allows the processor to handle several instructions at the same time.
28 ADVANTAGESSPEED:-RISC processors often achieve 2 to 4 times the performance of CISC processors.SIMPLER HARDWARE:- it uses much less chip space; extra functions like memory management unit or floating point arithmetic unit, can also be placed on same chip.Smaller chips allow a semiconductor mfg. to place more parts on a single silicon wafer, which can lower the per chip cost dramatically.SHORTER DESIGN CYCLE:-RISC processors are simpler than corresponding CISC processors, they can be designed more quickly.
29 RISC HAZARDSCODE QUALITY:-The performance of RISC processor depends on the code that it is executing. If the programmer or compiler does a poor job of instruction scheduling, the processor can spend quite a bit of time waiting for the result of one instruction before it can proceed with a subsequent instruction.DEBUGGING:- Instruction scheduling can make debugging difficult.CODE EXPANSION:-CISC machines perform complex action with a single instruction, whereas RISC machines may require multiple instructions for the same action, code expansion can be a problem.code expansion refer to the increase in size when the program is compiled for CISC machine & re-compiled for RISC machine. The exact expansion depend primarily on the quality of compiler and the nature of machine’s instruction set.
30 INSTRUCTION SET FORMATS (M.M. 255) A computer usually has a variety of Instruction Code Formats. It is the function of the control unit within the CPU to interpret each instruction code and provide the necessary control functions needed to process the instruction.The bits of the instruction are divided into groups called fields.The most common fields in instruction formats are:An Operation code field that specifies the operation to be performed.An Address field that designates a memory address or a processor register.A Mode field that specifies the way the operand or the effective address is determined.Instruction format with mode fieldOpcodeModeAddress
31 Types of Instruction Sets Data Transfer Instructions : Load, StoreArithmetic Instructions: Add, SubtractLogical Instructions: AND, ORProgram Control Instructions: Jump, Branch, BreakInput-Output Instructions: Instructions related to IO devices. e.g. Rewind, Print Line
32 Computers may have instructions of several different lengths containing varying number of addresses. The number of address fields in the instruction format of a computer depends on the internal organization of its registers.Most computers fall into one of 3 types of CPU organizations:1. Single accumulator organization:- All the operations are performed with an accumulator register. The instruction format in this type of computer uses one address field.For example: ADD Xwhere X is the address of the operands .2. General register organization:- The instruction format in this type of computer needs three register address fields.For example: ADD R1,R2,R3
33 Using Zero,one,two,or three address instructions. 3. Stack organizationFor example : ADDThe instruction in a stack computer consists of an operation code with no address field. This operation has the effect of popping the 2 top numbers from the stack, adding the numbers and pushing the sum into the stack.To illustrate the influence of the number of address on computer programs, we will evaluate the arithmetic statementX=(A+B)*(C+D)Using Zero,one,two,or three address instructions.
34 THREE-ADDRESS INSTRUCTIONS: Computers may have instructions of several different lengths containing varying number of addresses.THREE-ADDRESS INSTRUCTIONS:Computers with 3-address instruction formats can use each address field to specify either a processor register or a memory operand.For example: ADD R1, A, BADD R2, C, DMUL X, R1,R2ADVANTAGE: It results in short programs when evaluating arithmetic expressions.DISADVANTAGE: The instructions requires too many bits to specify 3 addresses.
35 2. TWO-ADDRESS INSTRUCTIONS: Two-address instructions are the most common in commercial computers.Here again each address field can specify either a processor register, or a memory word.For example: MOV R1,AADD R1,BMOV R2,CADD R2,DMUL R1,R2MOV X,R1The first symbol listed in an instruction is assumed to be both a source and the destination where the result of the operation is transformed.
36 3. ONE-ADDRESS INSTRUCTION: One-address instruction use an implied accumulator (AC) register for all data manipulation.For example: LOAD AADD BSTORE TLOAD CADD DMUL TSTORE XAll operations are done between the AC register and a memory operand.
37 4. ZERO-ADDRESS INSTRUCTIONS: A stack-organized computer does not use an address field for the instructions.The PUSH and POP instructions, need an address field to specify the operand that communicates with the stack.For example: PUSH APUSH BADDPUSH CPUSH DMULPOP XTo evaluate arithmetic expressions in a stack computer, it is necessary to convert the expression into reverse polish notation.The name “zero-address” is given to this type of computer because of the absence of an address field in the computational instructions.
38 Other computers use a single binary for operation & Address mode. THE ADDRESSING MODES: (M.M. Chapter -8)Specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually referenced.computers use addressing mode techniques for the purpose of accommodating the following purposes:-1.) To give programming versatility to the user by providing such facilities as pointers to memory, counters for loop control, indexing of data and various other purposes.2.) To reduce the number of bits in the addressing field of the instructions.Other computers use a single binary for operation & Address mode.The mode field is used to locate the operand.Address field may designate a memory address or a processor register.There are 2 modes that need no address field at all (Implied & immediate modes).
39 The most well known addressing mode then are: Implied mode.Immediate modeRegister modeRegister Indirect modeAuto-increment or Auto-decrement modeDirect ModeIndirect ModeRelative Address ModeIndex Addressing Mode
40 Although most addressing modes modify the address field of the instruction, there are two modes that need no address field at all:1.) Implied mode2.) Immediate mode.IMPLIED MODE:In this mode the operands are specified implicitly in the definition of the instruction.For example:-“complement accumulator” is an implied-mode instruction because the operand in the accumulator register is implied in the definition of the instruction. In fact, all register reference instructions that use an accumulator are implied-mode instructions.
41 Immediate mode:In this mode the operand is specified in the instruction itself. In other words, an immediate-mode instruction has an operand field rather than an address field.The operand field contains the actual operand to be used in conjunction with the operation specified in the instruction.It was mentioned previously that the address field of an instruction may specify either a memory word or a processor register. When the address field specifies a processor register, the instruction is said to be in register-mode.
42 Register direct mode:In this mode the operands are in registers that reside within the C.P.U.The particular register is selected from the register field in the instruction.A K-bit field can specify any one of 2k registers.Register indirect mode:In this mode the instruction specifies a register in the CPU whose contents give the address of the operand in the memory.In other words, the selected register contains the address of the operand rather than the operand itself.Before using a register indirect mode instruction, the programmer must ensure that the memory address of the operand is placed in the processor register with a previous instruction.Advantage:The address field of the instruction uses fewer bits to select a register than would have been required to specify a memory address directly.
43 Auto increment or Auto decrement: This is similar to register indirect mode except that the register is incremented or decremented after (or before) its value is used to access memory.When the address stored in the registers refers to a table of data in memory, it is necessary to increment or decrement the registers after every access to the table.This can be achieved by using the increment or decrement instruction. In some computers it is automatically accessed.The address field of an instruction is used by the control unit in the CPU to obtain the operands from memory.Sometimes the value given in the address field is the address of the operand, but sometimes it is the address from which the address has to be calculated.For that we need to know about the concept of ‘EFFECTIVE ADDRESS’.
44 Effective address:The effective address is defined to be the memory address obtained from the computation dictated by the given addressing mode.The effective address is the address of the operand in a computational-type instruction.DIRECT ADDRESS MODE:-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.
45 Effective address= address part of instruction+ INDIRECT ADDRESS MODEIn this mode the address field of the instruction gives the address where the effective address is stored in memory.Control unit fetches the instruction from the memory and uses its address part to access memory again to read the effective address.Some addressing modes requires the following to calculate the effective address:Effective address= address part of instruction+content of CPU register
46 Central Processing Unit Addressing modes Indirect Mode R1 and A are called “pointers”Add (R1),R0Add (A),R0MainmemoryBOperandABR1BRegisterBOperandRegister R1 contains Address BAddress A contains Address BAddress B has the operandAddress B has the operandEffective Address of the operand is the contents of a register ora memory location whose address appears in the instruction.
47 RELATIVE ADDRESS MODEIn this mode the content of the program counter is added to the address part of the instruction in order to obtain the effective address.The address part of the instruction is usually a signed number(either a +ve or a –ve number).When the number is added to the content of the program counter, the result produces an effective address whose position in memory is relative to the address of the next instruction.
48 INDEXED ADDERESSING MODE In this mode the content of an index register is added to the address part of the instruction to obtain the effective address.The index register is a special CPU register that contains an index value.NOTE:If an index-type instruction does not include an address field in its format, the instruction is automatically converted to the register indirect mode of operation.
49 BASE REGISTER ADDRESSING MODE In this mode the content of a base register is added to the address part of the instruction to obtain the effective address.This is similar to the indexed addressing mode except that the register is now called a base register instead of the index register.The base register addressing mode is used in computers to facilitate the relocation of programs in memory.When programs and data are moved from one segment of memory to another.
50 Central Processing Unit Addressing modes Numerical Example (M. M Central Processing Unit Addressing modes Numerical Example (M.M. 265) : Two word instruction at 200&201PC=200R1=400AddressMemoryXR=100AC200Load to AC Mode201Address=500202Next InstructionAddressing mode eff. Add Content of ACDirect AddressImmediate operandIndirect AddressRelative Address (PC=PC+2) 325Indexed Address (XR+500) 900RegisterRegister IndirectAuto-incrementAuto-decrement399450400700500800600900702325800300Tabular list
51 TYPES OF INTERRUPTIn a computer, having interrupt facility, when the input / output device is ready for the data transfer, it sends an interrupt signal to the computerIn the mean time, the computer may be busy with other tasks.After receiving the interrupt signal, the computer fulfills the request of I/O device.The interrupt enable flip-flop IEN can be set and cleared with 2 instructions (ION and IOF). When IEN is cleared to 0, the flags can not interrupt the computer. When IEN is set to 1, the computer can be interrupted.These 2 instructions provide the programmer with the capability of making a decision as to whether or not to use the interrupt facility.
52 TYPES OF INTERRUPTS: 3 major types are: External interruptsInternal interruptsSoftware interruptsExternal interrupts come from I/O devices, from a timing device, from a circuit monitoring the power supply, or from any other external source. For example: Timeout interruptInternal interrupts arise from illegal or erroneous use of an instruction or data. Internal interrupts are also called traps. For example, attempt to divide by zero.
53 The difference between internal interrupt and external interrupt is that the internal interrupt is initiated by some exceptional condition caused by program itself rather than by an external event. External interrupts depend on external conditions that are independent of the program.SOFTWARE INTERRUPT: A software interrupt is initiated by executing an instruction. Software interrupt is a special call instruction that behaves like an interrupt rather than a subroutine call. The most common use of a software interrupt is associated with a supervisor call instruction. This instruction provides means for switching from a CPU user mode to the supervisor mode.
54 PROGRAMMED I/O, DMA & INTERRUPTS These all are modes of transfer.Data transfer between the central computer and the I/O devices may be handled in a variety of modes.The modes are:Programmed I/O.Interrupt-initiated I/ODirect memory access (DMA)