OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_1.2/] [rtl/] [CONTROL/] [Unit_Control.v] - Blame information for rev 71

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 diegovalve
/**********************************************************************************
2
Theia, Ray Cast Programable graphic Processing Unit.
3
Copyright (C) 2010  Diego Valverde (diego.valverde.g@gmail.com)
4
 
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 2
8
of the License, or (at your option) any later version.
9
 
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14
 
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
19
***********************************************************************************/
20
/**********************************************************************************
21
Description:
22
 
23
This is the main Finite State Machine.
24
 
25
**********************************************************************************/
26
 
27
`timescale 1ns / 1ps
28
`include "aDefinitions.v"
29
 
30
`define CU_AFTER_RESET_STATE 0
31
`define CU_WAIT_FOR_INITIAL_CONFIGURATION 1
32
`define CU_TRIGGER_CONFIGURATION_DATA_READ 2
33
`define CU_WAIT_FOR_CONFIG_DATA_READ    3
34
`define CU_ACK_CONFIG_DATA_READ 4
35
`define CU_PRECALCULATE_CONSTANTS 5
36
`define CU_WAIT_FOR_CONSTANT 6
37
`define CU_ACK_PRECALCULATE_CONSTANTS 7
38
`define CU_WAIT_FOR_TASK 8
39
`define CU_READ_TASK_DATA 9
40
`define CU_WAIT_TASK_DATA_READ 10
41
`define CU_ACK_TASK_DATA_READ 11
42
`define CU_TRIGGER_RGU 12
43
`define CU_WAIT_FOR_RGU 13
44
`define CU_ACK_RGU 14
45
`define CU_TRIGGER_GEO 15
46
`define CU_WAIT_FOR_GEO_SYNC 16
47
//`define CU_CHECK_AABBIU_REQUEST 17
48
`define CU_TRIGGER_TCC 17
49
//`define CU_CHECK_BIU_REQUEST 18
50
`define CU_TRIGGER_TFF 18
51
//`define CU_CHECK_GEO_DONE 19
52
`define CU_WAIT_FOR_TFF 19
53
`define CU_TRIGGER_AABBIU 20
54
`define CU_WAIT_FOR_AABBIU 21
55
`define CU_TRIGGER_BIU 22
56
`define CU_WAIT_FOR_BIU 23
57
`define CU_ACK_UCODE 24
58
`define CU_TRIGGER_PSU 25
59
`define CU_WAIT_FOR_PSU 26
60
`define CU_ACK_PSU 27
61
`define CU_TRIGGER_PCU 28
62
`define CU_WAIT_FOR_PCU 29
63
`define CU_ACK_PCU 30
64
`define CU_CHECK_HIT 31
65
`define CU_CLEAR_REGISTERS 32
66
`define CU_WAIT_CLEAR_REGISTERS 33
67
`define CU_ACK_CLEAR_REGISTERS  34
68
`define CU_TRIGGER_PSU_WITH_TEXTURE 35
69
`define WAIT_FOR_TCC 36
70
`define CU_TRIGGER_NPU 37
71
`define CU_WAIT_NPU 38
72
`define CU_ACK_NPU 39
73
`define CU_PERFORM_INTIAL_CONFIGURATION 40
74
`define CU_SET_PICTH 41
75 63 diegovalve
`define CU_TRIGGER_USERCONSTANTS 42
76
`define CU_WAIT_USERCONSTANTS           43
77
`define CU_ACK_USERCONSTANTS 44
78
`define CU_TRIGGER_USERPIXELSHADER 45
79
`define CU_WAIT_FOR_USERPIXELSHADER 46
80
`define CU_ACK_USERPIXELSHADER 47
81 18 diegovalve
 
82
//--------------------------------------------------------------
83
module ControlUnit
84
(
85
 
86
input  wire                                  Clock,
87
input  wire                                  Reset,
88
input  wire[15:0]                            iControlRegister,
89
output reg                                   oGFUEnable,
90
input    wire                                  iTriggerAABBIURequest,
91
input   wire                                   iTriggerBIURequest,
92
input wire                                   iTriggertTCCRequest,
93
output reg                                   oUCodeEnable,
94 60 diegovalve
output reg[`ROM_ADDRESS_WIDTH-1:0]           oCodeInstructioPointer,
95 18 diegovalve
input   wire                                   iUCodeDone,
96
input wire                                   iUCodeReturnValue,
97
input wire                                   iGFUDone,
98
input wire                                   iGEOSync,
99
output reg                                   oTriggerTFF,
100
input wire                                   iTFFDone,
101
input wire                                   MST_I,
102
output reg[2:0]                              oRamBusOwner,
103
input wire                                   iIODone,
104
output reg                                   oSetCurrentPitch,
105 71 diegovalve
output reg                                   oFlipMemEnabled,
106
output reg                                   oFlipMem,
107 18 diegovalve
output reg                                   oIOWritePixel
108
 
109
);
110
 
111
//Internal State Machine varibles
112
reg     [5:0]    CurrentState;
113
reg     [5:0]    NextState;
114
integer ucode_file;
115
reg rResetHitFlop,rHitFlopEnable;
116
wire wHit;
117
 
118
`ifdef DUMP_CODE
119
        integer log;
120
 
121
        initial
122
        begin
123
 
124
        $display("Opening ucode dump file....\n");
125
        ucode_file = $fopen("CU.log","w");
126
        end
127
 
128
`endif
129
 
130
//--------------------------------------------------------------
131
FFToggleOnce_1Bit FFTO1
132
(
133
        .Clock( Clock ),
134
        .Reset( rResetHitFlop ),
135
        .Enable( rHitFlopEnable && iUCodeDone ),
136
        .S( iUCodeReturnValue ),
137
        .Q( wHit )
138
);
139
//--------------------------------------------------------------
140
 
141
`ifdef DEBUG
142
        always @ ( wHit )
143
        begin
144
                `LOGME "*** Triangle HIT ***\n");
145
        end
146
`endif
147
 
148
//Next states logic and Reset sequence
149
always @(posedge Clock or posedge Reset)
150
  begin
151
 
152
    if (Reset)
153
                CurrentState <= `CU_AFTER_RESET_STATE;
154
    else
155
                CurrentState <= NextState;
156
 
157
  end
158
 
159
//--------------------------------------------------------------
160
always @ ( * )
161
begin
162
        case (CurrentState)
163
        //-----------------------------------------
164
        `CU_AFTER_RESET_STATE:
165
        begin
166
 
167
        `ifdef DEBUG
168
                `LOGME"%d CU_AFTER_RESET_STATE\n",$time);
169
        `endif
170
 
171
                oRamBusOwner                            <= 0;
172 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_INITIAL;
173 18 diegovalve
                oGFUEnable                                      <= 0;
