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 217

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 188 diegovalve
 
27
 
28 158 diegovalve
 
29
`timescale 1ns / 1ps
30
`include "aDefinitions.v"
31 174 diegovalve
`ifdef VERILATOR
32
`include "Collaterals.v"
33
`endif
34 158 diegovalve
 
35 188 diegovalve
`define CU_AFTER_RESET_STATE                0
36
`define CU_WAIT_FOR_INITIAL_CONFIGURATION   1
37
`define CU_TRIGGER_CONFIGURATION_DATA_READ  2
38
`define CU_WAIT_FOR_CONFIG_DATA_READ        3
39
`define CU_ACK_CONFIG_DATA_READ             4
40
`define CU_PRECALCULATE_CONSTANTS           5
41
`define CU_WAIT_FOR_CONSTANT                6
42
`define CU_ACK_PRECALCULATE_CONSTANTS       7
43
`define CU_TRIGGER_MAIN                     8
44
`define CU_WAIT_FOR_MAIN                    9
45
`define CU_ACK_MAIN                         10
46
`define CU_CLEAR_REGISTERS                  11
47
`define CU_WAIT_CLEAR_REGISTERS             12
48
`define CU_ACK_CLEAR_REGISTERS              13
49
`define CU_PERFORM_INTIAL_CONFIGURATION     14
50
`define CU_TRIGGER_USERCONSTANTS            15
51
`define CU_WAIT_USERCONSTANTS               16
52
`define CU_ACK_USERCONSTANTS                17
53
`define CU_DONE                             18
54
`define CU_WAIT_FOR_RENDER_ENABLE           19
55
`define CU_WAIT_FOR_HOST_DATA_AVAILABLE     20
56
`define CU_WAIT_FOR_HOST_DATA_ACK           21
57
`define CU_COMMIT_PIXEL_RESULT              22
58 158 diegovalve
//--------------------------------------------------------------
59
module ControlUnit
60
(
61
 
62
input  wire                                  Clock,
63
input  wire                                  Reset,
64
input  wire[15:0]                            iControlRegister,
65
output reg                                   oGFUEnable,
66
input    wire                                  iTriggerAABBIURequest,
67
input   wire                                   iTriggerBIURequest,
68
input wire                                   iTriggertTCCRequest,
69
output reg                                   oUCodeEnable,
70
output reg[`ROM_ADDRESS_WIDTH-1:0]           oCodeInstructioPointer,
71
input   wire                                   iUCodeDone,
72
input wire                                   iUCodeReturnValue,
73
input wire                                   iGFUDone,
74
input wire                                   iGEOSync,
75
output reg                                   oTriggerTFF,
76
input wire                                   iTFFDone,
77
input wire                                   MST_I,
78
//output reg[2:0]                              //oRamBusOwner,
79
input wire                                   iIODone,
80
output reg                                   oSetCurrentPitch,
81
output reg                                   oFlipMemEnabled,
82
output reg                                   oFlipMem,
83
output reg                                   oIOWritePixel,
84
input wire                                   iRenderEnable,
85
input wire                                   iSceneTraverseComplete,
86
input wire                                   iHostDataAvailable,
87
input wire                                   iHostAckDataRead,
88
 
89
`ifdef DEBUG
90
input wire[`MAX_CORES-1:0]                  iDebug_CoreID,
91
`endif
92
 
93
output reg                                   oResultCommited,
94
output reg                                   oDone
95
 
96
);
97
 
98
//Internal State Machine varibles
99
reg     [5:0]    CurrentState;
100
reg     [5:0]    NextState;
101
integer ucode_file;
102
reg rResetHitFlop,rHitFlopEnable;
103
wire wHit;
104
 
105
`ifdef DUMP_CODE
106
        integer log;
107
 
108
        initial
109
        begin
110
 
111
        //$display("Opening ucode dump file....\n");
112
        ucode_file = $fopen("CU.log","w");
113
        end
114
 
115
`endif
116
 
117
 
118
 
119
//--------------------------------------------------------------
120
FFToggleOnce_1Bit FFTO1
121
(
122
        .Clock( Clock ),
123
        .Reset( rResetHitFlop ),
124
        .Enable( rHitFlopEnable && iUCodeDone ),
125
        .S( iUCodeReturnValue ),
126
        .Q( wHit )
127
);
128
//--------------------------------------------------------------
129
 
130
 
131
//Next states logic and Reset sequence
132
always @(posedge Clock or posedge Reset)
133
  begin
134
 
135
    if (Reset)
136
                CurrentState <= `CU_AFTER_RESET_STATE;
137
    else
138
                CurrentState <= NextState;
139
 
140
  end
141
 
142
//--------------------------------------------------------------
143
always @ ( * )
144
begin
145
        case (CurrentState)
146
        //-----------------------------------------
147
        `CU_AFTER_RESET_STATE:
148
        begin
149
 
150
        `ifdef DEBUG_CU
151
                $display("%d CU_AFTER_RESET_STATE\n",$time);
152
        `endif
153
 
154
                //oRamBusOwner                          = 0;
155
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_INITIAL;
156
                oGFUEnable                                      = 0;
157
                oUCodeEnable                            = 0;
158
                oIOWritePixel                           = 0;
159
                rResetHitFlop                           = 1;
160
                rHitFlopEnable                          = 0;
161
                oTriggerTFF             = 0;
162
                oSetCurrentPitch        = 1;
163
                oFlipMemEnabled         = 0;
164
                oFlipMem                                                = 0;
165
                oDone                   = 0;
166
                oResultCommited                 = 0;
167
                //oIncCurrentPitch        = 0;
168
 
169
                NextState                                       = `CU_WAIT_FOR_INITIAL_CONFIGURATION;
170
 
171
        end
172
        //-----------------------------------------
173
 
174
        `CU_WAIT_FOR_INITIAL_CONFIGURATION:
175
        begin
176
 
177
                oCodeInstructioPointer  = 0;
178
                oGFUEnable                                      = 0;
179
                oUCodeEnable                            = 0;
180
                oIOWritePixel                           = 0;
181
                rResetHitFlop                           = 1;
182
                rHitFlopEnable                          = 0;
183
      oTriggerTFF             = 0;
184
                oSetCurrentPitch        = 0;
185
                oFlipMemEnabled         = 0;
186
                oFlipMem                                                = 0;
187
                oDone                   = 0;
188
                oResultCommited                 = 0;
189
                //oIncCurrentPitch        = 0;          
190
 
191
                if ( MST_I  )
192
                        NextState = `CU_PERFORM_INTIAL_CONFIGURATION;//`CU_WAIT_FOR_CONFIG_DATA_READ;
193
                else
194
                        NextState = `CU_WAIT_FOR_INITIAL_CONFIGURATION;
195
 
196
 
197
        end
198
        //-----------------------------------------
199
        `CU_PERFORM_INTIAL_CONFIGURATION:
200
        begin
201
 
202
        //oRamBusOwner                          = 0;
203
                oCodeInstructioPointer  = 0;
204
                oGFUEnable                                      = 0;
205
                oUCodeEnable                            = 0;
206
                oIOWritePixel                           = 0;
207
                rResetHitFlop                           = 1;
208
                rHitFlopEnable                          = 0;
209
      oTriggerTFF             = 0;
210
                oSetCurrentPitch        = 0;
211
                oFlipMemEnabled         = 0;
212
                oFlipMem                                                = 0;
213
                oDone                   = 0;
214
                oResultCommited                 = 0;
215
                //oIncCurrentPitch        = 0;          
216
 
217
                if ( MST_I  == 0 && iRenderEnable == 1'b1)
218
                        NextState = `CU_CLEAR_REGISTERS;//`CU_WAIT_FOR_CONFIG_DATA_READ;
219
                else
220
                        NextState = `CU_PERFORM_INTIAL_CONFIGURATION;
221
 
222
 
223
        end
224
        //-----------------------------------------
225
        `CU_CLEAR_REGISTERS:
226
        begin
227
 
228
        `ifdef DEBUG_CU
229
                $display("%d CU_CLEAR_REGISTERS\n",$time);
230
        `endif
231
 
232
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_INITIAL;
233
                oGFUEnable                                      = 0;
234
                oUCodeEnable                            = 1;    //*
235
                oIOWritePixel                           = 0;
236
                rResetHitFlop                           = 0;
237
                rHitFlopEnable                          = 0;
238
                oTriggerTFF             = 0;
239
                oSetCurrentPitch        = 0;
240
                oFlipMemEnabled         = 1;
241
                oFlipMem                                                = 0;
242
                oDone                   = 0;
243
                oResultCommited                 = 0;
244
 
245 188 diegovalve
 
246 158 diegovalve
                NextState                                       = `CU_WAIT_CLEAR_REGISTERS;
247
        end
248
//-----------------------------------------     
249
        `CU_WAIT_CLEAR_REGISTERS:
250
        begin
251 188 diegovalve
 
252 158 diegovalve
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_INITIAL;
253
                oGFUEnable                                      = 0;
254
                oUCodeEnable                            = 0;
255
                oIOWritePixel                           = 0;
256
                rResetHitFlop                           = 0;
257
                rHitFlopEnable                          = 0;
258
      oTriggerTFF             = 0;
259
                oSetCurrentPitch        = 0;
260
                oFlipMemEnabled         = 1;
261
                oFlipMem                                                = 0;
262
                oDone                   = 0;
263
                oResultCommited                 = 0;
264
                //oIncCurrentPitch        = 0;
265
 
266
                if ( iUCodeDone )
267
                        NextState = `CU_ACK_CLEAR_REGISTERS;
268
                else
269
                        NextState = `CU_WAIT_CLEAR_REGISTERS;
270
 
271
        end
272
        //-----------------------------------------
273
        `CU_ACK_CLEAR_REGISTERS:
274
        begin
275
 
276
        `ifdef DEBUG_CU
277
                $display("%d CU_ACK_CLEAR_REGISTERS\n", $time);
278
        `endif
279
 
280
        //$display("CORE: %d CU_ACK_CLEAR_REGISTERS", iDebug_CoreID);
281
 
282
                //oRamBusOwner                          = 0;
283
                oCodeInstructioPointer  = 0;
284
                oGFUEnable                                      = 0;
285
                oUCodeEnable                            = 0; //*         
286
                oIOWritePixel                           = 0;
287
                rResetHitFlop                           = 0;
288
                rHitFlopEnable                          = 0;
289
      oTriggerTFF             = 0;
290
                oSetCurrentPitch        = 0;
291
                oFlipMemEnabled         = 0;
292
                oFlipMem                                                = 0;
293
                oDone                   = 0;
294
                oResultCommited                 = 0;
295
                //oIncCurrentPitch        = 0;
296
 
297
                NextState = `CU_WAIT_FOR_CONFIG_DATA_READ;
298
        end
299
 
300
 
301
 
302
        //-----------------------------------------
303
        `CU_WAIT_FOR_CONFIG_DATA_READ:
304
        begin
305
 
306
                oCodeInstructioPointer  = 0;
307
                oGFUEnable                                      = 0;
308
                oUCodeEnable                            = 0;
309
                oIOWritePixel                           = 0;
310
                rResetHitFlop                           = 0;
311
                rHitFlopEnable                          = 0;
312
      oTriggerTFF             = 0;
313
                oSetCurrentPitch        = 0;
314
                oFlipMemEnabled         = 0;
315
                oFlipMem                                                = 0;
316
                oDone                   = 0;
317
                oResultCommited                 = 0;
318
                //oIncCurrentPitch        = 0;
319
 
320
                if ( MST_I == 0  )
321
                        NextState = `CU_PRECALCULATE_CONSTANTS;
322
                else
323
                        NextState = `CU_WAIT_FOR_CONFIG_DATA_READ;
324
 
325
        end
326
        //-----------------------------------------
327
        `CU_PRECALCULATE_CONSTANTS:
328
        begin
329
//$display("CORE: %d CU_PRECALCULATE_CONSTANTS", iDebug_CoreID);
330
        `ifdef DEBUG_CU
331
                $display("%d Control: CU_PRECALCULATE_CONSTANTS\n", $time);
332
        `endif
333
 
334
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
335
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_CPPU;
336
                oGFUEnable                              = 0;
337
                oUCodeEnable                            = 1; //*        
338
                oIOWritePixel                           = 0;
339
                rResetHitFlop                           = 0;
340
                rHitFlopEnable                          = 0;
341
      oTriggerTFF             = 0;
342
                oSetCurrentPitch        = 0;
343
                oFlipMemEnabled         = 0;
344
                oFlipMem                                                = 0;
345
                oDone                   = 0;
346
                oResultCommited                 = 0;
347
                //oIncCurrentPitch        = 0;
348
 
349
                NextState = `CU_WAIT_FOR_CONSTANT;
350
 
351
        end
352
        //-----------------------------------------
353
        `CU_WAIT_FOR_CONSTANT:
354
        begin
355
//      `ifdef DEBUG_CU
356
//              $display("%d Control: CU_WAIT_FOR_CONSTANT\n", $time);
357
//      `endif
358
 
359
 
360
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
361
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_CPPU;
362
                oGFUEnable                                 = 0;
363
                oUCodeEnable                            = 0; //*         
364
                oIOWritePixel                           = 0;
365
                rResetHitFlop                           = 0;
366
                rHitFlopEnable                          = 0;
367
      oTriggerTFF             = 0;
368
                oSetCurrentPitch        = 0;
369
                oFlipMemEnabled         = 0;
370
                oFlipMem                                                = 0;
371
                oDone                   = 0;
372
                oResultCommited                 = 0;
373
                //oIncCurrentPitch        = 0;
374
 
375
                if ( iUCodeDone )
376
                        NextState = `CU_ACK_PRECALCULATE_CONSTANTS;
377
                else
378
                        NextState = `CU_WAIT_FOR_CONSTANT;
379
 
380
        end
381
        //-----------------------------------------
382
        `CU_ACK_PRECALCULATE_CONSTANTS:
383
        begin
384
        //$display("CORE: %d CU_ACK_PRECALCULATE_CONSTANTS", iDebug_CoreID);
385
        `ifdef DEBUG_CU
386
                $display("%d Control: CU_ACK_PRECALCULATE_CONSTANTS\n", $time);
387
        `endif
388
 
389
 
390
                //oRamBusOwner                          = 0;//`REG_BUS_OWNED_BY_BCU;
391
                oCodeInstructioPointer  = 0;
392
                oGFUEnable                                 = 0;
393
                oUCodeEnable                            = 0; //*         
394
                oIOWritePixel                           = 0;
395
                rResetHitFlop                           = 0;
396
                rHitFlopEnable                          = 0;
397
      oTriggerTFF             = 0;
398
                oSetCurrentPitch        = 0;
399
                oFlipMemEnabled         = 0;
400
                oFlipMem                                                = 0;
401
                oDone                   = 0;
402
                oResultCommited                 = 0;
403
                //oIncCurrentPitch        = 0;
404
 
405
                NextState = `CU_TRIGGER_USERCONSTANTS;//CU_WAIT_FOR_TASK;
406
 
407
        end
408
        //-----------------------------------------
409
 
410
        `CU_TRIGGER_USERCONSTANTS:
411
        begin
412
        `ifdef DEBUG_CU
413
                $display("%d Control: CU_TRIGGER_USERCONSTANTS\n",$time);
414
        `endif
415
 
416
                //$display("CORE: %d CU_TRIGGER_USERCONSTANTS", iDebug_CoreID);
417
 
418
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
419
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_USERCONSTANTS;
420
                oGFUEnable                                      = 0;
421
                oUCodeEnable                            = 1;    //*
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
                NextState = `CU_WAIT_USERCONSTANTS;
434
        end
435
        //-----------------------------------------
436
        `CU_WAIT_USERCONSTANTS:
437
        begin
438
 
439
//      `ifdef DEBUG_CU
440
//              $display("%d Control: CU_WAIT_FOR_RGU\n",$time);
441
//      `endif
442
 
443
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
444
                oCodeInstructioPointer  = `ENTRYPOINT_INDEX_USERCONSTANTS;
445
                oGFUEnable                                      = 0;
446
                oUCodeEnable                            = 0;
447
                oIOWritePixel                           = 0;
448
                rResetHitFlop                           = 0;
449
                rHitFlopEnable                          = 0;
450
      oTriggerTFF             = 0;
451
                oSetCurrentPitch        = 0;
452
                oFlipMemEnabled         = 0;
453
                oFlipMem                                                = 0;
454
                oDone                   = 0;
455
                oResultCommited                 = 0;
456
                //oIncCurrentPitch        = 0;
457
 
458
                if ( iUCodeDone )
459
                        NextState = `CU_ACK_USERCONSTANTS;
460
                else
461
                        NextState = `CU_WAIT_USERCONSTANTS;
462
        end
463
        //-----------------------------------------
464
        `CU_ACK_USERCONSTANTS:
465
        begin
466
 
467
        `ifdef DEBUG_CU
468
                $display("%d Control: CU_ACK_RGU\n",$time);
469
        `endif
470
 
471
        //$display("CORE: %d CU_ACK_USERCONSTANTS", iDebug_CoreID);
472
 
473
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
474
                oCodeInstructioPointer  = 0;
475
                oGFUEnable                                      = 0;
476
                oUCodeEnable                            = 0; //* 
477
                oIOWritePixel                           = 0;
478
                rResetHitFlop                           = 0;
479
                rHitFlopEnable                          = 0;
480
      oTriggerTFF             = 0;
481
                oSetCurrentPitch        = 0;
482
                oFlipMemEnabled         = 0;
483
                oFlipMem                                                = 0;
484
                oDone                   = 0;
485
                oResultCommited                 = 0;
486
                //oIncCurrentPitch        = 0;
487
 
488
                if ( iUCodeDone  == 0)
489
                        NextState = `CU_WAIT_FOR_RENDER_ENABLE;
490
                else
491
                        NextState = `CU_ACK_USERCONSTANTS;
492
 
493
        end
494
        //-----------------------------------------
495
        `CU_WAIT_FOR_RENDER_ENABLE:
496
        begin
497
        `ifdef DEBUG_CU
498
        $display("CORE: %d CU_WAIT_FOR_RENDER_ENABLE", iDebug_CoreID);
499
        `endif
500
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
501
                oCodeInstructioPointer  = 0;
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 ( iRenderEnable)
516 178 diegovalve
                        NextState = `CU_WAIT_FOR_HOST_DATA_AVAILABLE;//`CU_TRIGGER_RGU;
517 158 diegovalve
                else
518
                        NextState = `CU_WAIT_FOR_RENDER_ENABLE;
519
        end
520
        //-----------------------------------------
521
        `CU_WAIT_FOR_HOST_DATA_ACK:
522
        begin
523
           oCodeInstructioPointer       = 0;
524
                oUCodeEnable                            = 0;
525
                oGFUEnable                                      = 0;
526
                oIOWritePixel                           = 0;
527
                rResetHitFlop                           = 0;
528
                rHitFlopEnable                          = 0;
529
                oTriggerTFF             = 0;
530
                oSetCurrentPitch        = 0;
531
                oFlipMemEnabled         = 0;
532
                oFlipMem                                                = 0;
533
                oDone                   = 0;
534
                oResultCommited                 = 0;
535
 
536
                if ( iHostAckDataRead )
537
                        NextState = `CU_WAIT_FOR_HOST_DATA_AVAILABLE;
538
                else
539
                        NextState = `CU_WAIT_FOR_HOST_DATA_ACK;
540
        end
541
        //-----------------------------------------
542
        //Wait until data from Host becomes available
543
        `CU_WAIT_FOR_HOST_DATA_AVAILABLE:
544
        begin
545
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
546
                oCodeInstructioPointer  = 0;
547
                oUCodeEnable                            = 0;
548
                oGFUEnable                                      = 0;
549
                oIOWritePixel                           = 0;
550
                rResetHitFlop                           = 0;
551
                rHitFlopEnable                          = 0;
552
                oTriggerTFF             = 0;
553
                oSetCurrentPitch        = 0;
554
                oFlipMemEnabled         = 0;
555
                oFlipMem                                                = 0;
556
                oDone                   = 0;
557
                oResultCommited                 = 0;
558
 
559
                if ( iHostDataAvailable )
560
                        NextState = `CU_TRIGGER_MAIN;
561
                else
562
                        NextState = `CU_WAIT_FOR_HOST_DATA_AVAILABLE;
563
 
564
 
565
        end
566
        //-----------------------------------------
567
        `CU_TRIGGER_MAIN:
568
        begin
569
        `ifdef DEBUG_CU
570
                $display("%d CORE: %d Control: CU_TRIGGER_MAIN\n",$time,iDebug_CoreID);
571
        `endif
572
 
573
                        //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
574
                        oCodeInstructioPointer  = `ENTRYPOINT_INDEX_MAIN;
575
                        oUCodeEnable                            = 1;
576
                        oGFUEnable                                      = 1;
577
                        oIOWritePixel                           = 0;
578
                        rResetHitFlop                           = 0;
579
                        rHitFlopEnable                          = 0;
580
         oTriggerTFF             = 0;
581
                        oSetCurrentPitch        = 0;
582
                        oFlipMemEnabled         = 1;
583
                        oFlipMem                                                = 1;
584
                        oDone                   = 0;
585
                        oResultCommited                 = 0;
586
                        ////$display("\n\n %d XOXOXOXOX FLIP XOXOXOXOXOX\n\n",$time);
587
                        //oIncCurrentPitch        = 0;
588
                //      $stop();
589
 
590
                        NextState = `CU_WAIT_FOR_MAIN;
591
 
592
        end
593
        //-----------------------------------------
594
        `CU_WAIT_FOR_MAIN:
595
        begin
596
//      `ifdef DEBUG_CU
597
//              $display("%d Control: CU_WAIT_FOR_MAIN\n",$time);
598
//      `endif
599
 
600
                        //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
601
                        oCodeInstructioPointer  = `ENTRYPOINT_INDEX_MAIN;
602
                        oUCodeEnable                            = 0;
603
                        oGFUEnable                                      = 1;
604
                        oIOWritePixel                           = 0;
605
                        rResetHitFlop                           = 0;
606
                        rHitFlopEnable                          = 1;
607
         oTriggerTFF             = 0;
608
                        oSetCurrentPitch        = 0;
609
                        oFlipMemEnabled         = 1;
610
                        oFlipMem                                                = 0;
611
                        oDone                   = 0;
612
                        oResultCommited                 = 0;
613
                        //oIncCurrentPitch        = 0;
614
 
615
                        //NextState = `CU_WAIT_FOR_MAIN;
616
 
617
 
618
                if ( iUCodeDone )
619
                        NextState = `CU_ACK_MAIN;
620
                else
621
                        NextState = `CU_WAIT_FOR_MAIN;
622
 
623
        end
624
        //-----------------------------------------
625
        /*
626
                ACK UCODE by setting oUCodeEnable = 0
627
        */
628
        `CU_ACK_MAIN:
629
        begin
630
        `ifdef DEBUG_CU
631
                $display("%d CORE: %d Control: CU_ACK_MAIN\n",$time, iDebug_CoreID);
632
        `endif
633
 
634
                        //oRamBusOwner                          = `REG_BUS_OWNED_BY_GFU;
635
                        oCodeInstructioPointer  = 0; //*
636
                        oUCodeEnable                            = 0;     //*
637 188 diegovalve
                        oGFUEnable                                      = 0;
638 158 diegovalve
                        oIOWritePixel                           = 0;
639
                        rResetHitFlop                           = 0;
640
                        rHitFlopEnable                          = 1;
641
         oTriggerTFF             = 0;
642
                        oSetCurrentPitch        = 0;
643
                        oFlipMemEnabled         = 0;
644
                        oFlipMem                                                = 0;
645
                        oDone                   = 0;
646
                        oResultCommited                 = 0;
647 188 diegovalve
 
648 178 diegovalve
                if (iUCodeDone == 1'b0 && iUCodeReturnValue == 0)
649
                        NextState = `CU_WAIT_FOR_HOST_DATA_AVAILABLE;
650
                else if (iUCodeDone == 1'b0 && iUCodeReturnValue == 1)
651
         NextState = `CU_COMMIT_PIXEL_RESULT;
652
                else
653
                        NextState = `CU_ACK_MAIN;
654 158 diegovalve
 
655 188 diegovalve
        end
656
        //-----------------------------------------
657
        `CU_COMMIT_PIXEL_RESULT:
658
        begin
659 178 diegovalve
                oCodeInstructioPointer  = 0;
660
                oUCodeEnable                            = 0;
661
                oGFUEnable                                      = 0;
662
                oIOWritePixel                           = 0;
663
                rResetHitFlop                           = 0;
664
                rHitFlopEnable                          = 0;
665
                oTriggerTFF             = 0;
666
                oSetCurrentPitch        = 0;
667
                oFlipMemEnabled         = 0;
668 188 diegovalve
                oFlipMem                                                = 0;
669
                oDone                   = 0;
670 178 diegovalve
                oResultCommited                 = 1;
671
 
672
 
673
                NextState = `CU_WAIT_FOR_HOST_DATA_AVAILABLE;
674 188 diegovalve
        end
675 158 diegovalve
        //-----------------------------------------
676
        //-----------------------------------------
677
        `CU_DONE:
678
        begin
679
                //oRamBusOwner                          = `REG_BUS_OWNED_BY_UCODE;
680
                oCodeInstructioPointer  = 0;
681
                oUCodeEnable                            = 0;
682
                oGFUEnable                                      = 0;
683
                oIOWritePixel                           = 0;
684
                rResetHitFlop                           = 0;
685
                rHitFlopEnable                          = 0;
686
      oTriggerTFF             = 0;
687
                oSetCurrentPitch        = 0;
688
                oFlipMemEnabled         = 0;
689
                oFlipMem                                                = 1;
690
                oDone                   = 1;
691
                oResultCommited                 = 0;
692
                //oIncCurrentPitch        = 0;
693
 
694
 
695
                NextState = `CU_DONE;
696
 
697
        end
698
        //---------------------------------------------------
699
        default:
700
        begin
701
 
702
        `ifdef DEBUG_CU
703
                $display("%d Control: ERROR Undefined State\n",$time);
704
        `endif
705
 
706
                //oRamBusOwner                          = 0;
707
                oCodeInstructioPointer  = 0;
708
                oUCodeEnable                            = 0;
709
                oGFUEnable                                      = 0;
710
                oIOWritePixel                           = 0;
711
                rResetHitFlop                           = 0;
712
                rHitFlopEnable                          = 0;
713
      oTriggerTFF             = 0;
714
                oSetCurrentPitch        = 0;
715
                oFlipMemEnabled         = 0;
716
                oFlipMem                                                = 0;
717
                oDone                   = 0;
718
                oResultCommited                 = 0;
719
                //oIncCurrentPitch        = 0;
720
 
721
                NextState = `CU_AFTER_RESET_STATE;
722
        end
723
        //-----------------------------------------
724
 
725
        endcase
726
 
727
end //always    
728
endmodule

powered by: WebSVN 2.1.0

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