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 178

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

powered by: WebSVN 2.1.0

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