174
                oUCodeEnable                            <= 0;
175
                oIOWritePixel                           <= 0;
176
                rResetHitFlop                           <= 1;
177
                rHitFlopEnable                          <= 0;
178
                oTriggerTFF             <= 0;
179
                oSetCurrentPitch        <= 1;
180 71 diegovalve
                oFlipMemEnabled         <= 0;
181
                oFlipMem                                                <= 0;
182 18 diegovalve
                //oIncCurrentPitch        <= 0;
183
 
184
                NextState                                       <= `CU_WAIT_FOR_INITIAL_CONFIGURATION;
185
 
186
        end
187
        //-----------------------------------------
188
 
189
        `CU_WAIT_FOR_INITIAL_CONFIGURATION:
190
        begin
191
        $display("CU_WAIT_FOR_INITIAL_CONFIGURATION");
192
//              `ifdef DEBUG
193
//                      `LOGME"%d Control: CU_WAIT_FOR_INITIAL_CONFIGURATION\n",$time);
194
//              `endif
195
 
196
                oRamBusOwner                            <= 0;
197 60 diegovalve
                oCodeInstructioPointer  <= 0;
198 18 diegovalve
                oGFUEnable                                      <= 0;
199
                oUCodeEnable                            <= 0;
200
                oIOWritePixel                           <= 0;
201
                rResetHitFlop                           <= 1;
202
                rHitFlopEnable                          <= 0;
203
      oTriggerTFF             <= 0;
204
                oSetCurrentPitch        <= 0;
205 71 diegovalve
                oFlipMemEnabled         <= 0;
206
                oFlipMem                                                <= 0;
207 18 diegovalve
                //oIncCurrentPitch        <= 0;         
208
 
209
                if ( MST_I  )
210
                        NextState <= `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
211
                else
212
                        NextState <= `CU_WAIT_FOR_INITIAL_CONFIGURATION;
213
 
214
 
215
        end
216
        //-----------------------------------------
217
        `CU_PERFORM_INTIAL_CONFIGURATION:
218
        begin
219
        oRamBusOwner                            <= 0;
220 60 diegovalve
                oCodeInstructioPointer  <= 0;
221 18 diegovalve
                oGFUEnable                                      <= 0;
222
                oUCodeEnable                            <= 0;
223
                oIOWritePixel                           <= 0;
224
                rResetHitFlop                           <= 1;
225
                rHitFlopEnable                          <= 0;
226
      oTriggerTFF             <= 0;
227
                oSetCurrentPitch        <= 0;
228 71 diegovalve
                oFlipMemEnabled         <= 0;
229
                oFlipMem                                                <= 0;
230 18 diegovalve
                //oIncCurrentPitch        <= 0;         
231
 
232
                if ( MST_I  )
233
                        NextState <= `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
234
                else
235
                        NextState <= `CU_CLEAR_REGISTERS;
236
 
237
        end
238
        //-----------------------------------------
239
        `CU_CLEAR_REGISTERS:
240
        begin
241
        `ifdef DEBUG
242
                `LOGME"%d CU_CLEAR_REGISTERS\n",$time);
243
        `endif
244
 
245
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
246 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_INITIAL;
247 18 diegovalve
                oGFUEnable                                      <= 0;
248
                oUCodeEnable                            <= 1;   //*
249
                oIOWritePixel                           <= 0;
250
                rResetHitFlop                           <= 0;
251
                rHitFlopEnable                          <= 0;
252
                oTriggerTFF             <= 0;
253
                oSetCurrentPitch        <= 0;
254 71 diegovalve
                oFlipMemEnabled         <= 1;
255
                oFlipMem                                                <= 1;
256
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
257 18 diegovalve
                //oIncCurrentPitch        <= 0;
258
 
259
                NextState                                       <= `CU_WAIT_CLEAR_REGISTERS;
260
        end
261
//-----------------------------------------     
262
        `CU_WAIT_CLEAR_REGISTERS:
263
        begin
264
//      `ifdef DEBUG
265
//              `LOGME"%d CU_WAIT_CLEAR_REGISTERS\n",$time);
266
//      `endif  
267
 
268
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
269 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_INITIAL;
270 18 diegovalve
                oGFUEnable                                      <= 0;
271
                oUCodeEnable                            <= 0;
272
                oIOWritePixel                           <= 0;
273
                rResetHitFlop                           <= 0;
274
                rHitFlopEnable                          <= 0;
275
      oTriggerTFF             <= 0;
276
                oSetCurrentPitch        <= 0;
277 71 diegovalve
                oFlipMemEnabled         <= 1;
278
                oFlipMem                                                <= 0;
279 18 diegovalve
                //oIncCurrentPitch        <= 0;
280
 
281
                if ( iUCodeDone )
282
                        NextState <= `CU_ACK_CLEAR_REGISTERS;
283
                else
284
                        NextState <= `CU_WAIT_CLEAR_REGISTERS;
285
 
286
        end
287
        //-----------------------------------------
288
        `CU_ACK_CLEAR_REGISTERS:
289
        begin
290
        `ifdef DEBUG
291
                `LOGME"%d CU_ACK_CLEAR_REGISTERS\n", $time);
292
        `endif
293
 
294
                oRamBusOwner                            <= 0;
295 60 diegovalve
                oCodeInstructioPointer  <= 0;
296 18 diegovalve
                oGFUEnable                                      <= 0;
297
                oUCodeEnable                            <= 0; //*        
298
                oIOWritePixel                           <= 0;
299
                rResetHitFlop                           <= 0;
300
                rHitFlopEnable                          <= 0;
301
      oTriggerTFF             <= 0;
302
                oSetCurrentPitch        <= 0;
303 71 diegovalve
                oFlipMemEnabled         <= 0;
304
                oFlipMem                                                <= 0;
305 18 diegovalve
                //oIncCurrentPitch        <= 0;
306
 
307
                NextState <= `CU_WAIT_FOR_CONFIG_DATA_READ;
308
        end
309
 
310
 
311
 
312
        //-----------------------------------------
313
        `CU_WAIT_FOR_CONFIG_DATA_READ:
314
        begin
315
        $display("CU_WAIT_FOR_CONFIG_DATA_READ");
316
//              `ifdef DEBUG
317
//                      `LOGME"%d Control: CU_WAIT_FOR_CONFIG_DATA_READ\n",$time);
318
//              `endif
319
 
320
                oRamBusOwner                            <= 0;//`REG_BUS_OWNED_BY_BCU;
321 60 diegovalve
                oCodeInstructioPointer  <= 0;
322 18 diegovalve
                oGFUEnable                                      <= 0;
323
                oUCodeEnable                            <= 0;
324
                oIOWritePixel                           <= 0;
325
                rResetHitFlop                           <= 0;
