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 113

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 113 albert.wat
`ifdef SIMPLY_RISC_TWEAKS
22
`define SIMPLY_RISC_SCANIN .si(0)
23
`else
24
`define SIMPLY_RISC_SCANIN .si()
25
`endif
26 95 fafa1971
////////////////////////////////////////////////////////////////////////
27
/*
28
//  Module Name: sparc_ifu_ifqdp
29
//  Description:
30
//  The IFQ is the icache fill queue.  This communicates between the
31
//  IFU and the outside world.  It handles icache misses and
32
//  invalidate requests from the crossbar.
33
*/
34
////////////////////////////////////////////////////////////////////////
35
// Global header file includes
36
////////////////////////////////////////////////////////////////////////
37
 
38 113 albert.wat
`include "ifu.h"
39 95 fafa1971
 
40
//`define MILFSM_NULL   4'b0000
41
//`define MILFSM_WAIT   4'b1000
42
//`define MILFSM_REQ    4'b1100
43
//`define MILFSM_FILL0  4'b1001
44
//`define MILFSM_FILL1  4'b1011
45
 
46
//`define MIL_V  3
47
//`define MIL_R  2
48
//`define MIL_A  1
49
//`define MIL_F  0
50
 
51
 
52
module sparc_ifu_milfsm(/*AUTOARG*/
53
   // Outputs
54
   so, fsm_ifc_errreq, fsm_ifc_wrt_tir, fsm_ifc_comp_valid,
55
   fsm_ifc_mil_valid, fsm_ifc_mil_cancel, fsm_ifc_thr_ready,
56
   fsm_ifc_pred_rdy, fsm_ifc_pcxreq, fsm_ifc_addrbit4_i2,
57
   fsm_ifc_milchld, fsm_ifc_milstate,
58
   // Inputs
59
   ifc_fsm_can_thisthr, ifc_fsm_fill_thisthr_i2,
60
   ifc_fsm_wr_complete_f, ifqadv_i2, ifd_ifc_4bpkt_i2,
61
   fcl_ifq_thr_s1, ifc_fsm_imiss_thisthr_s, ifc_fsm_milhit_s,
62
   ifc_fsm_hiton_thismil_s, ifc_fsm_pcxaccept_thisthr,
63
   ifc_fsm_miladdr4, clk, se, si, reset, ifc_fsm_err_thisthr
64
   );
65
 
66
   input       ifc_fsm_can_thisthr,
67
                     ifc_fsm_fill_thisthr_i2;
68
 
69
   input       ifc_fsm_wr_complete_f;
70
 
71
   input       ifqadv_i2;
72
 
73
   input       ifd_ifc_4bpkt_i2;
74
   input [1:0] fcl_ifq_thr_s1;
75
   input       ifc_fsm_imiss_thisthr_s;
76
   input       ifc_fsm_milhit_s;
77
         input       ifc_fsm_hiton_thismil_s,
78
               ifc_fsm_pcxaccept_thisthr;
79
   input       ifc_fsm_miladdr4;
80
 
81
   input       clk,
82
               se,
83
               si,
84
               reset;
85
 
86
   input       ifc_fsm_err_thisthr;
87
 
88
 
89
   output      so;
90
 
91
   output      fsm_ifc_errreq;
92
   output      fsm_ifc_wrt_tir;
93
 
94
   output      fsm_ifc_comp_valid,
95
                     fsm_ifc_mil_valid,
96
               fsm_ifc_mil_cancel,
97
                     fsm_ifc_thr_ready;
98
   output      fsm_ifc_pred_rdy,
99
                     fsm_ifc_pcxreq,
100
                     fsm_ifc_addrbit4_i2;
101
 
102
   output [2:0] fsm_ifc_milchld;
103
 
104
   output [3:0] fsm_ifc_milstate;
105
 
106
 
107
//----------------------------------------------------------------------
108
// Declarations
109
//----------------------------------------------------------------------
110
 
111
 
112
   // local variables
113
   reg [3:0]     next_state;
114
 
115
   wire [3:0]    milstate;
116
 
117
   wire [2:0]   local_milchld;
118
 
119
   wire         milchld_valid;
120
 
121
   wire   fill_this16b;
122
 
123
 
124
   wire         cancel_mil,
125
                      cancel_next;
126
   wire         err_pending,
127
                      err_pending_next;
128
 
129
   wire         valid_d1,
130
                valid_i2;
131
 
132
   wire [2:0]    next_milchld;
133
 
134
 
135
   // Missed Instruction List State Machine
136
   // 3   - valid
137
   // 2   - req
138
   // 1   - addr for fill fill (1/0)
139
   // 0   - fill
140
   //
