[email protected] Stored Program A stored-program digital computer is one that keeps its...

24
[email protected] 1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read- write, random access memory (RAM). The idea of the stored-program computer changed all that. By creating an instruction set architecture and detailing the computation as a series of instructions (the program), the machine becomes much more flexible. By treating those instructions in the same way as data, a stored-program machine can easily change the program, and can do so under program control. Once in the computers memory a program will be executed one instruction at a time by repeatedly going through In the vast majority of modern computers, the same memory is used for both data and program instructions. This is known as the stored program concept or sometimes the Von Neumann principle.

Transcript of [email protected] Stored Program A stored-program digital computer is one that keeps its...

Page 1: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 1

Stored Program • A stored-program digital computer is one that keeps its

programmed instructions, as well as its data, in read-write, random access memory (RAM).

• The idea of the stored-program computer changed all that. • By creating an instruction set architecture and detailing the

computation as a series of instructions (the program), the machine becomes much more flexible.

• By treating those instructions in the same way as data, a stored-program machine can easily change the program, and can do so under program control.

• Once in the computers memory a program will be executed one instruction at a time by repeatedly going through

• In the vast majority of modern computers, the same memory is used for both data and program instructions.

• This is known as the stored program concept or sometimes the Von Neumann principle.

Page 2: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 2

Von Neumann Architecture• The von Neumann architecture is a

design model for a stored-program digital computer that uses a processing unit and a single separate storage structure to hold both instructions and data.

• Memory is used to store both program instructions and data

• Program instructions are coded data • A central processing unit (CPU) gets

instructions and/or data from memory, decodes the instructions and then sequentially performs them.

• A processor fetches instructions and data from a memory, operates on the data, and writes the results back into memory

• It is named after the mathematician and early computer scientist John von Neumann.

• Such computers implement a universal Turing machine and have a sequential architecture.

• .

Page 3: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 3

Von Neumann Components

• Input

• Output

• Memory

• ALU

• Control Unit

Page 4: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 4

CPUThe processor itself consists of 3 main components:

• Arithmetic-logic unit (ALU)in which all arithmetic and logic operations are carried out

• Control unitcoordinates the activities taking place in the CPU, memory and peripherals

• System clockgenerates clock pulses to step the control unit through its operation

Also

• Registersspecial storage locations to hold information temporarily

Page 5: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 5

System clock

• Electronic component • It generates electric signals at a fast speed• It controls all functions of computer using clock

ticks • These ticks of system clock are known as clock

cycle and speed of CPU• The speed at which the CPU executes

instructions is called clock speed or clock rate.• It generates a continuous sequence of clock

pulse to step the control unit through its operations

Page 6: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 6

Registers• Is a small high speed memory inside CPU.• Used to store temporary results • CPU contains the no of registers and has

a predefined functions• Register size determines how much

information it can store • The size of register is in bytes • A register can be one,two,four or eight

byte

Page 7: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 7

CPU Registers

Arithmetic logic unit

Program Counter(PC)

ControlUnit

Current Instruction

Register (CIR)

Memory Address Register (MAR)

Status Register (SR)

Memory Data Register(MDR)

R0

R1

R2

R3

R4

R5

External bus

Main Memory

The MDR is sometimes known as the memory buffer register (MBR)

General purpose registers

Page 8: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 8

Two internal registers

– Memory address register (MAR)• Specifies the address for the next read or write

– Memory buffer register (MBR)• Contains data written into memory or receives data

read from memory

– I/O address register– I/O buffer register

Page 9: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 9

Top-Level Components

Page 10: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 10

Processor Registers

• User-visible registers– Enable programmer to minimize main-

memory references by optimizing register use

• Control and status registers– Used by processor to control operating of the

processor– Used by privileged operating-system routines

to control the execution of programs

Page 11: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 11

User-Visible Registers

• Address Registers– Index

• Involves adding an index to a base value to get an address

– Segment pointer• When memory is divided into segments, memory is

referenced by a segment and an offset• e.g. CS,DS,ES