326
                rHitFlopEnable                          <= 0;
327
      oTriggerTFF             <= 0;
328
                oSetCurrentPitch        <= 0;
329 71 diegovalve
                oFlipMemEnabled         <= 0;
330
                oFlipMem                                                <= 0;
331 18 diegovalve
                //oIncCurrentPitch        <= 0;
332
 
333
                if ( MST_I == 0  )
334
                        NextState <= `CU_PRECALCULATE_CONSTANTS;
335
                else
336
                        NextState <= `CU_WAIT_FOR_CONFIG_DATA_READ;
337
 
338
        end
339
        //-----------------------------------------
340
        `CU_PRECALCULATE_CONSTANTS:
341
        begin
342
        $display("CU_PRECALCULATE_CONSTANTS");
343
        `ifdef DEBUG
344
                `LOGME"%d Control: CU_PRECALCULATE_CONSTANTS\n", $time);
345
        `endif
346
 
347
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
348 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_CPPU;
349 18 diegovalve
                oGFUEnable                              <= 0;
350
                oUCodeEnable                            <= 1; //*       
351
                oIOWritePixel                           <= 0;
352
                rResetHitFlop                           <= 0;
353
                rHitFlopEnable                          <= 0;
354
      oTriggerTFF             <= 0;
355
                oSetCurrentPitch        <= 0;
356 71 diegovalve
                oFlipMemEnabled         <= 0;
357
                oFlipMem                                                <= 0;
358 18 diegovalve
                //oIncCurrentPitch        <= 0;
359
 
360
                NextState <= `CU_WAIT_FOR_CONSTANT;
361
 
362
        end
363
        //-----------------------------------------
364
        `CU_WAIT_FOR_CONSTANT:
365
        begin
366
//      `ifdef DEBUG
367
//              `LOGME"%d Control: CU_WAIT_FOR_CONSTANT\n", $time);
368
//      `endif
369
 
370
 
371
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
372 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_CPPU;
373 18 diegovalve
                oGFUEnable                                 <= 0;
374
                oUCodeEnable                            <= 0; //*        
375
                oIOWritePixel                           <= 0;
376
                rResetHitFlop                           <= 0;
377
                rHitFlopEnable                          <= 0;
378
      oTriggerTFF             <= 0;
379
                oSetCurrentPitch        <= 0;
380 71 diegovalve
                oFlipMemEnabled         <= 0;
381
                oFlipMem                                                <= 0;
382 18 diegovalve
                //oIncCurrentPitch        <= 0;
383
 
384
                if ( iUCodeDone )
385
                        NextState <= `CU_ACK_PRECALCULATE_CONSTANTS;
386
                else
387
                        NextState <= `CU_WAIT_FOR_CONSTANT;
388
 
389
        end
390
        //-----------------------------------------
391
        `CU_ACK_PRECALCULATE_CONSTANTS:
392
        begin
393
        $display("CU_ACK_PRECALCULATE_CONSTANTS");
394
        `ifdef DEBUG
395
                `LOGME"%d Control: CU_ACK_PRECALCULATE_CONSTANTS\n", $time);
396
        `endif
397
 
398
 
399
                oRamBusOwner                            <= 0;//`REG_BUS_OWNED_BY_BCU;
400 60 diegovalve
                oCodeInstructioPointer  <= 0;
401 18 diegovalve
                oGFUEnable                                 <= 0;
402
                oUCodeEnable                            <= 0; //*        
403
                oIOWritePixel                           <= 0;
404
                rResetHitFlop                           <= 0;
405
                rHitFlopEnable                          <= 0;
406
      oTriggerTFF             <= 0;
407
                oSetCurrentPitch        <= 0;
408 71 diegovalve
                oFlipMemEnabled         <= 0;
409
                oFlipMem                                                <= 0;
410 18 diegovalve
                //oIncCurrentPitch        <= 0;
411
 
412 63 diegovalve
                NextState <= `CU_TRIGGER_USERCONSTANTS;//CU_WAIT_FOR_TASK;
413 18 diegovalve
 
414
        end
415
        //-----------------------------------------
416 71 diegovalve
 
417 63 diegovalve
        `CU_TRIGGER_USERCONSTANTS:
418
        begin
419
        `ifdef DEBUG
420
                `LOGME"%d Control: CU_TRIGGER_RGU\n",$time);
421
        `endif
422
 
423
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
424
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_USERCONSTANTS;
425
                oGFUEnable                                      <= 0;
426
                oUCodeEnable                            <= 1;   //*
427
                oIOWritePixel                           <= 0;
428
                rResetHitFlop                           <= 0;
429
                rHitFlopEnable                          <= 0;
430
      oTriggerTFF             <= 0;
431
                oSetCurrentPitch        <= 0;
432 71 diegovalve
                oFlipMemEnabled         <= 0;
433
                oFlipMem                                                <= 0;
434 63 diegovalve
                //oIncCurrentPitch        <= 0;
435
 
436
                NextState <= `CU_WAIT_USERCONSTANTS;
437
        end
438
        //-----------------------------------------
439
        `CU_WAIT_USERCONSTANTS:
440
        begin
441
 
442
//      `ifdef DEBUG
443
//              `LOGME"%d Control: CU_WAIT_FOR_RGU\n",$time);
444
//      `endif
445
 
446
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
447
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_USERCONSTANTS;
448
                oGFUEnable                                      <= 0;
449
                oUCodeEnable                            <= 0;
450
                oIOWritePixel                           <= 0;
451
                rResetHitFlop                           <= 0;
452
                rHitFlopEnable                          <= 0;
453
      oTriggerTFF             <= 0;
454
                oSetCurrentPitch        <= 0;
455 71 diegovalve
                oFlipMemEnabled         <= 0;
456
                oFlipMem                                                <= 0;
457 63 diegovalve
                //oIncCurrentPitch        <= 0;
458
 
459
                if ( iUCodeDone )
460
                        NextState <= `CU_ACK_USERCONSTANTS;
461
                else
462
                        NextState <= `CU_WAIT_USERCONSTANTS;
463
        end
464
        //-----------------------------------------
465
        `CU_ACK_USERCONSTANTS:
466
        begin
467
 
468
        `ifdef DEBUG
469
                `LOGME"%d Control: CU_ACK_RGU\n",$time);
470
        `endif
471
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
472
                oCodeInstructioPointer  <= 0;
473
                oGFUEnable                                      <= 0;
474
                oUCodeEnable                            <= 0; //*        
475
                oIOWritePixel                           <= 0;
476
                rResetHitFlop                           <= 0;
477
                rHitFlopEnable                          <= 0;
478
      oTriggerTFF             <= 0;
479
                oSetCurrentPitch        <= 0;
480 71 diegovalve
                oFlipMemEnabled         <= 0;