141
   // 2   - child valid
142
   // 1:0 - child thr ptr
143
   //
144
 
145
 
146
   always @(/*AUTOSENSE*/err_pending or ifc_fsm_err_thisthr
147
            or ifc_fsm_fill_thisthr_i2 or ifc_fsm_imiss_thisthr_s
148
            or ifc_fsm_milhit_s or ifc_fsm_pcxaccept_thisthr
149
            or ifc_fsm_wr_complete_f or ifd_ifc_4bpkt_i2 or ifqadv_i2
150
            or milstate)
151
     begin
152
              case (milstate)  //  synopsys parallel_case
153
                4'b0000: // null
154
                  begin
155
                     //ic_wrreq_i2 = 1'b0;             
156
                     //  orphan_chld = 1'b0;
157
               next_state[1:0] = 2'b0;
158
               if (ifc_fsm_err_thisthr | ifc_fsm_imiss_thisthr_s)
159
                             begin
160 113 albert.wat
                                next_state[`MIL_V] = 1'b1;
161 95 fafa1971
                                if (ifc_fsm_milhit_s & ~ifc_fsm_err_thisthr)
162 113 albert.wat
                                  next_state[`MIL_R] = 1'b0;  // MILFSM_WAIT
163 95 fafa1971
                                else
164 113 albert.wat
                                  next_state[`MIL_R] = 1'b1;  // MILFSM_REQ;
165 95 fafa1971
                             end
166
                     else
167
                             next_state = milstate;
168
                  end // case: begin...
169
 
170
                4'b1100:  // req
171
                  begin
172
                     // ic_wrreq_i2 = 1'b0;             
173
                     // if canthr=1, the request will not be sent out in this cycle.
174
               if ((ifc_fsm_pcxaccept_thisthr) &
175
                   ~(ifc_fsm_err_thisthr | err_pending))
176
                 // two requests are made when there is an error.
177
                 // one, with errbit=1 gets back in invalidate response, 
178
                 // the other, with errbit=0, gets the regular ifill 
179
                 // return
180
                             begin
181
                                // we invalidate the icache on detecting an error
182
                                // only if this wasn't an MIL hit as well.  If it
183
                                // was an MIL we would have gone to the wait state
184
                                // already and it is too late to invalidate the cache
185 113 albert.wat
                                next_state = `MILFSM_WAIT;
186 95 fafa1971
                    //              orphan_chld = 1'b0;             
187
                             end
188
//                   else if ((cancel_mil | ifc_fsm_can_thisthr) & 
189
//                        ~milchld_valid & ~ifc_fsm_hiton_thismil_s)
190
//                           begin
191
//                              next_state = `MILFSM_NULL;
192
//                           end
193
                     else
194
                             begin
195
                                next_state = milstate;
196
                    //              orphan_chld = 1'b0;
197
                             end
198
                  end // case: 4'b1100
199
 
200
                4'b1000: // wait
201
                  begin
202
               //              orphan_chld = 1'b0;
203
                     if (ifc_fsm_fill_thisthr_i2)
204
                             begin
205
                                // ic_wrreq_i2 = 1'b1;
206
                    if (ifd_ifc_4bpkt_i2 & ifqadv_i2) // 4B ifill from IOB
207
                      // don't want to advance too quickly and get fasle compl
208 113 albert.wat
                      next_state = `MILFSM_NULL;
209 95 fafa1971
                    else if (~ifd_ifc_4bpkt_i2)
210 113 albert.wat
                                  next_state = `MILFSM_FILL0;
211 95 fafa1971
                    else
212
                      next_state = milstate;
213
                             end
214
                     else
215
                             begin
216
                                next_state = milstate;
217
                                //ic_wrreq_i2 = 1'b0;               
218
                             end
219
                  end // case: 4'b1000
220
 
221
                4'b1001: // fill0
222
                  begin
223
               //              orphan_chld = 1'b0;
224
               if (ifc_fsm_wr_complete_f)
225
                             begin
226 113 albert.wat
                                next_state = `MILFSM_FILL1;
227 95 fafa1971
                                //ic_wrreq_i2 = 1'b1;
228
                             end
229
                     else
230
                             begin
231
                                next_state = milstate;
232
                                //ic_wrreq_i2 = 1'b1;
233
                             end
234
                  end // case: 4'b1001
235
 
236
                4'b1011: // fill1
237
                  // Do we really need this state??  yes, to start thr
238
                  begin
239
               //              orphan_chld = 1'b0;                  
240
                     if (ifc_fsm_wr_complete_f)
241
                             begin
242
                                //ic_wrreq_i2 = 1'b0;               
243
                    //              if (delay_mil | ifc_fsm_imiss_thisthr_s)
244
                    //                next_state = `MILFSM_REQ;
245
                    //              else
246 113 albert.wat
                                next_state = `MILFSM_NULL;
247 95 fafa1971
                             end
248
                     else
249
                             begin
250
                                //ic_wrreq_i2 = 1'b1;
251
                                next_state = milstate;
252
                             end // else: !if(ifc_fsm_wr_complete_f)
253
                  end // case: 4'b10001
254
 
255
                default:
256
                  begin
257
               // synopsys translate_off
258
                     // 0in <fire -message "MILSTATE, Error: SPARC/IFU/MILFSM: unknown state!"
259 113 albert.wat
`ifdef DEFINE_0IN
260
`else
261
               if ($time > (4* `CMP_CLK_PERIOD))
