Model Computer Input/ Output Unit Memory Unit Control Unit Arithmetic Logic Unit Data Bus CPU.

Post on 17-Jan-2016

225 views 0 download

Tags:

Transcript of Model Computer Input/ Output Unit Memory Unit Control Unit Arithmetic Logic Unit Data Bus CPU.

Model ComputerModel Computer

Input/Output

Unit

MemoryUnit

ControlUnit

ArithmeticLogicUnit

Data Bus

CPU

Control UnitControl Unit

Input/Output

Unit

MemoryUnit

ArithmeticLogicUnit

IR

InstructionDecoder

PC

MAR

Memory UnitMemory Unit

Input/Output

Unit

ControlUnit

ArithmeticLogicUnit

MAR

MDR

Address Decoder

MainStore

Arithmetic/Logic UnitArithmetic/Logic Unit

Input/Output

Unit

MainMemory

ControlUnit

ACCSR

Model ComputerModel Computer

ACCSRMDR

Address Decoder

IR

InstructionDecoder

PC

MAR

RegistersRegisters

A register is a single storage unit where data is stored temporary for a special purpose

MAR holds the address of the memory location to be accessed

MDR holds the data item read from or written to the specified memory location

RegistersRegisters

PC holds the address of the next instruction to be fetched from the main store

IR holds the current instruction fetched from the main store while it is being decoded

RegistersRegisters

ACC holds the data item to be processed or the results of the most recent operations in the ALU

SR holds a set of condition flags which describe the status of the most recent operation carried out by the ALU

Programming the CPUProgramming the CPU

00001 : Load the contents in memory location 11111 into the accumulator

00010 : Store the contents in the accumulator in the memory location 11101

Fetch CycleFetch Cycle

0011111101011110

00001

00001

1

01000001

PC is set to 00001 initiallyMAR is loaded with 00001

Fetch CycleFetch Cycle

0011111101011110

00001

00001

1

2

01000001

Address decoder selectsthe memory location 00001

Fetch CycleFetch Cycle

0011111101011110

00001

00001

00111111

1

2

301000001

The instruction in location 00001 is loaded into MDR

Fetch CycleFetch Cycle

0011111101011110

00001

00001

0011111100111111

1

2

3

4

01000001

The instruction is then copied to IR

Execution CycleExecution Cycle

0011111101011110

00010

0011111101000001

5

LDA 00001

PC is set to 00010The instruction is decoded

Execution CycleExecution Cycle

0011111101011110

00010

11111

0011111101000001

5 6

LDA

MAR is set to 11111

Execution CycleExecution Cycle

0011111101011110

00010

11111

0011111101000001

5 6

7

LDA

The address decoder selects the location 11111

Execution CycleExecution Cycle

0011111101011110

00010

11111

0011111101000001

01000001

5 6

7

8

LDA

The data in location 11111 is loaded into MDR

Execution CycleExecution Cycle

0011111101011110

00010

11111

0011111101000001

01000001

5 6

7

8

LDA

01000001

9

The data is then copied to ACC

Fetch CycleFetch Cycle

0011111101011110

00010

00010

1

0100000101000001

Fetch CycleFetch Cycle

0011111101011110

00010

00010

1

2

0100000101000001

Fetch CycleFetch Cycle

0011111101011110

00010

00010

01011110

1

2

3

0100000101000001

Fetch CycleFetch Cycle

0011111101011110

00010

00010

0101111001011110

1

2

3

4

0100000101000001

Execution CycleExecution Cycle

0011111101011110

00011

00010

0011111001000001

5

STA

0011111001000001

Execution CycleExecution Cycle

0011111101011110

00011

11110

0011111001000001

00111110

5 6

STA

01000001

Execution CycleExecution Cycle

0011111101011110

00011

11110

0011111001000001

0100000101000001

5 6

STA

PC

MAR 7

Execution CycleExecution Cycle

0011111101011110

00011

11110

0011111001000001

0100000101000001

5 6

7

8

STA

Execution CycleExecution Cycle

0011111101011110

00011

11110

0011111001000001

0100000101000001

5 6

8

9

7

STA

01000001

SMC Instruction SetSMC Instruction SetLDA load accumulator with memory

STA store accumulator in memory

ADD add memory to accumulator

SUB subtract memory from accumulator

DEC decrement memory by 1

JMP unconditional jump

BNE branch if negative

STP stop

SMC Instruction SetSMC Instruction SetLDA LoaD Accumulator with memory

STA STore Accumulator in memory

ADD ADD memory to accumulator

SUB SUBtract memory from accumulator

DEC DECrement memory by 1

JMP unconditional JuMP

BNE Branch if NEgative

STP SToP

Fetch/Execution CycleFetch/Execution Cycle Address in PC is sent to MAR Address decoder interpret the address in MA

R and locate the specified memory location Control signal ( read ) is issued Contents in specified location are deposited

into MDR Contents is then sent to IR Execute the instruction held in IR

Example program #1Example program #1

00001 LDA 11111

00010 ADD 11110

00011 STA 11101

00100 STP

1

2

3

4

Address Instruction

Example program #2Example program #2

00001 LDA 11111

00010 SUB 11110

00011 BNE 00110

00100 LDA 11111

00101 JMP 00111

00110 LDA 11110

00111 STA 11101

01000 STP

1

2

3

4

5

6

7

8

Address Instruction