481
                oFlipMem                                                <= 0;
482 63 diegovalve
                //oIncCurrentPitch        <= 0;
483
 
484
                if ( iUCodeDone  == 0)
485
                        NextState <= `CU_TRIGGER_RGU;
486
                else
487
                        NextState <= `CU_ACK_USERCONSTANTS;
488
 
489
        end
490
        //-----------------------------------------
491 18 diegovalve
        `CU_TRIGGER_RGU:
492
        begin
493
 
494
        `ifdef DEBUG
495
                `LOGME"%d Control: CU_TRIGGER_RGU\n",$time);
496
        `endif
497
 
498
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
499 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_RGU;
500 18 diegovalve
                oGFUEnable                                      <= 0;
501
                oUCodeEnable                            <= 1;   //*
502
                oIOWritePixel                           <= 0;
503
                rResetHitFlop                           <= 0;
504
                rHitFlopEnable                          <= 0;
505
      oTriggerTFF             <= 0;
506
                oSetCurrentPitch        <= 0;
507 71 diegovalve
                oFlipMemEnabled         <= 0;
508
                oFlipMem                                                <= 0;
509 18 diegovalve
                //oIncCurrentPitch        <= 0;
510
 
511
                NextState <= `CU_WAIT_FOR_RGU;
512
        end
513
        //-----------------------------------------
514
        `CU_WAIT_FOR_RGU:
515
        begin
516
 
517
//      `ifdef DEBUG
518
//              `LOGME"%d Control: CU_WAIT_FOR_RGU\n",$time);
519
//      `endif
520
 
521
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
522 60 diegovalve
                oCodeInstructioPointer  <= 0;
523 18 diegovalve
                oGFUEnable                                      <= 0;
524
                oUCodeEnable                            <= 0;
525
                oIOWritePixel                           <= 0;
526
                rResetHitFlop                           <= 0;
527
                rHitFlopEnable                          <= 0;
528
      oTriggerTFF             <= 0;
529
                oSetCurrentPitch        <= 0;
530 71 diegovalve
                oFlipMemEnabled         <= 0;
531
                oFlipMem                                                <= 0;
532 18 diegovalve
                //oIncCurrentPitch        <= 0;
533
 
534
                if ( iUCodeDone )
535
                        NextState <= `CU_ACK_RGU;
536
                else
537
                        NextState <= `CU_WAIT_FOR_RGU;
538
        end
539
        //-----------------------------------------
540
        `CU_ACK_RGU:
541
        begin
542
 
543
        `ifdef DEBUG
544
                `LOGME"%d Control: CU_ACK_RGU\n",$time);
545
        `endif
546
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
547 60 diegovalve
                oCodeInstructioPointer  <= 0;
548 18 diegovalve
                oGFUEnable                                      <= 0;
549
                oUCodeEnable                            <= 0; //*        
550
                oIOWritePixel                           <= 0;
551
                rResetHitFlop                           <= 0;
552
                rHitFlopEnable                          <= 0;
553
      oTriggerTFF             <= 0;
554
                oSetCurrentPitch        <= 0;
555 71 diegovalve
                oFlipMemEnabled         <= 0;
556
                oFlipMem                                                <= 0;
557 18 diegovalve
                //oIncCurrentPitch        <= 0;
558
 
559
                if ( iUCodeDone  == 0)
560
                        NextState <= `CU_TRIGGER_GEO;
561
                else
562
                        NextState <= `CU_ACK_RGU;
563
 
564
        end
565
        //-----------------------------------------
566
        `CU_TRIGGER_GEO:
567
        begin
568
 
569
        `ifdef DEBUG
570
                `LOGME"%d Control: CU_TRIGGER_GEO\n",$time);
571
        `endif
572
 
573
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
574 60 diegovalve
                oCodeInstructioPointer  <= 0;
575 18 diegovalve
                oUCodeEnable                            <= 0;
576
                oGFUEnable                                      <= 1;
577
                oIOWritePixel                           <= 0;
578
                rResetHitFlop                           <= 1;   //*
579
                rHitFlopEnable                          <= 0;
580
      oTriggerTFF             <= 0;
581
                oSetCurrentPitch        <= 0;
582 71 diegovalve
                oFlipMemEnabled         <= 0;
583
                oFlipMem                                                <= 0;
584 18 diegovalve
                //oIncCurrentPitch        <= 0;
585
 
586
                NextState <= `CU_WAIT_FOR_GEO_SYNC;
587
 
588
        end
589
        //-----------------------------------------
590
        `CU_WAIT_FOR_GEO_SYNC:
591
        begin
592
 
593
        `ifdef DEBUG
594
                `LOGME"%d Control: CU_WAIT_FOR_GEO_SYNC\n",$time);
595
        `endif
596
 
597
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
598 60 diegovalve
                oCodeInstructioPointer  <= 0;
599 18 diegovalve
                oUCodeEnable                            <= 0;
600
                oGFUEnable                                      <= 0; //Change AUg 15
601
                oIOWritePixel                           <= 0;
602
                rResetHitFlop                           <= 0;
603
                rHitFlopEnable                          <= 0;
604
      oTriggerTFF             <= 0;
605
                oSetCurrentPitch        <= 0;
606 71 diegovalve
                oFlipMemEnabled         <= 0;
607
                oFlipMem                                                <= 0;
608 18 diegovalve
                //oIncCurrentPitch        <= 0;
609
 
610
        if (iGEOSync & iTriggerAABBIURequest )
611
                NextState <= `CU_TRIGGER_AABBIU;
612
        else if (iGEOSync & iTriggerBIURequest)
613
                NextState <= `CU_TRIGGER_BIU;
614
        else if (iGEOSync & iTriggertTCCRequest )
615
      NextState <= `CU_TRIGGER_TCC;
616
   else if (iGEOSync & iGFUDone )
617
      NextState <= `CU_CHECK_HIT;
618
   else
619
      NextState <= `CU_WAIT_FOR_GEO_SYNC;
620
 
621
        end
622
        //-----------------------------------------
623
        `CU_TRIGGER_TCC:
624
        begin
625
        //$display("CU_TRIGGER_TCC");
626
        `ifdef DEBUG
627
                `LOGME"%d Control: CU_TRIGGER_TCC\n",$time);
628
        `endif
629
 
630
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
631 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_TCC;
632 18 diegovalve
                oUCodeEnable                            <= 1;   //*
633
                oGFUEnable                                      <= 0;
634
                oIOWritePixel                           <= 0;
635
                rResetHitFlop                           <= 0;
636
                rHitFlopEnable                          <= 0;
637
      oTriggerTFF             <= 0;
638
                oSetCurrentPitch        <= 0;
639 71 diegovalve
                oFlipMemEnabled         <= 1;
640
                oFlipMem                                                <= 1; //We need u,v from last IO read cycle