262 95 fafa1971
                 begin
263 113 albert.wat
                                `ifdef MODELSIM
264
                                          $display ("MILSTATE",
265 95 fafa1971
                            "Error: SPARC/IFU/MILFSM: unknown state! %b\n",milstate);
266 113 albert.wat
                                `else
267
                          $error ("MILSTATE",
268
                            "Error: SPARC/IFU/MILFSM: unknown state! %b\n",milstate);
269
                                `endif
270 95 fafa1971
                 end
271 113 albert.wat
`endif
272 95 fafa1971
               // synopsys translate_on               
273
                     next_state = milstate;
274
                     //ic_wrreq_i2 = 1'b0;                  
275
               //              orphan_chld = 1'b0;      
276
                  end // case: default
277
              endcase // casex(milstate)
278
     end // always @ (...
279
 
280
 
281
   // MIL state reg
282 113 albert.wat
   dffr_s #(4) milst_reg(.din  (next_state[3:0]),
283 95 fafa1971
                                   .q    (milstate[3:0]),
284
                                   .clk  (clk),
285
                                   .rst  (reset),
286 113 albert.wat
                                   .se   (se), `SIMPLY_RISC_SCANIN, .so());
287 95 fafa1971
 
288
   // Cancel - Delay state machine
289
   // -- not used anymore
290
   // C D
291
   // 0 0  - null
292
   // 1 0  - current thread cancelled but pending from L2
293
   // 1 1  - one ifill pending from L2, current thread will be sent
294
   //        out after that.
295
 
296
//   assign cancel_next = (ifc_fsm_can_thisthr | 
297
//                                         cancel_mil) & next_state[`MIL_V];    // reset wins
298
 
299
   assign cancel_next = (ifc_fsm_can_thisthr | cancel_mil) &
