Toward a general purpose computer Example: Game of Life
Game of Life For Each Line For Each Cell Solve Cell
Game of Life For Each Line For Each Cell Solve Cell Generation LineCell Matrix
Modularity Generation Module Matrix Module Line Module Cell Module
Algorithm for the Generation Module 1. CurrentGen = 0 2. Solve for current Matrix 3. CurrentGen++ 4. If CurrentGen < MAX_GEN goto 2
Solve Matrix 0. j = 1 1. Calculate line (j) 2. If j < MAX_LINE 2.1 j goto STOP
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 goto Store tmp in : even generation: i+16 odd generation : i-16
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
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
Algorithm implementation Algorithm How to do?What to do? The operation itselfcontrol
The operations in the algorithm: Operations: Add Subtract
The operation: Defining interfaces CountNeighbors CellAlive Calculate Line Solve Matrix Generation Return Number of Neighbor: N Alive: Dead: (i-1) location Return the line The matrix Return The Operation itself
The operation: Module Calculate Line, instruction 2 If alive If dead Calculate_Line(j) = OR tmp = Result = Calculate_Line(j) = OR tmp = Result = The j-th location If alive, set location i in tmp to alive The Operation itself
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
The operations in the algorithm: Operations: Add Subtract OR The Operation itself
Implementing instructions Module Count_Neighbors, instruction 1, 2.1, 3 decode(i-1) = AND Line (j) = Result = decode(i-1) = AND Line (j) = Result = 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
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
The operations in the algorithm: Operations: Add Subtract The logic AND + Check if zero The Operation itself
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
Small ALU Status Bit The Operation itself
Small ALU Status Bit The Operation itself ALU isZero Op InputB InputA
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
Implementation of AND(line,decode(i+1)) Reg1 Reg2 Reg3 Regn
Implementation of AND(line,decode(i+1)) Reg1 Reg2 Reg3 Regn ReadA ReadB 1 2 Connected like MUX 1
Implementation of AND(line,decode(i+1)) Reg1 Reg2 Reg3 Regn ReadA ReadB 1 2 Decoder Enable Write Write Address Write Data
Implementation of AND(line,decode(i+1)) Registers Data 1 Data 2 Data 1 Address Data 2 Address WriteAddress Write Data Write
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
In generation Current Generation Matrix, gen=0 Next generation Matrix I I+16
In generation Current Generation Matrix,gen=1 Next generation Matrix I+16 I
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
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
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= : N=N+1 The Operation itself
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
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
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
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
Instruction Hierarchy Instruction Micro-Instruction Instruction Algorithmic Instruction The Operation itself
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
Timing variables (example with 4 time variables) CP t0 t1 t2 t3 One instruction
Generating Timing variables example with 16 timing variables CP Register 4bits Adder 1 Decoder t0 t15
Control of Count_Neighbor
Control of Count_Neighbor
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)
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
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing
Putting it all together: implementing what to do with ROM ROM Input ROM Output Current State Timing CVC D1D2WAWOpR0R1 t0t1t2t t0. Tmp = i+1 t1. Tmp = decode(Tmp) t2. controlVariable = is zero[AND(CurrentLine, Tmp)] t3. do nothing
Control of Count_Neighbor 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
Putting it all together: implmenting control with ROM ROM InputROM Output Current State Timing CVC NextState t0t1t2t 0100 0010 0011 Here is the branch.
ROM Timing VariableCurrentState Registers ALU Extend 1 to 16 MUX R0R1 1 Result zerobit Op D1 D2 WA Write WriteData Next State Current State