641
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
642 18 diegovalve
                //oIncCurrentPitch        <= 0;
643
 
644
          NextState  <= `WAIT_FOR_TCC;
645
        end
646
        //-----------------------------------------
647
        `WAIT_FOR_TCC:
648
        begin
649
 
650
        //$display("WAIT_FOR_TCC");
651
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
652 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_TCC;
653 18 diegovalve
                oUCodeEnable                            <= 0;    //*
654
                oGFUEnable                                      <= 0;
655
                oIOWritePixel                           <= 0;
656
                rResetHitFlop                           <= 0;
657
                rHitFlopEnable                          <= 0;
658
      oTriggerTFF             <= 0;
659
                oSetCurrentPitch        <= 0;
660 71 diegovalve
                oFlipMemEnabled         <= 1;
661
                oFlipMem                                                <= 0;
662 18 diegovalve
                //oIncCurrentPitch        <= 0;
663
 
664
           if ( iUCodeDone )
665
                        NextState <= `CU_ACK_UCODE;
666
                else
667
                        NextState <= `WAIT_FOR_TCC;
668
 
669
        end
670
        //-----------------------------------------
671
        /*
672
        Was there any hit at all?
673
        At this point, all the triangles in the list
674
        have been traversed looking for a hit with our ray.
675
        There are 3 possibilities:
676
        1) The was not a single hit, then just paint a black
677
        pixel on the screen and send it via PCU.
678
        2)There was a hit and Texturing is not enabled, then trigger the PSU with
679
        no texturing
680
        2) There was a hit and Texturing is enabled, then fetch the texture
681
        values corresponding to the triangle that we hitted.
682
        */
683
        `CU_CHECK_HIT:
684
        begin
685
 
686
        `ifdef DEBUG
687
                `LOGME"%d Control: CU_CHECK_HIT\n",$time);
688
        `endif
689
 
690
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
691 60 diegovalve
                oCodeInstructioPointer  <= 0;
692 18 diegovalve
                oUCodeEnable                            <= 0;
693
                oGFUEnable                                      <= 0;    ///CHANGED Aug 15
694
                oIOWritePixel                           <= 0;
695
                rResetHitFlop                           <= 0;
696
                rHitFlopEnable                          <= 0;
697
           oTriggerTFF             <= 0;
698
                oSetCurrentPitch        <= 0;
699 71 diegovalve
                oFlipMemEnabled         <= 1;
700
                oFlipMem                                                <= 1;
701
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
702 18 diegovalve
                //oIncCurrentPitch        <= 0;
703
 