300 113 albert.wat
                          (milstate[`MIL_V] | ifc_fsm_imiss_thisthr_s |
301 95 fafa1971
                           ifc_fsm_err_thisthr);    // reset wins
302
 
303 113 albert.wat
   dffr_s #(1) can_ff(.din  (cancel_next),
304 95 fafa1971
                                .q    (cancel_mil),
305
                                .clk  (clk),
306
                                .rst  (reset),
307 113 albert.wat
                                .se   (se), `SIMPLY_RISC_SCANIN, .so());
308 95 fafa1971
 
309
   // track if we need to send out an error request
310
   assign err_pending_next = (ifc_fsm_err_thisthr &
311 113 albert.wat
                              (milstate[`MIL_R] | ~milstate[`MIL_V]) |
312 95 fafa1971
//                            err_pending & next_state[`MIL_V]) &       
313 113 albert.wat
                        err_pending & milstate[`MIL_V]) &
314 95 fafa1971
                              ~ifc_fsm_pcxaccept_thisthr;
315
                         // & ~ifc_fsm_can_thisthr;
316
 
317 113 albert.wat
   dffr_s #(1) err_ff(.din (err_pending_next),
318 95 fafa1971
                                .q   (err_pending),
319
                                .clk (clk),
320 113 albert.wat
                                .rst (reset), .se(se), `SIMPLY_RISC_SCANIN, .so());
321 95 fafa1971
   assign fsm_ifc_errreq = err_pending;
322
 
323
   // Track secondary hits
324
   assign next_milchld[2] = ifc_fsm_hiton_thismil_s |    // hit on MIL by
325
                                                             // someone else
326 113 albert.wat
                                    fsm_ifc_milchld[2] & milstate[`MIL_V]; // reset
327 95 fafa1971
 
328
   assign next_milchld[1:0] = ifc_fsm_hiton_thismil_s ? fcl_ifq_thr_s1 :
329
                                                                          fsm_ifc_milchld[1:0];
330
 
331 113 albert.wat
   dffr_s #(3) milchld_reg(.din  (next_milchld),
332 95 fafa1971
                                     .clk  (clk),
333
                                     .rst  (reset),
334
                                     .q    (local_milchld),
335 113 albert.wat
                                     .se   (se), `SIMPLY_RISC_SCANIN, .so());
336 95 fafa1971
 
337 113 albert.wat
   assign fsm_ifc_milchld[2] = local_milchld[2] & milstate[`MIL_V];
338 95 fafa1971
   assign fsm_ifc_milchld[1:0] = local_milchld[1:0];
339
 
340 113 albert.wat
   assign milchld_valid = local_milchld[2] & milstate[`MIL_V];
341 95 fafa1971
 
342
//   assign fsm_ifc_addrbit4_i2 = milstate[`MIL_F];
343 113 albert.wat
   assign fsm_ifc_addrbit4_i2 = milstate[`MIL_F] & milstate[`MIL_V] &
344
                                (milstate[`MIL_A] | ifc_fsm_wr_complete_f);
345 95 fafa1971
 
346
   // determine if we want to fill from the first pkt or second pkt
347 113 albert.wat
   assign fill_this16b = ~(milstate[`MIL_F] ^ ifc_fsm_miladdr4) |
348 95 fafa1971
                            ifd_ifc_4bpkt_i2;
349
 
350
   // write to thread inst reg (TIR)
351
//   assign fsm_ifc_wrt_tir =  (next_state[`MIL_F]) & ~cancel_mil & 
352
//                           ifc_fsm_fill_thisthr_i2;
353 113 albert.wat
   assign fsm_ifc_wrt_tir =  (milstate[`MIL_V] & ~milstate[`MIL_R]) &
354 95 fafa1971
                                                 ~(cancel_mil | ifc_fsm_can_thisthr) &
355
                               ifc_fsm_fill_thisthr_i2 &
356
                               fill_this16b;
357
 
358
   // write to Icache 
359
//   assign fsm_ifc_wrreq_i2 = ic_wrreq_i2;
360 113 albert.wat
   assign valid_i2 = milstate[`MIL_V] & ~fsm_ifc_thr_ready;
361 95 fafa1971
 
362 113 albert.wat
   dff_s vld_ff(.din (valid_i2),
363 95 fafa1971
                    .q   (valid_d1),
364
                    .clk (clk),
365 113 albert.wat
                    .se  (se), `SIMPLY_RISC_SCANIN, .so());
366 95 fafa1971
 
367
   // signal thread completion
368 113 albert.wat
   assign fsm_ifc_thr_ready = milstate[`MIL_V] & milstate[`MIL_F] &
369
                              milstate[`MIL_A] & ifc_fsm_wr_complete_f |
370
                              ~milstate[`MIL_V] & valid_d1;
371 95 fafa1971
 
372
   // predict ready assuming 2nd ifill happens in the next cycle
373 113 albert.wat
   assign fsm_ifc_pred_rdy =  milstate[`MIL_V] & milstate[`MIL_F] &
374 95 fafa1971
                              (ifc_fsm_wr_complete_f |
375 113 albert.wat
                               milstate[`MIL_A]); //  & ifc_fsm_fill_thisthr_i2
376 95 fafa1971
 
377
   // set compare valid for mil hit signal
378 113 albert.wat
   assign fsm_ifc_comp_valid = milstate[`MIL_V] &     // valid entry
379
                                     ~milstate[`MIL_F] &    // not f0 or f1
380 95 fafa1971
                               ~milchld_valid;        // no chld already
381
 
382 113 albert.wat
   assign fsm_ifc_mil_valid = milstate[`MIL_V];
383 95 fafa1971
   assign fsm_ifc_mil_cancel = cancel_mil;
384
 
385
   // In the request state or if we need to send an error invalidate, 
386
   // ask for bus from LSU. 
387
//   assign fsm_ifc_pcxreq = (milstate[`MIL_V] & milstate[`MIL_R] |
388
//                          err_pending | ifc_fsm_err_thisthr) & 
389
//                         ~ifc_fsm_pcxaccept_thisthr & 
390
//                            (milchld_valid | ~cancel_mil);
391
 
392
//   assign fsm_ifc_pcxreq = (milstate[`MIL_V] & milstate[`MIL_R] & 
393
//                                ~ifc_fsm_pcxaccept_thisthr & 
394
//                            (milchld_valid | ~cancel_mil));
395
 
396
   // removed pcx_accept from critical path
397 113 albert.wat
   assign fsm_ifc_pcxreq = milstate[`MIL_V] & milstate[`MIL_R];
398 95 fafa1971
 
399
   assign fsm_ifc_milstate = milstate;
400
 
401
 
402
endmodule

powered by: WebSVN 2.1.0

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