Intro to cao &store program

54
4 th SEM(CSE) COMPUTER ARCHITECTURE AND ORGANIZATION - M. MORRIS MANO - J.P. Hayes

description

introduction of cao

Transcript of Intro to cao &store program

Page 1: Intro to cao &store program

4th SEM(CSE)COMPUTER ARCHITECTURE

AND ORGANIZATION

- M. MORRIS MANO

- J.P. Hayes

Page 2: Intro to cao &store program

UNIT-IGeneral System

Architecture

Page 3: Intro to cao &store program

Elements Of Computers

Every 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.

Page 4: Intro to cao &store program

Central Processing

unit

Program Control

Arithmetic Logic Unit

MAIN MEMORY

Input –Output

equipment

Instructions

data

MAIN COMPONENTS OF MACHINE COMPUTATIONS

Page 5: Intro to cao &store program

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).

o It contains a Program Control Unit (also called as instruction unit) whose function is to fetch instructions from memory and interpret them.

o An Arithmetic Logic Unit(ALU) of Part CPU’s data-processing or execution unit, carries out the instructions.

Page 6: Intro to cao &store program

NOTE:- ALU is so called because many instructions specify either arithmetic operations or various nonnumerical operations that corresponds to logical reasoning and decision making.

Page 7: Intro to cao &store program

DIGITAL COMPUTERS Digital 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) .

Page 8: Intro to cao &store program

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 as 10010011 11011001.

To provide communication between a computer and human users ,a means of translating information between human and machine (binary) formats is necessary.

Page 9: Intro to cao &store program

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.

Page 10: Intro to cao &store program

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.

Page 11: Intro to cao &store program

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.

Page 12: Intro to cao &store program

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.

Page 13: Intro to cao &store program

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 OP

To 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).

Page 14: Intro to cao &store program

The General structure it had –

A CPU for executing instructions

A main memory for storing active programs

A secondary memory for backup storage

Miscellaneous 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.

Page 15: Intro to cao &store program

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).

Page 16: Intro to cao &store program

Instruction decoder …….

Control signals

Program control unit (PCU)

ARIR

IBR PC

DR

Arithmetic- Logic unit

AC MQ

Data Processing unit DPU

Address

0 1 2 3 4

4094 4095

M(2)M(1)M(0)

M(3)M(4)

M(4,094)M(4,095)

Organization of CPU and main memory of IAS computer

Page 17: Intro to cao &store program

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:

o Instruction register (IR), which stores the opcode that is currently being executed.

o Program counter (PC) which automatically stores and keeps track of the address of the next instruction to be fetched.

Page 18: Intro to cao &store program

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.

Page 19: Intro to cao &store program

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 :

o AC (Accumulator)

o Data register (DR)

DPU contains a Special-purpose data register MQ (Multiplier-quotient) intended for use by multiply and divide instructions.

Page 20: Intro to cao &store program

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.

Page 21: Intro to cao &store program

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.

Page 22: Intro to cao &store program

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.

Memory

M

Processor

P

Instruction

Stream

Stream

Data

Page 23: Intro to cao &store program

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.

Page 24: Intro to cao &store program

Classification of processors based on Instruction set (J.P. Hayes 194)

The primary objective of processor designer is to The primary objective of processor designer is to improve performance.improve performance.

Performance is defined as the amount of work that Performance is defined as the amount of work that the processor can do in a given period of time.the processor can do in a given period of time.

Different instructions perform different amount of Different instructions perform different amount of work.work.

To increase performance ,either have the processor To increase performance ,either have the processor that execute many instructions in less time (inc. the that execute many instructions in less time (inc. the clock speed of the processor) ,or make each clock speed of the processor) ,or make each instruction to execute more work (inc. the power & instruction to execute more work (inc. the power & complexity of each instruction).complexity of each instruction).

Page 25: Intro to cao &store program

CISC & RISC CISC & RISC

CISC stands for COMPLEX INSTRUCTION CISC stands for COMPLEX INSTRUCTION SET COMPUTER.SET COMPUTER.

RISC stand for REDUCE INSTRUCTION RISC stand for REDUCE INSTRUCTION SET COMPUTER. SET COMPUTER.