704
                if (wHit && !iControlRegister[`CR_EN_TEXTURE] )
705
                        NextState <= `CU_TRIGGER_PSU;
706
                else if (wHit && iControlRegister[`CR_EN_TEXTURE])
707
                        NextState <= `CU_TRIGGER_TFF;           //Fetch the texture values from external RAM
708
                else
709
                        NextState <= `CU_TRIGGER_PCU;           //Make sure contents of the OUT_REG are ZERo!
710
        end
711
        //-----------------------------------------
712
        /*
713
        Get the texture values from external RAM.
714
        GFU already took care of calculating the correct
715
        texture addresses for the 4 coordinates so now lets
716
        just ask for them.
717
        */
718
        `CU_TRIGGER_TFF:
719
        begin
720
        `ifdef DEBUG
721
                `LOGME"%d Control: CU_TRIGGER_TFF\n",$time);
722
        `endif
723
 
724
        //$display("CU_TRIGGER_TFF");
725
 
726
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
727 60 diegovalve
                oCodeInstructioPointer  <= 0;
728 18 diegovalve
                oUCodeEnable                            <= 0;
729
                oGFUEnable                                      <= 1;
730
                oIOWritePixel                           <= 0;
731
                rResetHitFlop                           <= 0;
732
                rHitFlopEnable                          <= 0;
733
                oTriggerTFF             <= 1;       //*
734 71 diegovalve
           oSetCurrentPitch        <= 0;
735
                oFlipMemEnabled         <= 1;
736
                oFlipMem                                                <= 0;  //NO need, we did this n check hit
737 18 diegovalve
                //oIncCurrentPitch        <= 0;
738
 
739
                NextState <= `CU_WAIT_FOR_TFF;
740
        end
741
        //-----------------------------------------
742
        `CU_WAIT_FOR_TFF:
743
        begin
744
 
745
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_GFU;
746 60 diegovalve
                oCodeInstructioPointer  <= 0;
747 18 diegovalve
                oUCodeEnable                            <= 0;
748
                oGFUEnable                                      <= 0;     //Changed Aug 14
749
                oIOWritePixel                           <= 0;
750
                rResetHitFlop                           <= 0;
751
                rHitFlopEnable                          <= 0;
752
                oTriggerTFF             <= 0;
753
                oSetCurrentPitch        <= 0;
754 71 diegovalve
                oFlipMemEnabled         <= 1;
755
                oFlipMem                                                <= 0;
756
 
757 18 diegovalve
                //oIncCurrentPitch        <= 0;
758
 
759
        if (iTFFDone)
760
                NextState <= `CU_TRIGGER_PSU_WITH_TEXTURE;
761
        else
762
                NextState <= `CU_WAIT_FOR_TFF;
763
 
764
        end
765
        //-----------------------------------------
766
        `CU_TRIGGER_PSU_WITH_TEXTURE:
767
        begin
768
 
769
        `ifdef DEBUG
770
                `LOGME"%d Control: CU_TRIGGER_PSU_WITH_TEXTURE\n",$time);
771
        `endif
772
 
773
           oRamBusOwner                                 <= `REG_BUS_OWNED_BY_UCODE;
774 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_PSU2;
775 18 diegovalve
                oUCodeEnable                            <= 1;
776
                oGFUEnable                                      <= 0;
777
                oIOWritePixel                           <= 0;
778
                rResetHitFlop                           <= 0;
779
                rHitFlopEnable                          <= 0;
780
                oTriggerTFF             <= 0;
781
                oSetCurrentPitch        <= 0;
782 71 diegovalve
                oFlipMemEnabled         <= 1;
783
                oFlipMem                                                <= 1;
784
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
785 18 diegovalve
           //oIncCurrentPitch        <= 0;
786
 
787
                NextState <= `CU_WAIT_FOR_PSU;
788
        end
789
        //-----------------------------------------
790
        `CU_TRIGGER_AABBIU:
791
        begin
792
 
793
        `ifdef DEBUG
794
                `LOGME"%d Control: CU_TRIGGER_AABBIU\n",$time);
795
        `endif
796
//      $stop();
797 60 diegovalve
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
798 18 diegovalve
 
799 60 diegovalve
                oCodeInstructioPointer  <=`ENTRYPOINT_INDEX_AABBIU;
800 18 diegovalve
                oUCodeEnable                            <= 1;
801
                oGFUEnable                                      <= 1;
802
                oIOWritePixel                           <= 0;
803
                rResetHitFlop                           <= 0;
804
                rHitFlopEnable                          <= 0;
805
      oTriggerTFF             <= 0;
806
                oSetCurrentPitch        <= 0;
807 71 diegovalve
                oFlipMemEnabled         <= 1;
808
                oFlipMem                                                <= 1;
809
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
810 18 diegovalve
                //oIncCurrentPitch        <= 0;
811
 
812
                NextState <= `CU_WAIT_FOR_AABBIU;
813
        end
814
        //-----------------------------------------
815
        `CU_WAIT_FOR_AABBIU:
816
        begin
817
 
818
 
819
//      `ifdef DEBUG
820
//              `LOGME"%d Control: CU_WAIT_FOR_AABBIU\n",$time);
821
//      `endif
822
 
823
 
824
//      $display("iUCodeDone",iUCodeDone);
825
 
826
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
827 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_AABBIU;
828 18 diegovalve
                oUCodeEnable                            <= 0;
829
                oGFUEnable                                      <= 1;
830
                oIOWritePixel                           <= 0;
831
                rResetHitFlop                           <= 0;
832
                rHitFlopEnable                          <= 0;
833
      oTriggerTFF             <= 0;
834
                oSetCurrentPitch        <= 0;
835 71 diegovalve
                oFlipMemEnabled         <= 0;
836
                oFlipMem                                                <= 0;
837 18 diegovalve
                //oIncCurrentPitch        <= 0;
838
 
839
                if ( iUCodeDone )
840
                begin
841
        //         $display("iUCodeDone\n",iUCodeDone);
842
        //              $stop();
843
                        NextState <= `CU_ACK_UCODE;
844
                end
845
                else
846
                        NextState <= `CU_WAIT_FOR_AABBIU;
847
        end
848
        //-----------------------------------------
849
        `CU_TRIGGER_BIU:
850
        begin
851
        `ifdef DEBUG
852
                `LOGME"%d Control: CU_TRIGGER_BIU\n",$time);
853
        `endif
854
 
855
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
856 60 diegovalve
                        oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_BIU;
857 18 diegovalve
                        oUCodeEnable                            <= 1;
858
                        oGFUEnable                                      <= 1;
859
                        oIOWritePixel                           <= 0;
860
                        rResetHitFlop                           <= 0;//1;        
861
                        rHitFlopEnable                          <= 1;
862
         oTriggerTFF             <= 0;
863
                        oSetCurrentPitch        <= 0;
864 71 diegovalve
                        oFlipMemEnabled         <= 1;
865
                        oFlipMem                                                <= 1;
866
                        //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
867 18 diegovalve
                        //oIncCurrentPitch        <= 0;
868
                //      $stop();
869
 
870
                        NextState <= `CU_WAIT_FOR_BIU;
871
 
872
        end
873
        //-----------------------------------------
874
        `CU_WAIT_FOR_BIU:
875
        begin
876
//      `ifdef DEBUG
877
//              `LOGME"%d Control: CU_WAIT_FOR_BIU\n",$time);
878
//      `endif
879
 
880
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
881 60 diegovalve
                        oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_BIU;
882 18 diegovalve
                        oUCodeEnable                            <= 0;
883
                        oGFUEnable                                      <= 1;
884
                        oIOWritePixel                           <= 0;
885
                        rResetHitFlop                           <= 0;
886
                        rHitFlopEnable                          <= 1;
887
         oTriggerTFF             <= 0;
888
                        oSetCurrentPitch        <= 0;
889 71 diegovalve
                        oFlipMemEnabled         <= 1;
890
                        oFlipMem                                                <= 0;
891 18 diegovalve
                        //oIncCurrentPitch        <= 0;
892
 
893
                if ( iUCodeDone )
894
                        NextState <= `CU_ACK_UCODE;
895
                else
896
                        NextState <= `CU_WAIT_FOR_BIU;
897
        end
898
        //-----------------------------------------
899
        /*
900
                ACK UCODE by setting oUCodeEnable = 0
901
        */
902
        `CU_ACK_UCODE:
903
        begin
904
        `ifdef DEBUG
905
                `LOGME"%d Control: CU_ACK_UCODE\n",$time);
906
        `endif
907
 
908
                        oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
909 60 diegovalve
                        oCodeInstructioPointer  <= 0; //*
910 18 diegovalve
                        oUCodeEnable                            <= 0;    //*
911
                        oGFUEnable                                      <= 0; //Changed Aug 15
912
                        oIOWritePixel                           <= 0;
913
                        rResetHitFlop                           <= 0;
914
                        rHitFlopEnable                          <= 0;
915
         oTriggerTFF             <= 0;
916
                        oSetCurrentPitch        <= 0;
917 71 diegovalve
                        oFlipMemEnabled         <= 0;
918
                        oFlipMem                                                <= 0;
919 18 diegovalve
                        //oIncCurrentPitch        <= 0;
920
 
921
        //              $stop();
922
 
923
                        if ( iUCodeDone == 0 )
924
                                NextState <= `CU_WAIT_FOR_GEO_SYNC;
925
                        else
926
                                NextState <= `CU_ACK_UCODE;
927
        end
928
        //-----------------------------------------
929
        /*
930
        Here we no longer use GFU so set Enable to zero
931
        */
932
        `CU_TRIGGER_PSU:
933
        begin
934
        `ifdef DEBUG
935
                `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
936
        `endif
937
 
938
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
939 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_PSU;
940 18 diegovalve
                oUCodeEnable                            <= 1;
941
                oGFUEnable                                      <= 0;//*
942
                oIOWritePixel                           <= 0;
943
                rResetHitFlop                           <= 0;
944
                rHitFlopEnable                          <= 0;
945
                oTriggerTFF             <= 0;
946
                oSetCurrentPitch        <= 0;
947 71 diegovalve
                oFlipMemEnabled         <= 1;
948
                oFlipMem                                                <= 1;
949
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
950 18 diegovalve
                //oIncCurrentPitch        <= 0;
951
 
952
 
953
                NextState <= `CU_WAIT_FOR_PSU;
954
        end
955
        //-----------------------------------------
956
        `CU_WAIT_FOR_PSU:
957
        begin
958
 
959
//      `ifdef DEBUG
960
//              `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
961
//      `endif
962
 
963
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
964 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_PSU;
965 18 diegovalve
                oUCodeEnable                            <= 0;
966
                oGFUEnable                                      <= 0;
967
                oIOWritePixel                           <= 0;
968
                rResetHitFlop                           <= 0;
969
                rHitFlopEnable                          <= 0;
970
                oTriggerTFF             <= 0;
971
                oSetCurrentPitch        <= 0;
972 71 diegovalve
                oFlipMemEnabled         <= 1;
973
                oFlipMem                                                <= 0;
974 18 diegovalve
                //oIncCurrentPitch        <= 0;
975
 
976
 
977
                if ( iUCodeDone )
978
                        NextState <= `CU_ACK_PSU;
979
                else
980
                        NextState <= `CU_WAIT_FOR_PSU;
981
 
982
        end
983
        //-----------------------------------------
984
        `CU_ACK_PSU:
985
        begin
986
        `ifdef DEBUG
987
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
988
        `endif
989
 
990
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
991 60 diegovalve
                oCodeInstructioPointer  <= 0;    //*
992 18 diegovalve
                oUCodeEnable                            <= 0;    //*
993
                oGFUEnable                                      <= 0;
994
                oIOWritePixel                           <= 0;
995
                rResetHitFlop                           <= 0;
996
                rHitFlopEnable                          <= 0;
997
      oTriggerTFF             <= 0;
998
                oSetCurrentPitch        <= 0;
999 71 diegovalve
                oFlipMemEnabled         <= 1;
1000
                oFlipMem                                                <= 0;
1001 18 diegovalve
                //oIncCurrentPitch        <= 0;
1002
 
1003
                if ( iUCodeDone  == 0)
1004 63 diegovalve
                        NextState <= `CU_TRIGGER_USERPIXELSHADER;
1005 18 diegovalve
                else
1006
                        NextState <= `CU_ACK_PSU;
1007
 
1008
 
1009
        end
1010
        //-----------------------------------------
1011
        /*
1012
                Trigger the Pixel Commit.
1013
        */
1014
        `CU_TRIGGER_PCU:
1015
        begin
1016
 
1017
        `ifdef DEBUG
1018
                `LOGME"%d Control: CU_TRIGGER_PCU\n",$time);
