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

Subversion Repositories s1_core

[/] [s1_core/] [trunk/] [hdl/] [rtl/] [sparc_core/] [sparc_ifu_milfsm.v] - Blame information for rev 105

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

Line No. Rev Author Line
1 95 fafa1971
// ========== Copyright Header Begin ==========================================
2
// 
3
// OpenSPARC T1 Processor File: sparc_ifu_milfsm.v
4
// Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
5
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6
// 
7
// The above named program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public
9
// License version 2 as published by the Free Software Foundation.
10
// 
11
// The above named program is distributed in the hope that it will be 
12
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
// General Public License for more details.
15
// 
16
// You should have received a copy of the GNU General Public
17
// License along with this work; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
// 
20
// ========== Copyright Header End ============================================
21
////////////////////////////////////////////////////////////////////////
22
/*
23
//  Module Name: sparc_ifu_ifqdp
24
//  Description:
25
//  The IFQ is the icache fill queue.  This communicates between the
26
//  IFU and the outside world.  It handles icache misses and
27
//  invalidate requests from the crossbar.
28
*/
29
////////////////////////////////////////////////////////////////////////
30
// Global header file includes
31
////////////////////////////////////////////////////////////////////////
32
 
33
/*
34
/* ========== Copyright Header Begin ==========================================
35
*
36
* OpenSPARC T1 Processor File: ifu.h
37
* Copyright (c) 2006 Sun Microsystems, Inc.  All Rights Reserved.
38
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
39
*
40
* The above named program is free software; you can redistribute it and/or
41
* modify it under the terms of the GNU General Public
42
* License version 2 as published by the Free Software Foundation.
43
*
44
* The above named program is distributed in the hope that it will be
45
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
46
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
47
* General Public License for more details.
48
*
49
* You should have received a copy of the GNU General Public
50
* License along with this work; if not, write to the Free Software
51
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
52
*
53
* ========== Copyright Header End ============================================
54
*/
55
////////////////////////////////////////////////////////////////////////
56
/*
57
//
58
//  Module Name: ifu.h
59
//  Description:
60
//  All ifu defines
61
*/
62
 
63
//--------------------------------------------
64
// Icache Values in IFU::ICD/ICV/ICT/FDP/IFQDP
65
//--------------------------------------------
66
// Set Values
67
 
68
// IC_IDX_HI = log(icache_size/4ways) - 1
69
 
70
 
71
// !!IMPORTANT!! a change to IC_LINE_SZ will mean a change to the code as
72
//   well.  Unfortunately this has not been properly parametrized.
73
//   Changing the IC_LINE_SZ param alone is *not* enough.
74
 
75
 
76
// !!IMPORTANT!! a change to IC_TAG_HI will mean a change to the code as
77
//   well.  Changing the IC_TAG_HI param alone is *not* enough to
78
//   change the PA range. 
79
// highest bit of PA
80
 
81
 
82
 
83
// Derived Values
84
// 4095
85
 
86
 
87
// number of entries - 1 = 511
88
 
89
 
90
// 12
91
 
92
 
93
// 28
94
 
95
 
96
// 7
97
 
98
 
99
// tags for all 4 ways + parity
100
// 116
101
 
102
 
103
// 115
104
 
105
 
106
 
107
//----------------------------------------------------------------------
108
// For thread scheduler in IFU::DTU::SWL
109
//----------------------------------------------------------------------
110
// thread states:  (thr_state[4:0])
111
 
112
 
113
 
114
 
115
 
116
 
117
 
118
 
119
 
120
// thread configuration register bit fields
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
//----------------------------------------------------------------------
129
// For MIL fsm in IFU::IFQ
130
//----------------------------------------------------------------------
131
 
132
 
133
 
134
 
135
 
136
 
137
 
138
 
139
 
140
 
141
 
142
//---------------------------------------------------
143
// Interrupt Block
144
//---------------------------------------------------
145
 
146
 
147
 
148
 
149
 
150
 
151
 
152
//-------------------------------------
153
// IFQ
154
//-------------------------------------
155
// valid bit plus ifill
156
 