RISC is the generic name given to RISC is the generic name given to processors that use a small number of simple processors that use a small number of simple instructions, to try to do less work with each instructions, to try to do less work with each instruction but execute them much faster.instruction but execute them much faster.

Page 26: Intro to cao &store program

RISC INSTRUCTIONSRISC INSTRUCTIONS

RISC processor is restricted to the use of RISC processor is restricted to the use of LOAD & STORE instructions when LOAD & STORE instructions when communicating b/w memory & CPU.communicating b/w memory & CPU.

Most RISC instructions involve only register-Most RISC instructions involve only register-to-register operations that are internal to to-register operations that are internal to CPU.CPU.

Page 27: Intro to cao &store program

RISC CHARACTERISTICSRISC CHARACTERISTICS

SIMPLE INSTRUCTION SETSIMPLE INSTRUCTION SET:-The instruction set :-The instruction set contains simple, basic instruction, from which contains simple, basic instruction, from which more complex instructions can be composed.more complex instructions can be composed.

SAME LENGTH INSTRUCTIONSSAME LENGTH INSTRUCTIONS:- Each instruction is of :- Each instruction is of the same length, so that it may be fetched in the same length, so that it may be fetched in a single operation.a single operation.

1 MACHINE CYCLE INSTRUCTIONS1 MACHINE CYCLE INSTRUCTIONS:-Most instructions :-Most instructions complete in one machine cycle, which allows complete in one machine cycle, which allows the processor to handle several instructions the processor to handle several instructions at the same time.at the same time.

Page 28: Intro to cao &store program

ADVANTAGESADVANTAGES

SPEEDSPEED:-RISC processors often achieve 2 to 4 times the :-RISC processors often achieve 2 to 4 times the performance of CISC processors.performance of CISC processors.

SIMPLER HARDWARESIMPLER HARDWARE:- it uses much less chip space; :- it uses much less chip space; extra functions like memory management unit or floating extra functions like memory management unit or floating point arithmetic unit, can also be placed on same chip.point arithmetic unit, can also be placed on same chip.

Smaller chips allow a semiconductor mfg. to place more Smaller chips allow a semiconductor mfg. to place more parts on a single silicon wafer, which can lower the per parts on a single silicon wafer, which can lower the per chip cost dramatically.chip cost dramatically.

SHORTER DESIGN CYCLESHORTER DESIGN CYCLE:-RISC processors are simpler :-RISC processors are simpler than corresponding CISC processors, they can be than corresponding CISC processors, they can be designed more quickly.designed more quickly.

Page 29: Intro to cao &store program

RISC HAZARDSRISC HAZARDS

CODE QUALITYCODE QUALITY:-The performance of RISC processor depends :-The performance of RISC processor depends on the code that it is executing. If the programmer or compiler on the code that it is executing. If the programmer or compiler does a poor job of instruction scheduling, the processor can does a poor job of instruction scheduling, the processor can spend quite a bit of time waiting for the result of one instruction spend quite a bit of time waiting for the result of one instruction before it can proceed with a subsequent instruction.before it can proceed with a subsequent instruction.

DEBUGGINGDEBUGGING:- Instruction scheduling can make debugging :- Instruction scheduling can make debugging difficult.difficult.

CODE EXPANSIONCODE EXPANSION:-CISC machines perform complex action :-CISC machines perform complex action with a single instruction, whereas RISC machines may require with a single instruction, whereas RISC machines may require multiple instructions for the same action, code expansion can be multiple instructions for the same action, code expansion can be a problem.a problem.

code expansion refer to the increase in size when the program is code expansion refer to the increase in size when the program is compiled for CISC machine & re-compiled for RISC machine. compiled for CISC machine & re-compiled for RISC machine. The exact expansion depend primarily on the quality of compiler The exact expansion depend primarily on the quality of compiler and the nature of machine’s instruction set.and the nature of machine’s instruction set.

Page 30: Intro to cao &store program

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:

1. An Operation code field that specifies the operation to be performed.

2. An Address field that designates a memory address or a processor register.