1019
        `endif
1020
 
1021
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
1022 60 diegovalve
                oCodeInstructioPointer  <= 0;    //*
1023 18 diegovalve
                oUCodeEnable                            <= 0;    //*
1024
                oGFUEnable                                      <= 0;
1025
                oIOWritePixel                           <= 1; //*
1026
                rResetHitFlop                           <= 0;
1027
                rHitFlopEnable                          <= 0;
1028
      oTriggerTFF             <= 0;
1029
                oSetCurrentPitch        <= 0;
1030 71 diegovalve
                oFlipMemEnabled         <= 1;
1031
                oFlipMem                                                <= 1;
1032
                //$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
1033 18 diegovalve
                //oIncCurrentPitch        <= 0;
1034
 
1035
 
1036
                NextState <= `CU_SET_PICTH;
1037
 
1038
        end
1039
        //-----------------------------------------
1040
        `CU_SET_PICTH:
1041
        begin
1042
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
1043 60 diegovalve
                oCodeInstructioPointer  <= 0;    //*
1044 18 diegovalve
                oUCodeEnable                            <= 0;    //*
1045
                oGFUEnable                                      <= 0;
1046
                oIOWritePixel                           <= 1; //*
1047
                rResetHitFlop                           <= 0;
1048
                rHitFlopEnable                          <= 0;
1049
      oTriggerTFF             <= 0;
1050
                oSetCurrentPitch        <= 1; //*
1051 71 diegovalve
                oFlipMemEnabled         <= 1;
1052
                oFlipMem                                                <= 0;
1053 18 diegovalve
                //oIncCurrentPitch        <= 0;
1054
 
1055
 
1056
                NextState <= `CU_WAIT_FOR_PCU;
1057
        end
1058
        //-----------------------------------------
1059
        `CU_WAIT_FOR_PCU:
1060
        begin
1061
 
1062
//      `ifdef DEBUG
1063
//              `LOGME"%d Control: CU_WAIT_FOR_PCU\n",$time);
1064
//      `endif
1065
 
1066
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
1067 60 diegovalve
                oCodeInstructioPointer  <= 0;    //*
1068 18 diegovalve
                oUCodeEnable                            <= 0;    //*
1069
                oGFUEnable                                      <= 0;
1070
                oIOWritePixel                           <= 1;
1071
                rResetHitFlop                           <= 0;
1072
                rHitFlopEnable                          <= 0;
1073
      oTriggerTFF             <= 0;
1074
                oSetCurrentPitch        <= 0;
1075 71 diegovalve
                oFlipMemEnabled         <= 1;
1076
                oFlipMem                                                <= 0;
1077 18 diegovalve
                //oIncCurrentPitch        <= 0;
1078
 
1079
                if ( iIODone )
1080
                        NextState <= `CU_ACK_PCU;
1081
                else
1082
                        NextState <= `CU_WAIT_FOR_PCU;
1083
 
1084
        end
1085
        //-----------------------------------------
1086
        `CU_ACK_PCU:
1087
        begin
1088
 
1089
        `ifdef DEBUG
1090
                `LOGME"%d Control: CU_ACK_PCU\n",$time);
1091
        `endif
1092
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_GFU;
1093 60 diegovalve
                oCodeInstructioPointer  <= 0;    //*
1094 18 diegovalve
                oUCodeEnable                            <= 0;    //*
1095
                oGFUEnable                                      <= 0;
1096
                oIOWritePixel                           <= 0;
1097
                rResetHitFlop                           <= 0;
1098
                rHitFlopEnable                          <= 0;
1099
      oTriggerTFF             <= 0;
1100
                oSetCurrentPitch        <= 0;
1101 71 diegovalve
                oFlipMemEnabled         <= 1;
1102
                oFlipMem                                                <= 0;
1103 18 diegovalve
                //oIncCurrentPitch        <= 0;
1104
 
1105
                NextState <= `CU_TRIGGER_NPU;
1106
 
1107
        end
1108
        //-----------------------------------------
1109
        `CU_TRIGGER_NPU: //Next Pixel Unit
1110
        begin
1111
        `ifdef DEBUG
1112
                `LOGME"%d Control: CU_TRIGGER_NPU\n",$time);
1113
        `endif
1114
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
1115 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_NPG;       //*
1116 18 diegovalve
                oUCodeEnable                            <= 1;   //*
1117
                oGFUEnable                                      <= 0;
1118
                oIOWritePixel                           <= 0;
1119
                rResetHitFlop                           <= 0;
1120
                rHitFlopEnable                          <= 0;
1121
      oTriggerTFF             <= 0;
1122
                oSetCurrentPitch        <= 0;
1123 71 diegovalve
                oFlipMemEnabled         <= 1;
1124
                oFlipMem                                                <= 0;
1125 18 diegovalve
                //oIncCurrentPitch        <= 0;
1126
 
1127
                NextState <= `CU_WAIT_NPU;