157
 
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
//`ifdef SPARC_L2_64B
170
 
171
 
172
//`else
173
//`define BANK_ID_HI 8
174
//`define BANK_ID_LO 7
175
//`endif
176
 
177
//`define CPX_INV_PA_HI  116
178
//`define CPX_INV_PA_LO  112
179
 
180
 
181
 
182
 
183
 
184
 
185
 
186
//----------------------------------------
187
// IFU Traps
188
//----------------------------------------
189
// precise
190
 
191
 
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
// disrupting
206
 
207
 
208
 
209
 
210
 
211
 
212
 
213
 
214
//`define MILFSM_NULL   4'b0000
215
//`define MILFSM_WAIT   4'b1000
216
//`define MILFSM_REQ    4'b1100
217
//`define MILFSM_FILL0  4'b1001
218
//`define MILFSM_FILL1  4'b1011
219
 
220
//`define MIL_V  3
221
//`define MIL_R  2
222
//`define MIL_A  1
223
//`define MIL_F  0
224
 
225
 
226
module sparc_ifu_milfsm(/*AUTOARG*/
227
   // Outputs
228
   so, fsm_ifc_errreq, fsm_ifc_wrt_tir, fsm_ifc_comp_valid,
229
   fsm_ifc_mil_valid, fsm_ifc_mil_cancel, fsm_ifc_thr_ready,
230
   fsm_ifc_pred_rdy, fsm_ifc_pcxreq, fsm_ifc_addrbit4_i2,
231
   fsm_ifc_milchld, fsm_ifc_milstate,
232
   // Inputs
233
   ifc_fsm_can_thisthr, ifc_fsm_fill_thisthr_i2,
234
   ifc_fsm_wr_complete_f, ifqadv_i2, ifd_ifc_4bpkt_i2,
235
   fcl_ifq_thr_s1, ifc_fsm_imiss_thisthr_s, ifc_fsm_milhit_s,
236
   ifc_fsm_hiton_thismil_s, ifc_fsm_pcxaccept_thisthr,
237
   ifc_fsm_miladdr4, clk, se, si, reset, ifc_fsm_err_thisthr
238
   );
239
 
240
   input       ifc_fsm_can_thisthr,
241
                     ifc_fsm_fill_thisthr_i2;
242
 
243
   input       ifc_fsm_wr_complete_f;
244
 
245
   input       ifqadv_i2;
246
 
247
   input       ifd_ifc_4bpkt_i2;
248
   input [1:0] fcl_ifq_thr_s1;
249
   input       ifc_fsm_imiss_thisthr_s;
250
   input       ifc_fsm_milhit_s;
251
         input       ifc_fsm_hiton_thismil_s,
252
               ifc_fsm_pcxaccept_thisthr;
253
   input       ifc_fsm_miladdr4;
254
 
255
   input       clk,
256
               se,
257
               si,
258
               reset;
259
 
260
   input       ifc_fsm_err_thisthr;
261
 
262
 
263
   output      so;
264
 
265
   output      fsm_ifc_errreq;
266
   output      fsm_ifc_wrt_tir;
267
 
268
   output      fsm_ifc_comp_valid,
269
                     fsm_ifc_mil_valid,
270
               fsm_ifc_mil_cancel,
271
                     fsm_ifc_thr_ready;
272
   output      fsm_ifc_pred_rdy,
273
                     fsm_ifc_pcxreq,
274
                     fsm_ifc_addrbit4_i2;
275
 
276
   output [2:0] fsm_ifc_milchld;
277
 
278
   output [3:0] fsm_ifc_milstate;
279
 
280
 
281
//----------------------------------------------------------------------
282
// Declarations
283
//----------------------------------------------------------------------
284
 
285
 
286
   // local variables
287
   reg [3:0]     next_state;
288
 
289
   wire [3:0]    milstate;
290
 
291
   wire [2:0]   local_milchld;
292
 
293
   wire         milchld_valid;
294
 
295
   wire   fill_this16b;
296
 