3. A Mode field that specifies the way the operand or the effective address is determined.

Instruction format with mode field

AddressModeOpcode

Page 31: Intro to cao &store program

Types of Instruction Sets

Data Transfer Instructions : Load, Store Arithmetic Instructions: Add, Subtract Logical Instructions: AND, OR Program Control Instructions: Jump, Branch,

Break Input-Output Instructions: Instructions related

to IO devices. e.g. Rewind, Print Line

Page 32: Intro to cao &store program

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

Page 33: Intro to cao &store program

3. Stack organization For example : ADD

The 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 statement

X=(A+B)*(C+D) Using Zero,one,two,or three address instructions.

Page 34: Intro to cao &store program

Computers may have instructions of several different lengths containing varying number of addresses.

1. 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, B ADD R2, C, D MUL X, R1,R2

ADVANTAGE: It results in short programs when evaluating arithmetic expressions.

DISADVANTAGE: The instructions requires too many bits to specify 3 addresses.

Page 35: Intro to cao &store program

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,A ADD R1,B MOV R2,C ADD R2,D MUL R1,R2 MOV X,R1

The first symbol listed in an instruction is assumed to be both a source and the destination where the result of the operation is transformed.

Page 36: Intro to cao &store program

3. ONE-ADDRESS INSTRUCTION:

One-address instruction use an implied accumulator (AC) register for all data manipulation.

For example: LOAD A

ADD B

STORE T

LOAD C

ADD D

MUL T

STORE X All operations are done between the AC register and a memory

operand.

Page 37: Intro to cao &store program

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 A

PUSH B ADD

PUSH C PUSH D

ADD MUL POP X

To 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.

---------------------------------------------------------------------

Page 38: Intro to cao &store program

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).

Page 39: Intro to cao &store program

The most well known addressing mode then are: Implied mode. Immediate mode Register mode Register Indirect mode Auto-increment or Auto-decrement mode Direct Mode Indirect Mode Relative Address Mode Index Addressing Mode

Page 40: Intro to cao &store program

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.

Page 41: Intro to cao &store program

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.

Page 42: Intro to cao &store program

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.

Page 43: Intro to cao &store program

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’.

Page 44: Intro to cao &store program

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.

Page 45: Intro to cao &store program

INDIRECT ADDRESS MODE

In 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

Page 46: Intro to cao &store program

Central Processing UnitAddressing modes Indirect Mode

Effective Address of the operand is the contents of a register or a memory location whose address appears in the instruction.

R1

Add (R1),R0 Add (A),R0

RegisterB B Operand

memoryMain

A BOperandB

•Register R1 contains Address B•Address B has the operand

•Address A contains Address B•Address B has the operand

R1 and A are called “pointers”

Page 47: Intro to cao &store program

RELATIVE ADDRESS MODE

In 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.

Page 48: Intro to cao &store program

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.

Page 49: Intro to cao &store program

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.

Page 50: Intro to cao &store program

Central Processing UnitAddressing modesNumerical Example (M.M. 265) : Two word instruction at 200&201

Address=500Next Instruction

450700

800

900

325

300

Load to AC Mode

Memory

500

Address

201202

399400

702

600

200

800

PC=200 R1=400

XR=100 AC

Addressing mode eff. Add Content of AC-----------------------------------------------------------Direct Address 500 800Immediate operand 201 500Indirect Address 800 300Relative Address 702 (PC=PC+2) 325Indexed Address 600 (XR+500) 900Register --- 400Register Indirect 400 700Auto-increment 400 700Auto-decrement 399 450

Tabular list

Page 51: Intro to cao &store program

TYPES OF INTERRUPT

In a computer, having interrupt facility, when the input / output device is ready for the data transfer, it sends an interrupt signal to the computer

In 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.

Page 52: Intro to cao &store program

TYPES OF INTERRUPTS: 3 major types are:1. External interrupts2. Internal interrupts3. Software interrupts

External 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 interrupt

Internal 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.

Page 53: Intro to cao &store program

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.

Page 54: Intro to cao &store program

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:1. Programmed I/O.2. Interrupt-initiated I/O3. Direct memory access (DMA)