Download presentation

Presentation is loading. Please wait.

Published byHamza Core Modified over 2 years ago

1
Toward a general purpose computer Example: Game of Life

2
Game of Life For Each Line For Each Cell Solve Cell

3
Game of Life For Each Line For Each Cell Solve Cell Generation LineCell Matrix

4
Modularity Generation Module Matrix Module Line Module Cell Module

5
Algorithm for the Generation Module 1. CurrentGen = 0 2. Solve for current Matrix 3. CurrentGen++ 4. If CurrentGen < MAX_GEN goto 2

6
Solve Matrix 0. j = 1 1. Calculate line (j) 2. If j < MAX_LINE 2.1 j++ 2.2 goto 1. 3. STOP

7
Calculate Line j 0. i = 0, tmp = 0 1. Calculate Cell i. 2. If alive, set location i in tmp to alive 3. If i < MAX_CELL 3.1 i++ 3.2 goto 1. 4. Store tmp in : even generation: i+16 odd generation : i-16

8
CellAlive(cell index i, line index j) 0. N = Count_Neighbors(i,j-1,false) 1. N = N+Count_Neighbors(i,j,true) 2. N = N+Count_Neighbors(i,j+1,false) 3. If N > MIN && N < MAX 3.1 Return alive 4. Return dead

9
Count_Neighbors (index i,line j, center) 0. N = 0 1. If alive in location [i-1,j]: N=N+1 2. If not center: 2.1 If alive in location [i,j]: N=N+1 3. If alive in location [i+1,j]: N=N+1 4. Return N

10
Algorithm implementation Algorithm How to do?What to do? The operation itselfcontrol

11
The operations in the algorithm: Operations: Add Subtract

12
The operation: Defining interfaces CountNeighbors CellAlive Calculate Line Solve Matrix Generation Return Number of Neighbor: N Alive: 0..010..0 Dead: 0000000 (i-1) location Return the line The matrix Return The Operation itself

13
The operation: Module Calculate Line, instruction 2 If alive If dead Calculate_Line(j) = 0000000 OR tmp = 00000000 Result = 000000000 Calculate_Line(j) = 0001000 OR tmp = 00000000 Result = 000100000 The j-th location If alive, set location i in tmp to alive The Operation itself

14
The operation: Module Calculate Line, instruction 2 If alive, set location i in tmp to alive tmp = OR(tmp,Calculate_Line(j)) The Operation itself

15
The operations in the algorithm: Operations: Add Subtract OR The Operation itself

16
Implementing instructions Module Count_Neighbors, instruction 1, 2.1, 3 decode(i-1) = 0001000 AND Line (j) = 00010100 Result = 00010000 decode(i-1) = 0001000 AND Line (j) = 00000100 Result = 00000000 Zero – cell in location i is dead Non Zero – cell in location i is alive If alive in location [i-1,j] The Operation itself

17
Implementing instructions Module Count_Neighbors, instruction 1, 2.1, 3 Alive if AND(line,decode(i-1)) is not zero If alive in location [i-1,j] The Operation itself

18
The operations in the algorithm: Operations: Add Subtract The logic AND + Check if zero The Operation itself

19
Small ALU (arithmetic logic unit) Op selector MeaningResult 00AddRes = InputA+InputB 01SubractRes = InputA+ NOT(InputB)+1 10ANDRes = AND(InputA,InputB) 11DecodeRes = decode(InputA) The Operation itself

20
Small ALU Status Bit The Operation itself

21
Small ALU Status Bit The Operation itself ALU isZero Op InputB InputA

22
Variables of the algorithm Count_Neighbors Line j – The current line i - The index we are processing N - The number of Neighbors so far tmp - temporary processing space

23
Implementation of AND(line,decode(i+1)) Reg1 Reg2 Reg3 Regn

24
Implementation of AND(line,decode(i+1)) Reg1 Reg2 Reg3 Regn ReadA ReadB 1 2 Connected like MUX 1

25
Implementation of AND(line,decode(i+1)) Reg1 Reg2 Reg3 Regn ReadA ReadB 1 2 Decoder Enable Write Write Address Write Data

26
Implementation of AND(line,decode(i+1)) Registers Data 1 Data 2 Data 1 Address Data 2 Address WriteAddress Write Data Write

27
Variables of the algorithm Count_Neighbors VariableMeaningAddress CurrentLineHold the current line 0 IThe current index1 NThe Neighbor2 TmpTemporary space3 Constant 1 5 ControlVariableA flag to determine if the operation should be performed 6 CenterIs it the center7

28
In generation 0 0 15 16 32 1 17 Current Generation Matrix, gen=0 Next generation Matrix I I+16