– Stack pointer• Points to top of stack• Order is Last in first Out (LIFO)• E.g. SP ,BP ,DI ,SI

Page 12: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 12

Control and Status Registers• Program Counter (PC)

– Contains the address of an instruction to be fetched• Instruction Register (IR)

– Contains the instruction most recently fetched• Program Status Word (PSW)

– Condition codes– Interrupt enable/disable– Supervisor/user mode

• Condition Codes or Flags– Bits set by the processor hardware as a result of operations– Examples

• Positive result• Negative result• Zero• Overflow

Page 13: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 13

Others Registers

1. General Purpose registers:• Available to the programmer and referenced in assembly

language programs• Performing arithmetic functions • Some computers there is one general purpose which is

accumulator2. Stack Pointer (SP): • Which points to a stack holding return addresses and is

accessed when an interrupt or break in sequential program

3. Current instruction register (CIR):• contain both the operator and operand of the current

instruction

Page 14: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 14

Working of Registers

There are several steps in the Fetch Execute cycle that are executed in order. The CPU goes through this cycle once for each instruction that is executed.

To start off the fetch cycle, the address which is stored in the program counter (PC) is transferred to the memory address register (MAR).

Page 15: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 15

Working of Registers

To finish the cycle, the newly fetched instruction is transferred to the instruction register (IR) and unless told otherwise, the CU increments the PC to point to the next address location in memory.

Page 16: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 16

Working of Registers

The CPU then transfers the instruction located at the address stored in the MAR to the memory buffer register (MBR) via the data lines connecting the CPU to memory.This transfer from memory to CPU is coordinated by the control unit (CU).

The CPU then transfers the instruction located at the address stored in the MAR to the memory buffer register (MBR) via the data lines connecting the CPU to memory.

Page 17: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 17

CU Operations

• Fetch : fetches the instruction from main memory

• Decode: translate the program instruction into commands that the computer can process

• Execution: control the execution of instruction

Page 18: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 18

Machine Cycle

• Fetch Instruction

• Decode Instruction

• Execute instruction

• Storing

Process of writing the result to the memory is called storing

Page 19: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 19

Control unit ALU

Registers

Instruction cycle in Processor

(1) Fetch

(2) Decode (3) Execute

(4) Store

Memory

I-time E-time

Page 20: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 20

How the CPU registers are used

• Fetch phase : • The address of next instruction

is copied from the PC to the MAR.

• The instruction held at that address is copied to the MDR

• The contents of the MDR are copied to the CIR

• Execute Phase :• The instruction held in the CIR

is decoded.• The instruction is executed.

Page 21: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 21

Fetch Execute Cycle

Start

Any instructions to execute?

Fetch next instruction

Decode instruction

Execute instruction

Any interrupts to

be processed?

Transfer control to interrupt handling program

Yes

No

Yes

No

Page 22: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 22

Parallel Processors

Parallel processing is the ability of a computer system to undertake more than one task simultaneously.

•Multiple processing elements in the system• Need parallel programming to fully exploit such architectures.

• To achieve highest efficiency, the program characteristics must match the underlying architecture.•Newer computers no longer use the von Neumann architecture

Page 23: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 23

Application of parallel processor

• Supercomputers utilizing parallel processing are used to maintain the safety.

• Scientists are using parallel processing to design computer-generated models of vehicles.

• Airlines use parallel processing to process customer information, forecast demand and decide what fares to charge.

• The medical community uses parallel processing supercomputers.

Page 24: Mazharjaved2001@yahoo.com1 Stored Program A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in read-write,

[email protected] 24

Advantages and disadvantages

• Advantages:– Memory is scalable with number of processors. Increase the

number of processors and the size of memory increases proportionately.

– Each processor can rapidly access its own memory without interference and without the overhead incurred with trying to maintain cache

– Cost effectiveness: can use commodity, off-the-shelf processors and networking

• Disadvantages:– The programmer is responsible for the details associated

with data communication. – It may be difficult to map existing data structures, based on

global memory, to this memory organization.