297
 
298
   wire         cancel_mil,
299
                      cancel_next;
300
   wire         err_pending,
301
                      err_pending_next;
302
 
303
   wire         valid_d1,
304
                valid_i2;
305
 
306
   wire [2:0]    next_milchld;
307
 
308
 
309
   // Missed Instruction List State Machine
310
   // 3   - valid
311
   // 2   - req
312
   // 1   - addr for fill fill (1/0)
313
   // 0   - fill
314
   //
315
   // 2   - child valid
316
   // 1:0 - child thr ptr
317
   //
318
 
319
 
320
   always @(/*AUTOSENSE*/err_pending or ifc_fsm_err_thisthr
321
            or ifc_fsm_fill_thisthr_i2 or ifc_fsm_imiss_thisthr_s
322
            or ifc_fsm_milhit_s or ifc_fsm_pcxaccept_thisthr
323
            or ifc_fsm_wr_complete_f or ifd_ifc_4bpkt_i2 or ifqadv_i2
324
            or milstate)
325
     begin
326
              case (milstate)  //  synopsys parallel_case
327
                4'b0000: // null
328
                  begin
329
                     //ic_wrreq_i2 = 1'b0;             
330
                     //  orphan_chld = 1'b0;
331
               next_state[1:0] = 2'b0;
332
               if (ifc_fsm_err_thisthr | ifc_fsm_imiss_thisthr_s)
333
                             begin
334
                                next_state[3] = 1'b1;
335
                                if (ifc_fsm_milhit_s & ~ifc_fsm_err_thisthr)
336
                                  next_state[2] = 1'b0;  // MILFSM_WAIT
337
                                else
338
                                  next_state[2] = 1'b1;  // MILFSM_REQ;
339
                             end
340
                     else
341
                             next_state = milstate;
342
                  end // case: begin...
343
 
344
                4'b1100:  // req
345
                  begin
346
                     // ic_wrreq_i2 = 1'b0;             
347
                     // if canthr=1, the request will not be sent out in this cycle.
348
               if ((ifc_fsm_pcxaccept_thisthr) &
349
                   ~(ifc_fsm_err_thisthr | err_pending))
350
                 // two requests are made when there is an error.
351
                 // one, with errbit=1 gets back in invalidate response, 
352
                 // the other, with errbit=0, gets the regular ifill 
353
                 // return
354
                             begin
355
                                // we invalidate the icache on detecting an error
356
                                // only if this wasn't an MIL hit as well.  If it
357
                                // was an MIL we would have gone to the wait state
358
                                // already and it is too late to invalidate the cache
359
                                next_state = 4'b1000;
360
                    //              orphan_chld = 1'b0;             
361
                             end
362
//                   else if ((cancel_mil | ifc_fsm_can_thisthr) & 
363
//                        ~milchld_valid & ~ifc_fsm_hiton_thismil_s)
364
//                           begin
365
//                              next_state = `MILFSM_NULL;
366
//                           end
367
                     else
368
                             begin
369
                                next_state = milstate;
370
                    //              orphan_chld = 1'b0;
371
                             end
372
                  end // case: 4'b1100
373
 
374
                4'b1000: // wait
375
                  begin
376
               //              orphan_chld = 1'b0;
377
                     if (ifc_fsm_fill_thisthr_i2)
378
                             begin
379
                                // ic_wrreq_i2 = 1'b1;
380
                    if (ifd_ifc_4bpkt_i2 & ifqadv_i2) // 4B ifill from IOB
381
                      // don't want to advance too quickly and get fasle compl
382
                      next_state = 4'b0000;
383
                    else if (~ifd_ifc_4bpkt_i2)
384
                                  next_state = 4'b1001;
385
                    else
386
                      next_state = milstate;
387
                             end
388
                     else
389
                             begin
390
                                next_state = milstate;
391
                                //ic_wrreq_i2 = 1'b0;               
392
                             end
393
                  end // case: 4'b1000
394
 
395
                4'b1001: // fill0
396
                  begin
397
               //              orphan_chld = 1'b0;