29
In generation 1 0 15 16 32 1 17 Current Generation Matrix,gen=1 Next generation Matrix I+16 I

30
Variables of the algorithm Count_Neighbors VariableMeaningAddress CurrentLineHold the current line 0 IThe current index1 NThe Neighbor2 TmpTemporary space3 Constant 1 5 ControlVariableA flag to determine if the operation should be performed 6 CenterIs it the center7

31
Register/ALU circuit Registers Data 1 Address Data 2 Address WriteAddress Write ALU Op Extend 1 to 16 MUX R0R1 External Input 0 1 2

32
Control Algorithm is zero[AND(line,decode(i+1))] If alive in location [i+1,j]: N=N+1 Algorithm instruction Instruction a.Tmp = is zero[AND(Currentline, decode(i+1))] b.If controlVariable=0000001: N=N+1 The Operation itself

33
Control Algorithm is zero[AND(line,decode(i-1))] Tmp = is zero[AND(line,decode(i-1))] Instruction The Operation itself t0. Tmp = i-1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] Micro-Instruction

34
Micro instruction implementation t0. Data 1 Address = 1 Data 2 Address = 5 WriteAddress = 3 Write = 1 Op = 01 R0R1 = 01 Micro-Instruction The Operation itself a.Tmp = i+1 b.Tmp = decode(Tmp) c.controlVariable = is zero[AND(CurrentLine, Tmp)] Subtract i 1 tmp The result of the ALU

35
Micro instruction implementation t1. Data 1 Address = 3 Data 2 Address = 0 WriteAddress = 4 Write = 1 Op = 11 R0R1 = 01 The Operation itself a.Tmp = i+1 b.Tmp = decode(Tmp) c.controlVariable = is zero[AND(CurrentLine, Tmp)] Decode tmp Irrelevant tmp The result of the ALU Micro-Instruction

36
Micro instruction implementation t2. Data 1 Address = 0 Data 2 Address = 3 WriteAddress = 6 Write = 1 Op = 10 R0R1 = 00 The Operation itself a.Tmp = i+1 b.Tmp = decode(Tmp) c.controlVariable = is zero[AND(CurrentLine, Tmp)] And Line in register i tmp controlVariable The zero status bit Micro-Instruction

37
Instruction Hierarchy Instruction Micro-Instruction Instruction Algorithmic Instruction The Operation itself

38
Instruction Hierarchy Instruction t0: Micro-Instruction t n : Micro-Instruction t0: Micro-Instruction t n : Micro-Instruction Instruction Each micro instruction = 1 cycle Timing Variables

39
Timing variables (example with 4 time variables) CP t0 t1 t2 t3 One instruction

40
Generating Timing variables example with 16 timing variables CP Register 4bits Adder 1 Decoder t0 t15

41
Control of Count_Neighbor

42
0000 0001 0010 0011 0100 0101 0110 0111 1000

43
Control of Count_Neighbor 0000 0001 0010 0011 0100 0101 0110 0111 1000

44
Putting it all together: implementing what to do with ROM Current State TimingCVCD1D2WAWOpR0R1 t0t1t2t3 ROM Input ROM Output The current state (4 bits) The current timing variable (1 bits) Control variable (16bits) Center Register 7 (16bits)

45
Putting it all together: implementing what to do with ROM Data 1 Address ROM Input ROM Output Data 2 Address Write-Data MUX control WriteAddress Write ALU Operation Current State TimingCVCD1D2WAWOpR0R1 t0t1t2t3

46
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t3 00011000 153101 00010100 30411101 00010010 03611000 00100001 000000001 t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing

47
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t3 00011000 15310001 00010100 30411101 00010010 03611000 00100001 000000001 t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing

48
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t3 00011000 15310001 00010100 30411101 00010010 03611000 00100001 000000001 t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing

49
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t3 00011000 15310001 00010100 30411101 00010010 03611000 00100001 000000001 t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing

50
Control of Count_Neighbor 0000 0001 0010 0011 0100 0101 0110 0111 1000 t0. Set Current State 0001 t1. Set Current State 0001 t2. Set Current State 0001 t3. If ControlVariable=1 Set Current State 0010 t3. If ControlVariable=0 Set Current State 0011 Current State = 0001

51
Putting it all together: implmenting control with ROM ROM InputROM Output Current State Timing CVC NextState t0t1t2t3 00011000 0100 0010 0001 1 0010 00010001 0 0011 Here is the branch.

52
ROM Timing VariableCurrentState Registers ALU Extend 1 to 16 MUX R0R1 1 Result zerobit Op D1 D2 WA Write WriteData Next State Current State

Similar presentations

OK

Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit

Model Computer CPU Arithmetic Logic Unit Control Unit Memory Unit

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google