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

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [core/] [ds_dma64/] [pcie_src/] [pcie_core64_m1/] [source/] [pcie_blk_cf_err.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
 
2
//-----------------------------------------------------------------------------
3
//
4
// (c) Copyright 2009-2010 Xilinx, Inc. All rights reserved.
5
//
6
// This file contains confidential and proprietary information
7
// of Xilinx, Inc. and is protected under U.S. and
8
// international copyright and other intellectual property
9
// laws.
10
//
11
// DISCLAIMER
12
// This disclaimer is not a license and does not grant any
13
// rights to the materials distributed herewith. Except as
14
// otherwise provided in a valid license issued to you by
15
// Xilinx, and to the maximum extent permitted by applicable
16
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
17
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
18
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
19
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
20
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
21
// (2) Xilinx shall not be liable (whether in contract or tort,
22
// including negligence, or under any other theory of
23
// liability) for any loss or damage of any kind or nature
24
// related to, arising under or in connection with these
25
// materials, including for any direct, or any indirect,
26
// special, incidental, or consequential loss or damage
27
// (including loss of data, profits, goodwill, or any type of
28
// loss or damage suffered as a result of any action brought
29
// by a third party) even if such damage or loss was
30
// reasonably foreseeable or Xilinx had been advised of the
31
// possibility of the same.
32
//
33
// CRITICAL APPLICATIONS
34
// Xilinx products are not designed or intended to be fail-
35
// safe, or for use in any application requiring fail-safe
36
// performance, such as life-support or safety devices or
37
// systems, Class III medical devices, nuclear facilities,
38
// applications related to the deployment of airbags, or any
39
// other applications that could lead to death, personal
40
// injury, or severe property or environmental damage
41
// (individually and collectively, "Critical
42
// Applications"). Customer assumes the sole risk and
43
// liability of any use of Xilinx products in Critical
44
// Applications, subject only to applicable laws and
45
// regulations governing limitations on product liability.
46
//
47
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
48
// PART OF THIS FILE AT ALL TIMES.
49
//
50
//-----------------------------------------------------------------------------
51
// Project    : V5-Block Plus for PCI Express
52
// File       : pcie_blk_cf_err.v
53
//--------------------------------------------------------------------------------
54
//--------------------------------------------------------------------------------
55
//--
56
//-- Description: Error Manager. This module will generate error messages to be
57
//--  sent by the Tx block, and it will set appropriate error bits in register
58
//--  space.
59
//--
60
//--------------------------------------------------------------------------------
61
 
62
`ifndef Tcq
63
  `define Tcq 1
64
`endif
65
 
66
`timescale 1ns/1ns
67
 
68
module pcie_blk_cf_err
69
(
70
       // PCIe Block clock and reset
71
 
72
       input wire         clk,
73
       input wire         rst_n,
74
 
75
       // PCIe Soft Macro Cfg Interface
76
 
77
       input              cfg_err_cor_n,
78
       input              cfg_err_ur_n,
79
       input              cfg_err_ecrc_n,
80
       input              cfg_err_cpl_timeout_n,
81
       input              cfg_err_cpl_abort_n,
82
       input              cfg_err_cpl_unexpect_n,
83
       input              cfg_err_posted_n,
84
       input              cfg_err_locked_n,
85
       input       [47:0] cfg_err_tlp_cpl_header,
86
       output             cfg_err_cpl_rdy_n,
87
 
88
       // Rx/Tx indicates Poisoned TLP
89
       input              rx_err_cpl_ep_n, //Rx Completion
90
       input              tx_err_wr_ep_n,  //Tx Write
91
       input              rx_err_ep_n,     //Any
92
       input              rx_err_tlp_poisoned_n,
93
 
94
       // Rx indicates Competion Abort
95
       input              rx_err_cpl_abort_n,
96
 
97
       // Rx indicates Unsupported Request
98
       input              rx_err_cpl_ur_n,
99
       input              rx_err_tlp_ur_n,      //Bar miss, format problem
100
       input              rx_err_tlp_ur_lock_n, //UR due to Lock
101
       input              rx_err_tlp_p_cpl_n,
102
 
103
       // Rx indicates Malformed packet
104
       input              rx_err_tlp_malformed_n,
105
 
106
       // Header info from Rx
107
       input       [47:0] rx_err_tlp_hdr,
108
 
109
       // Output to Tx Block (via arbiter) to generate message/UR Completions
110
       output reg         send_cor  = 0,
111
       output reg         send_nfl  = 0,
112
       output reg         send_ftl  = 0,
113
       output reg         send_cplt = 0,
114
       output reg         send_cplu = 0,
115
       output wire [49:0] cmt_rd_hdr,
116
       output wire [49:0] cfg_rd_hdr,
117
       input  wire [49:0] request_data,
118
       input              grant,
119
       input              cs_is_cplu,
120
       input              cs_is_cplt,
121
       input              cs_is_cor,
122
       input              cs_is_nfl,
123
       input              cs_is_ftl,
124
 
125
       // Input from the PCIe Block
126
       input        [6:0] l0_dll_error_vector,
127
       input        [1:0] l0_rx_mac_link_error,
128
       input              l0_mac_link_up,
129
 
130
       // Output to PCIe Block, to set 
131
       output wire        l0_set_unsupported_request_other_error,
132
       output wire        l0_set_detected_fatal_error,
133
       output wire        l0_set_detected_nonfatal_error,
134
       output wire        l0_set_detected_corr_error,
135
       output wire        l0_set_user_system_error,
136
       output wire        l0_set_user_master_data_parity,
137
       output wire        l0_set_user_signaled_target_abort,
138
       output wire        l0_set_user_received_target_abort,
139
       output wire        l0_set_user_received_master_abort,
140
       output wire        l0_set_user_detected_parity_error,
141
 
142
       // Inputs fromthe Shadow Registers
143
       input       [15:0] cfg_dcommand,
144
       input       [15:0] cfg_command,
145
 
146
       // Inputs from the PCIe Block
147
       input              serr_en
148
);
149
 
150
  parameter UR = 1'b0,
151
            CA = 1'b1;
152
 
153
  wire decr_cplu;
154
  wire decr_cplt;
155
  wire decr_cor;
156
  wire decr_nfl;
157
  wire decr_ftl;
158
 
159
  wire tlp_posted;
160
  wire cfg_posted;
161
 
162
  wire tlp_is_np_and_ur;
163
  wire cfg_is_np_and_ur;
164
  wire cfg_is_np_and_cpl_abort, cfg_is_p_and_cpl_abort, cfg_is_p_and_cpl_abort_and_send_nfl;
165
 
166
  wire masterdataparityerror;
167
  wire signaledtargetabort;
168
  wire receivedtargetabort;
169
  wire receivedmasterabort;
170
  wire detectedparityerror;
171
  wire signaledsystemerror;
172
  wire unsupportedreq;
173
  wire detectedfatal;
174
  wire detectednonfatal;
175
  wire detectedcorrectable;
176
 
177
  wire    [3:0] cnt_cplt;
178
  wire    [3:0] cnt_cplu;
179
  wire    [3:0] cnt_ftl;
180
  wire    [3:0] cnt_nfl;
181
  wire    [3:0] cnt_cor;
182
 
183
  wire   [49:0] cmt_wr_hdr;
184
  wire   [49:0] cfg_wr_hdr;
185
 
186
  wire          incr_cplu, incr_cplt;
187
 
188
 
189
  reg    [49:0] reg_cmt_wr_hdr;
190
  reg    [49:0] reg_cfg_wr_hdr;
191
 
192
  reg     [3:0] cs_fsm;  // current state
193
 
194
  reg     [1:0] reg_cmt_wp, reg_cmt_rp;
195
  reg     [2:0] reg_cfg_wp, reg_cfg_rp;
196
 
197
  reg           reg_masterdataparityerror;
198
  reg           reg_signaledtargetabort;
199
  reg           reg_receivedtargetabort;
200
  reg           reg_receivedmasterabort;
201
  reg           reg_detectedparityerror;
202
  reg           reg_signaledsystemerror;
203
  reg           reg_detectedcorrectable;
204
  reg           reg_detectedfatal;
205
  reg           reg_detectednonfatal;
206
  reg           reg_unsupportedreq;
207
 
208
 
209
  reg           reg_incr_cplu, reg_incr_cplt;
210
 
211
  wire    [2:0] cor_num_int;
212
  wire    [2:0] cor_num;
213
  wire    [2:0] ftl_num;
214
  wire    [2:0] nfl_num_int;
215
  wire    [2:0] nfl_num;
216
  wire    [2:0] cplt_num;
217
  wire    [2:0] cplu_num;
218
  wire    [1:0] cmt_wp;
219
  wire    [1:0] cmt_rp;
220
  wire    [2:0] cfg_wp;
221
  wire    [2:0] cfg_rp;
222
 
223
  wire          reg_decr_nfl;
224
  wire          reg_decr_cor;
225
 
226
  //******************************************************************//
227
  // Decode the error report masking capabilities and error severity. //
228
  //******************************************************************//
229
  wire serr_en_cmd = cfg_command[8];
230
 
231
  wire [3:0] x_dcmd = cfg_dcommand[3:0];
232
  wire err_cor_en = x_dcmd[0];
233
  wire err_nfl_en = x_dcmd[1] | serr_en_cmd;
234
  wire err_ftl_en = x_dcmd[2] | serr_en_cmd;
235
  wire err_ur_en  = x_dcmd[3];
236
  wire err_ur_nfl_en  = x_dcmd[3] & x_dcmd[1];
237
 
238
  //******************************************************************//
239
  // ??? Need to drive these signals when errors are detected. ???    //
240
  // There is no clear instruction in the PCI Express Base Spec,      //
241
  // Rev. 1.0 how the PCI Express errors are mapped to PCI errors,    //
242
  // all the following PCI error reporting signals are tied to logic  //
243
  // zero until further clarify by the PCI SIG. (7/2/02)              //
244
  //******************************************************************//
245
 
246
  always @(posedge clk) begin
247
    if (~rst_n)
248
      reg_signaledsystemerror <= #`Tcq 1'b0;
249
    else if (serr_en_cmd & grant)
250
        // If NFL message is sent 'cos of a NP UR.
251
      if ((request_data[48] == UR) && (cs_is_cplu || cs_is_cplt) && grant && err_ur_en)
252
        reg_signaledsystemerror <= #`Tcq 1'b1;
253
        // If NFL message is sent 'cos of a P UR 
254
      else if (cs_is_cplu)
255
        reg_signaledsystemerror <= #`Tcq 1'b1;
256
        // If NFL | FTL message is sent 'cos of ERROR Non-Fatal | Fatal
257
      else if (cs_is_nfl|cs_is_ftl)
258
        reg_signaledsystemerror <= #`Tcq 1'b1;
259
      else
260
        reg_signaledsystemerror <= #`Tcq 1'b0;
261
    else
262
      reg_signaledsystemerror <= #`Tcq 1'b0;
263
  end
264
 
265
  wire parity_err_resp = cfg_command[6];
266
 
267
  always @(posedge clk) begin
268
    if (~rst_n) begin
269
      reg_masterdataparityerror <= #`Tcq 1'b0;
270
      reg_signaledtargetabort   <= #`Tcq 1'b0;
271
      reg_receivedtargetabort   <= #`Tcq 1'b0;
272
      reg_receivedmasterabort   <= #`Tcq 1'b0;
273
      reg_detectedparityerror   <= #`Tcq 1'b0;
274
      reg_detectedcorrectable   <= #`Tcq 1'b0;
275
      reg_detectedfatal         <= #`Tcq 1'b0;
276
      reg_detectednonfatal      <= #`Tcq 1'b0;
277
      reg_unsupportedreq        <= #`Tcq 1'b0;
278
    end
279
    else begin
280
        // This bit is set by Requestor if the Parity Error Enable
281
        // bit is set and either of the following two conditions occurs:
282
        //   --> Requestor receives completion marked poisoned
283
        //   --> Requestor poisons a write Request
284
        // If the Parity Error Enable bit is cleared, this bit is never set.
285
        // Default value of this field is 0.
286
      reg_masterdataparityerror <= #`Tcq parity_err_resp ? (~rx_err_cpl_ep_n | ~tx_err_wr_ep_n) : 1'b0;
287
 
288
      // This bit is set when the device completes a Request using completer Abort completion Status 
289
      // Default value of this field is 0.
290
      reg_signaledtargetabort <= #`Tcq  cfg_is_np_and_cpl_abort;
291
 
292
      // This bit is set when a Requestor receives a Completion with completer Abort completion Status 
293
      // Default value of this field is 0.
294
      reg_receivedtargetabort <= #`Tcq ~rx_err_cpl_abort_n;
295
 
296
      // This bit is set when a Requestor receives a completion with Unsupported Request completion status 
297
      // Default value of this field is 0.
298
      reg_receivedmasterabort <= #`Tcq ~rx_err_cpl_ur_n;
299
 
300
      // This bit is set by a device whenever it receives  a Poisoned TLP, regardless of the state of 
301
      // the Parity Error Enable bit.
302
      // Default value of this field is 0.
303
      reg_detectedparityerror <= #`Tcq ~rx_err_ep_n;
304
 
305
 
306
      // Refer Sec 6.2.6 Error Listing Rules for this classification
307
      reg_detectedcorrectable <= #`Tcq   ~cfg_err_cor_n;
308
 
309
      reg_detectedfatal       <= #`Tcq    ~rx_err_tlp_malformed_n;
310
 
311
      //Modified to NFL, other than UR or Posted Completer Abort
312
      reg_detectednonfatal    <= #`Tcq  ~cfg_err_ecrc_n |                              // Not a AFE, User detects a ECRC error for a TLP
313
                                        ~cfg_err_cpl_timeout_n;                        // Not a ANFE, User detects that Cpln has not arrived
314
 
315
      reg_unsupportedreq      <= #`Tcq  (~rx_err_tlp_ur_n & ~rx_err_tlp_p_cpl_n) |
316
                                        (~cfg_err_ur_n & ~cfg_err_posted_n) ;          // Not a ANFE, User detects a UR for a posted TLP
317
                                                                                       // so send a NFL message and record the UR in the
318
                                                                                       // status here.
319
    end
320
  end
321
 
322
 
323
  // Instantiate the error count-up/count-down modules
324
  // Correctible error handling: parse, count, send_request through a priorotised arbiter
325
  cmm_errman_cor  wtd_cor (
326
                 .cor_num                (cor_num_int)
327
                ,.inc_dec_b              (cor_add_sub_b)
328
                ,.reg_decr_cor           (reg_decr_cor)
329
                ,.add_input_one          (1'b0) //l0_rx_mac_link_error[1] & l0_mac_link_up)
330
                ,.add_input_two_n        (1'b1) //~l0_dll_error_vector[2])
331
                ,.add_input_three_n      (1'b1) //~l0_dll_error_vector[3])
332
                ,.add_input_four_n       (1'b1) //~l0_dll_error_vector[1])
333
                ,.add_input_five_n       (1'b1) //~l0_dll_error_vector[0])
334
                ,.add_input_six_n        (1'b1) ////cfg_err_cor_n)
335
                ,.decr_cor               (decr_cor)
336
                ,.rst                    (~rst_n)
337
                ,.clk                    (clk)
338
                );
339
 
340
  assign cor_num = cor_num_int - reg_decr_cor;
341
 
342
  cmm_errman_cnt_en  cor_cntr (
343
                 .count      (cnt_cor)
344
                ,.index      (cor_num)
345
                ,.inc_dec_b  (cor_add_sub_b)
346
                ,.enable     (err_cor_en)
347
                ,.rst        (~rst_n)
348
                ,.clk        (clk)
349
                );
350
 
351
 
352
 
353
  // Non-Fatal error handling: parse, count, send_request through a priorotised arbiter
354
  cmm_errman_cor  wtd_nfl (
355
                 .cor_num                (nfl_num_int)
356
                ,.inc_dec_b              (nfl_add_sub_b)
357
                ,.reg_decr_cor           (reg_decr_nfl)
358
                                            // Posted TLP that causes a UR, the NFL message is sent if
359
                                            // the UR&NFL are enabled together, or if the SERR is enabled.
360
                                            // Ref: Fig6-2, PCIe Base Spec v1.1
361
                ,.add_input_one          (1'b0)////~rx_err_tlp_ur_n & ~rx_err_tlp_p_cpl_n & (err_ur_nfl_en | serr_en) )
362
                ,.add_input_two_n        (1'b1)////err_nfl_en ? cfg_err_cpl_timeout_n : 1'b1)
363
                ,.add_input_three_n      (err_nfl_en ? rx_err_tlp_poisoned_n : 1'b1)
364
                ,.add_input_four_n       (1'b1)////err_nfl_en ? cfg_err_ecrc_n : 1'b1)
365
                ,.add_input_five_n       (1'b1)////~(~cfg_err_ur_n & ~cfg_err_posted_n & (err_ur_nfl_en|serr_en)))
366
                ,.add_input_six_n        (1'b1)
367
                ,.decr_cor               (decr_nfl)
368
                ,.rst                    (~rst_n)
369
                ,.clk                    (clk)
370
                );
371
 
372
  assign nfl_num = nfl_num_int - reg_decr_nfl;
373
 
374
  cmm_errman_cnt_en  nfl_cntr (
375
                 .count      (cnt_nfl)
376
                ,.index      (nfl_num)
377
                ,.inc_dec_b  (nfl_add_sub_b)
378
                ,.enable     (1'b1)
379
                ,.rst        (~rst_n)
380
                ,.clk        (clk)
381
                );
382
 
383
  // Fatal error handling: parse, count, send_request through a priorotised arbiter
384
  cmm_errman_ftl  wtd_ftl (
385
                 .ftl_num                   (ftl_num)
386
                ,.inc_dec_b                 (ftl_add_sub_b)
387
                ,.cmmp_training_err         (1'b0)
388
                ,.cmml_protocol_err_n       (1'b1) //~l0_dll_error_vector[6])
389
                ,.cmmt_err_rbuf_overflow    (1'b0)
390
                ,.cmmt_err_fc               (1'b0)
391
                ,.cmmt_err_tlp_malformed    (1'b0)
392
                ,.decr_ftl                  (decr_ftl)
393
                ,.rst                       (~rst_n)
394
                ,.clk                       (clk)
395
                );
396
 
397
  cmm_errman_cnt_en  ftl_cntr (
398
                 .count      (cnt_ftl)
399
                ,.index      (ftl_num)
400
                ,.inc_dec_b  (ftl_add_sub_b)
401
                ,.enable     (err_ftl_en)
402
                ,.rst        (~rst_n)
403
                ,.clk        (clk)
404
                );
405
 
406
 
407
 
408
  // Completion-Abort/Unsupported-Request TLM error handling: parse, count, send_request through a priorotised arbiter
409
  cmm_errman_cpl  wtd_cplt (
410
                 .cpl_num               (cplt_num)
411
                ,.inc_dec_b             (cplt_add_sub_b)
412
                ,.cmm_err_tlp_posted    (tlp_posted)
413
                ,.decr_cpl              (decr_cplt)
414
                ,.rst                   (~rst_n)
415
                ,.clk                   (clk)
416
                );
417
 
418
  cmm_errman_cnt_en  cplt_cntr (                // one counter for TLM
419
                 .count      (cnt_cplt)
420
                ,.index      (cplt_num)
421
                ,.inc_dec_b  (cplt_add_sub_b)
422
                ,.enable     (1'b1)             // always enable Cpl response
423
                ,.rst        (~rst_n)
424
                ,.clk        (clk)
425
                );
426
 
427
 
428
  // Completion-Abort/Unsupported-Request USER error handling: parse, count, send_request through a priorotised arbiter
429
  cmm_errman_cpl  wtd_cplu (
430
                 .cpl_num               (cplu_num)
431
                ,.inc_dec_b             (cplu_add_sub_b)
432
                ,.cmm_err_tlp_posted    (cfg_posted)
433
                ,.decr_cpl              (decr_cplu)
434
                ,.rst                   (~rst_n)
435
                ,.clk                   (clk)
436
                );
437
 
438
  cmm_errman_cnt_en  cplu_cntr (                // one counter for User
439
                 .count      (cnt_cplu)
440
                ,.index      (cplu_num)
441
                ,.inc_dec_b  (cplu_add_sub_b)
442
                ,.enable     (1'b1)             // always enable Cpl response
443
                ,.rst        (~rst_n)
444
                ,.clk        (clk)
445
                );
446
 
447
 
448
 
449
  always @(posedge clk) begin
450
    if (~rst_n) begin
451
      send_cor  <= #`Tcq 1'b0;
452
      send_nfl  <= #`Tcq 1'b0;
453
      send_ftl  <= #`Tcq 1'b0;
454
      send_cplt <= #`Tcq 1'b0;
455
      send_cplu <= #`Tcq 1'b0;
456
    end
457
    else  begin
458
      send_cor  <= #`Tcq |cnt_cor;
459
      send_nfl  <= #`Tcq |cnt_nfl;
460
      send_ftl  <= #`Tcq |cnt_ftl;
461
      send_cplt <= #`Tcq |cnt_cplt;
462
      send_cplu <= #`Tcq |cnt_cplu;
463
    end
464
  end
465
 
466
 
467
 
468
  // Store the header information into FIFO
469
  always @(posedge clk) begin
470
    if (~rst_n)
471
      reg_cmt_wr_hdr <= #`Tcq 50'h0000_0000_0000;
472
    else  begin
473
        // If UR 
474
      if (tlp_is_np_and_ur)
475
        reg_cmt_wr_hdr <= #`Tcq {rx_err_tlp_ur_lock_n,UR,  // Locked status, UR
476
                                 rx_err_tlp_hdr[47:0]};    // Lower-Addr + Byte-Count + TC + Attr + Req-ID + Tag
477
      else
478
        reg_cmt_wr_hdr <= #`Tcq 0;
479
    end
480
  end
481
 
482
 
483
  // Store the header information into FIFO
484
  always @(posedge clk) begin
485
    if (~rst_n)
486
      reg_cfg_wr_hdr <= #`Tcq 50'h0000_0000_0000;
487
    else  begin
488
      if (cfg_is_np_and_ur)
489
        reg_cfg_wr_hdr <= #`Tcq {cfg_err_locked_n,     UR,       // Locked status, UR
490
                                 cfg_err_tlp_cpl_header[47:0]};  // Lower-Addr + Byte-Count + TC + Attr + Req-ID + Tag
491
      else if (cfg_is_np_and_cpl_abort)
492
        reg_cfg_wr_hdr <= #`Tcq {cfg_err_locked_n,     CA,       // Locked status, CA
493
                                 cfg_err_tlp_cpl_header[47:0]};  // Lower-Addr + Byte-Count + TC + Attr + Req-ID + Tag
494
      else
495
        reg_cfg_wr_hdr <= #`Tcq 0;
496
    end
497
  end
498
 
499
  assign  cmt_wr_hdr = reg_cmt_wr_hdr;
500
  assign  cfg_wr_hdr = reg_cfg_wr_hdr;
501
 
502
 
503
 
504
 
505
 
506
  // Pipeline the completion request signals
507
  always @(posedge clk)
508
    if (~rst_n) begin
509
      reg_incr_cplu <= #`Tcq 1'b0;
510
      reg_incr_cplt <= #`Tcq 1'b0;
511
    end
512
    else begin
513
      reg_incr_cplu <= #`Tcq cfg_posted;
514
      reg_incr_cplt <= #`Tcq tlp_posted;
515
    end
516
 
517
 
518
  assign incr_cplu = reg_incr_cplu;
519
  assign incr_cplt = reg_incr_cplt;
520
 
521
  always @(posedge clk) begin
522
    if (~rst_n)                 reg_cmt_wp <= #`Tcq 2'b00;
523
    else if (incr_cplt)         reg_cmt_wp <= #`Tcq cmt_wp + 2'b01;
524
  end
525
 
526
  always @(posedge clk) begin
527
    if (~rst_n)                 reg_cfg_wp <= #`Tcq 3'b000;
528
    else if (incr_cplu)         reg_cfg_wp <= #`Tcq cfg_wp + 3'b001;
529
  end
530
 
531
 
532
  always @(posedge clk) begin
533
    if (~rst_n)                   reg_cmt_rp <= #`Tcq 2'b00;
534
    else if (cs_is_cplt & grant)  reg_cmt_rp <= #`Tcq cmt_rp + 2'b01;
535
  end
536
 
537
  always @(posedge clk) begin
538
    if (~rst_n)                   reg_cfg_rp <= #`Tcq 3'b000;
539
    else if (cs_is_cplu & grant)  reg_cfg_rp <= #`Tcq cfg_rp + 3'b001;
540
  end
541
 
542
  assign cmt_wp  = reg_cmt_wp;
543
  assign cfg_wp  = reg_cfg_wp;
544
  assign cmt_rp  = reg_cmt_rp;
545
  assign cfg_rp  = reg_cfg_rp;
546
 
547
  //******************************************************************//
548
  // Instantiate two 4-deep, 50-bit wide buffers to store the header //
549
  // information of the outstanding completion packets. One buffer    //
550
  // for the requests from the TLM (cmmt_* ports) and one for the     //
551
  // requests from the user (cfg_* ports).                            //
552
  // The buffer is implemented with RAM16X1D primitives and the       //
553
  // read data output is registered.                                  //
554
  // The write and read pointers to the header buffer are separately  //
555
  // advanced by the FSM. Pointer wraps around if overflow. Both the  //
556
  // write and read pointers are not managed (e.g. if there are 16    //
557
  // writes before a read occur, header information is lost).         //
558
  //******************************************************************//
559
 
560
  // Header buffer for completion from TLM (TRN I/F) & USR (CFG I/F)
561
  cmm_errman_ram4x26  cmt_hdr_buf (
562
                 .rddata (cmt_rd_hdr)
563
                ,.wrdata (cmt_wr_hdr)
564
                ,.wr_ptr (cmt_wp)
565
                ,.rd_ptr (cmt_rp)
566
                ,.we     (incr_cplt)
567
                ,.rst    (~rst_n)
568
                ,.clk    (clk)
569
                );
570
 
571
  cmm_errman_ram8x26  cfg_hdr_buf (
572
                 .rddata (cfg_rd_hdr)
573
                ,.wrdata (cfg_wr_hdr)
574
                ,.wr_ptr (cfg_wp)
575
                ,.rd_ptr (cfg_rp)
576
                ,.we     (incr_cplu)
577
                ,.rst    (~rst_n)
578
                ,.clk    (clk)
579
                );
580
 
581
  assign decr_cplu = cs_is_cplu && grant;
582
  assign decr_cplt = cs_is_cplt && grant;
583
  assign decr_cor  = cs_is_cor  && grant;
584
  assign decr_nfl  = cs_is_nfl  && grant;
585
  assign decr_ftl  = cs_is_ftl  && grant;
586
 
587
  //assign tlp_is_np_and_ur  = cmmt_err_tlp_ur & cmmt_err_tlp_p_cpl_n;
588
  assign tlp_is_np_and_ur  = ~rx_err_tlp_ur_n & rx_err_tlp_p_cpl_n;
589
                                // For a Non-Posted TLP that causes a UR, we should report a UR
590
  assign tlp_posted        = tlp_is_np_and_ur ? 1'b1 : 1'b0;
591
 
592
  assign cfg_is_np_and_ur                  = ~cfg_err_ur_n & cfg_err_posted_n;
593
  assign cfg_is_np_and_cpl_abort           = ~cfg_err_cpl_abort_n & cfg_err_posted_n;
594
 
595
  // cfg_posted has a 3 cycle delay from when cfg_err_ur_n or 
596
  // cfg_err_cpl_abort_n is asserted.  Set throttle at 4, so fifo needs space
597
  // for 3+3. Only 1 cpl can be added to fifo at a time.
598
 
599
  assign cfg_posted        = ((cfg_is_np_and_ur|cfg_is_np_and_cpl_abort) & ~cnt_cplu[2]) ? 1'b1 : 1'b0;
600
 
601
  assign cfg_err_cpl_rdy_n = (cnt_cplu[2] | ~rst_n);
602
 
603
 
604
  assign l0_set_user_master_data_parity    = reg_masterdataparityerror;
605
  assign l0_set_user_signaled_target_abort = reg_signaledtargetabort;
606
  assign l0_set_user_received_target_abort = reg_receivedtargetabort;
607
  assign l0_set_user_received_master_abort = reg_receivedmasterabort;
608
  assign l0_set_user_detected_parity_error = reg_detectedparityerror;
609
 
610
  assign l0_set_user_system_error = reg_signaledsystemerror;
611
 
612
  assign l0_set_unsupported_request_other_error = reg_unsupportedreq;
613
  assign l0_set_detected_fatal_error        = reg_detectedfatal;
614
  assign l0_set_detected_nonfatal_error     = reg_detectednonfatal;
615
  assign l0_set_detected_corr_error = reg_detectedcorrectable;
616
 
617
endmodule // pcie_blk_cf_err

powered by: WebSVN 2.1.0

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