398
               if (ifc_fsm_wr_complete_f)
399
                             begin
400
                                next_state = 4'b1011;
401
                                //ic_wrreq_i2 = 1'b1;
402
                             end
403
                     else
404
                             begin
405
                                next_state = milstate;
406
                                //ic_wrreq_i2 = 1'b1;
407
                             end
408
                  end // case: 4'b1001
409
 
410
                4'b1011: // fill1
411
                  // Do we really need this state??  yes, to start thr
412
                  begin
413
               //              orphan_chld = 1'b0;                  
414
                     if (ifc_fsm_wr_complete_f)
415
                             begin
416
                                //ic_wrreq_i2 = 1'b0;               
417
                    //              if (delay_mil | ifc_fsm_imiss_thisthr_s)
418
                    //                next_state = `MILFSM_REQ;
419
                    //              else
420
                                next_state = 4'b0000;
421
                             end
422
                     else
423
                             begin
424
                                //ic_wrreq_i2 = 1'b1;
425
                                next_state = milstate;
426
                             end // else: !if(ifc_fsm_wr_complete_f)
427
                  end // case: 4'b10001
428
 
429
                default:
430
                  begin
431
               // synopsys translate_off
432
                     // 0in <fire -message "MILSTATE, Error: SPARC/IFU/MILFSM: unknown state!"
433
 
434
 
435
               if ($time > (4* 1))
436
                 begin
437
 
438
 
439
 
440
 
441
                          $display ("MILSTATE",
442
                            "Error: SPARC/IFU/MILFSM: unknown state! %b\n",milstate);
443
 
444
                 end
445
 
446
               // synopsys translate_on               
447
                     next_state = milstate;
448
                     //ic_wrreq_i2 = 1'b0;                  
449
               //              orphan_chld = 1'b0;      
450
                  end // case: default
451
              endcase // casex(milstate)
452
     end // always @ (...
453
 
454
 
455
   // MIL state reg
456
   dffr #(4) milst_reg(.din  (next_state[3:0]),
457
                                   .q    (milstate[3:0]),
458
                                   .clk  (clk),
459
                                   .rst  (reset),
460
                                   .se   (se), .si(), .so());
461
 
462
   // Cancel - Delay state machine
463
   // -- not used anymore
464
   // C D
465
   // 0 0  - null
466
   // 1 0  - current thread cancelled but pending from L2
467
   // 1 1  - one ifill pending from L2, current thread will be sent
468
   //        out after that.
469
 
470
//   assign cancel_next = (ifc_fsm_can_thisthr | 
471
//                                         cancel_mil) & next_state[`MIL_V];    // reset wins
472
 
473
   assign cancel_next = (ifc_fsm_can_thisthr | cancel_mil) &
474
                          (milstate[3] | ifc_fsm_imiss_thisthr_s |
475
                           ifc_fsm_err_thisthr);    // reset wins
476
 
477
   dffr #(1) can_ff(.din  (cancel_next),
478
                                .q    (cancel_mil),
479
                                .clk  (clk),
480
                                .rst  (reset),
481
                                .se   (se), .si(), .so());
482
 
483
   // track if we need to send out an error request
484
   assign err_pending_next = (ifc_fsm_err_thisthr &
485
                              (milstate[2] | ~milstate[3]) |
486
//                            err_pending & next_state[`MIL_V]) &       
487
                        err_pending & milstate[3]) &
488
                              ~ifc_fsm_pcxaccept_thisthr;
489
                         // & ~ifc_fsm_can_thisthr;
490
 
491
   dffr #(1) err_ff(.din (err_pending_next),
492
                                .q   (err_pending),
493
                                .clk (clk),
494
                                .rst (reset), .se(se), .si(), .so());
495
   assign fsm_ifc_errreq = err_pending;
496
 
497
   // Track secondary hits
498
   assign next_milchld[2] = ifc_fsm_hiton_thismil_s |    // hit on MIL by
499
                                                             // someone else
500
                                    fsm_ifc_milchld[2] & milstate[3]; // reset