1128
        end
1129
        //-----------------------------------------
1130
        `CU_WAIT_NPU:
1131
        begin
1132
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
1133 60 diegovalve
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_NPG;
1134 18 diegovalve
                oUCodeEnable                            <= 0;
1135
                oGFUEnable                                      <= 0;
1136
                oIOWritePixel                           <= 0;
1137
                rResetHitFlop                           <= 0;
1138
                rHitFlopEnable                          <= 0;
1139
                oTriggerTFF             <= 0;
1140
                oSetCurrentPitch        <= 0;
1141 71 diegovalve
                oFlipMemEnabled         <= 1;
1142
                oFlipMem                                                <= 0;
1143 18 diegovalve
                //oIncCurrentPitch        <= 0;
1144
 
1145
                if ( iUCodeDone )
1146
                        NextState <= `CU_ACK_NPU;
1147
                else
1148
                        NextState <= `CU_WAIT_NPU;
1149
        end
1150
        //-----------------------------------------
1151
        `CU_ACK_NPU:
1152
        begin
1153
        `ifdef DEBUG
1154
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
1155
        `endif
1156
 
1157
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
1158 60 diegovalve
                oCodeInstructioPointer  <= 0;    //*
1159 18 diegovalve
                oUCodeEnable                            <= 0;    //*
1160
                oGFUEnable                                      <= 0;
1161
                oIOWritePixel                           <= 0;
1162
                rResetHitFlop                           <= 0;
1163
                rHitFlopEnable                          <= 0;
1164
      oTriggerTFF             <= 0;
1165
                oSetCurrentPitch        <= 0;
1166 71 diegovalve
                oFlipMemEnabled         <= 1;
1167
                oFlipMem                                                <= 0;
1168 18 diegovalve
                //oIncCurrentPitch        <= 0;
1169
 
1170
                if ( iUCodeDone  == 0)
1171
                        NextState <= `CU_TRIGGER_RGU;
1172
                else
1173
                        NextState <= `CU_ACK_NPU;
1174
 
1175
 
1176
        end
1177
        //-----------------------------------------
1178 63 diegovalve
        //-----------------------------------------
1179
        /*
1180
        Here we no longer use GFU so set Enable to zero
1181
        */
1182
        `CU_TRIGGER_USERPIXELSHADER:
1183
        begin
1184
        `ifdef DEBUG
1185
                `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
1186
        `endif
1187
 
1188
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
1189
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_PIXELSHADER;
1190
                oUCodeEnable                            <= 1;
1191
                oGFUEnable                                      <= 0;//*
1192
                oIOWritePixel                           <= 0;
1193
                rResetHitFlop                           <= 0;
1194
                rHitFlopEnable                          <= 0;
1195
                oTriggerTFF             <= 0;
1196
                oSetCurrentPitch        <= 0;
1197 71 diegovalve
                oFlipMemEnabled         <= 1;
1198
                oFlipMem                                                <= 0;
1199 63 diegovalve
                //oIncCurrentPitch        <= 0;
1200
 
1201
 
1202
                NextState <= `CU_WAIT_FOR_USERPIXELSHADER;
1203
        end
1204
        //-----------------------------------------
1205
        `CU_WAIT_FOR_USERPIXELSHADER:
1206
        begin
1207
 
1208
//      `ifdef DEBUG
1209
//              `LOGME"%d Control: CU_TRIGGER_PSU\n",$time);
1210
//      `endif
1211
 
1212
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
1213
                oCodeInstructioPointer  <= `ENTRYPOINT_INDEX_PIXELSHADER;
1214
                oUCodeEnable                            <= 0;
1215
                oGFUEnable                                      <= 0;
1216
                oIOWritePixel                           <= 0;
1217
                rResetHitFlop                           <= 0;
1218
                rHitFlopEnable                          <= 0;
1219
                oTriggerTFF             <= 0;
1220
                oSetCurrentPitch        <= 0;
1221 71 diegovalve
                oFlipMemEnabled         <= 1;
1222
                oFlipMem                                                <= 0;
1223 63 diegovalve
                //oIncCurrentPitch        <= 0;
1224
 
1225
 
1226
                if ( iUCodeDone )
1227
                        NextState <= `CU_ACK_USERPIXELSHADER;
1228
                else
1229
                        NextState <= `CU_WAIT_FOR_USERPIXELSHADER;
1230
 
1231
        end
1232
        //-----------------------------------------
1233
        `CU_ACK_USERPIXELSHADER:
1234
        begin
1235
        `ifdef DEBUG
1236
                `LOGME"%d Control: CU_ACK_PSU\n",$time);
1237
        `endif
1238
 
1239
                oRamBusOwner                            <= `REG_BUS_OWNED_BY_UCODE;
1240
                oCodeInstructioPointer  <= 0;    //*
1241
                oUCodeEnable                            <= 0;    //*
1242
                oGFUEnable                                      <= 0;
1243
                oIOWritePixel                           <= 0;
1244
                rResetHitFlop                           <= 0;
1245
                rHitFlopEnable                          <= 0;
1246
      oTriggerTFF             <= 0;
1247
                oSetCurrentPitch        <= 0;
1248 71 diegovalve
                oFlipMemEnabled         <= 1;
1249
                oFlipMem                                                <= 0;
1250 63 diegovalve
                //oIncCurrentPitch        <= 0;
1251
 
1252
                if ( iUCodeDone  == 0)
1253
                        NextState <= `CU_TRIGGER_PCU;
1254
                else
1255
                        NextState <= `CU_ACK_USERPIXELSHADER;
1256
 
1257
 
1258
        end
1259
        //---------------------------------------------------
1260 18 diegovalve
        default:
1261
        begin
1262
 
1263
        `ifdef DEBUG
1264
                `LOGME"%d Control: ERRO Undefined State\n",$time);
1265
        `endif
1266
 
1267
                oRamBusOwner                            <= 0;
1268 60 diegovalve
                oCodeInstructioPointer  <= 0;
1269 18 diegovalve
                oUCodeEnable                            <= 0;
1270
                oGFUEnable                                      <= 0;
1271
                oIOWritePixel                           <= 0;
1272
                rResetHitFlop                           <= 0;
1273
                rHitFlopEnable                          <= 0;
1274
      oTriggerTFF             <= 0;
1275
                oSetCurrentPitch        <= 0;
1276 71 diegovalve
                oFlipMemEnabled         <= 0;
1277
                oFlipMem                                                <= 0;
1278 18 diegovalve
                //oIncCurrentPitch        <= 0;
1279
 
1280
                NextState <= `CU_AFTER_RESET_STATE;
1281
        end
1282
        //-----------------------------------------
1283
 
1284
        endcase
1285
 
1286
end //always    
1287
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.