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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Unit_Control.v] - Blame information for rev 174

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

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

powered by: WebSVN 2.1.0

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