501
 
502
   assign next_milchld[1:0] = ifc_fsm_hiton_thismil_s ? fcl_ifq_thr_s1 :
503
                                                                          fsm_ifc_milchld[1:0];
504
 
505
   dffr #(3) milchld_reg(.din  (next_milchld),
506
                                     .clk  (clk),
507
                                     .rst  (reset),
508
                                     .q    (local_milchld),
509
                                     .se   (se), .si(), .so());
510
 
511
   assign fsm_ifc_milchld[2] = local_milchld[2] & milstate[3];
512
   assign fsm_ifc_milchld[1:0] = local_milchld[1:0];
513
 
514
   assign milchld_valid = local_milchld[2] & milstate[3];
515
 
516
//   assign fsm_ifc_addrbit4_i2 = milstate[`MIL_F];
517
   assign fsm_ifc_addrbit4_i2 = milstate[0] & milstate[3] &
518
                                (milstate[1] | ifc_fsm_wr_complete_f);
519
 
520
   // determine if we want to fill from the first pkt or second pkt
521
   assign fill_this16b = ~(milstate[0] ^ ifc_fsm_miladdr4) |
522
                            ifd_ifc_4bpkt_i2;
523
 
524
   // write to thread inst reg (TIR)
525
//   assign fsm_ifc_wrt_tir =  (next_state[`MIL_F]) & ~cancel_mil & 
526
//                           ifc_fsm_fill_thisthr_i2;
527
   assign fsm_ifc_wrt_tir =  (milstate[3] & ~milstate[2]) &
528
                                                 ~(cancel_mil | ifc_fsm_can_thisthr) &
529
                               ifc_fsm_fill_thisthr_i2 &
530
                               fill_this16b;
531
 
532
   // write to Icache 
533
//   assign fsm_ifc_wrreq_i2 = ic_wrreq_i2;
534
   assign valid_i2 = milstate[3] & ~fsm_ifc_thr_ready;
535
 
536
   dff vld_ff(.din (valid_i2),
537
                    .q   (valid_d1),
538
                    .clk (clk),
539
                    .se  (se), .si(), .so());
540
 
541
   // signal thread completion
542
   assign fsm_ifc_thr_ready = milstate[3] & milstate[0] &
543
                              milstate[1] & ifc_fsm_wr_complete_f |
544
                              ~milstate[3] & valid_d1;
545
 
546
   // predict ready assuming 2nd ifill happens in the next cycle
547
   assign fsm_ifc_pred_rdy =  milstate[3] & milstate[0] &
548
                              (ifc_fsm_wr_complete_f |
549
                               milstate[1]); //  & ifc_fsm_fill_thisthr_i2
550
 
551
   // set compare valid for mil hit signal
552
   assign fsm_ifc_comp_valid = milstate[3] &     // valid entry
553
                                     ~milstate[0] &    // not f0 or f1
554
                               ~milchld_valid;        // no chld already
555
 
556
   assign fsm_ifc_mil_valid = milstate[3];
557
   assign fsm_ifc_mil_cancel = cancel_mil;
558
 
559
   // In the request state or if we need to send an error invalidate, 
560
   // ask for bus from LSU. 
561
//   assign fsm_ifc_pcxreq = (milstate[`MIL_V] & milstate[`MIL_R] |
562
//                          err_pending | ifc_fsm_err_thisthr) & 
563
//                         ~ifc_fsm_pcxaccept_thisthr & 
564
//                            (milchld_valid | ~cancel_mil);
565
 
566
//   assign fsm_ifc_pcxreq = (milstate[`MIL_V] & milstate[`MIL_R] & 
567
//                                ~ifc_fsm_pcxaccept_thisthr & 
568
//                            (milchld_valid | ~cancel_mil));
569
 
570
   // removed pcx_accept from critical path
571
   assign fsm_ifc_pcxreq = milstate[3] & milstate[2];
572
 
573
   assign fsm_ifc_milstate = milstate;
574
 
575
 
576
endmodule

powered by: WebSVN 2.1.0

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