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/] [cmm_errman_cnt_en.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       : cmm_errman_cnt_en.v
53
//--------------------------------------------------------------------------------
54
//--------------------------------------------------------------------------------
55
 
56
/***********************************************************************
57
 
58
  Description:
59
  This is the error counter module for tracking the outstanding
60
  correctible/fatal. When overflow or underflow occurs, it remains at
61
  either full scale (overflow) or zero (underflow) instead of rolling
62
  over.
63
 
64
***********************************************************************/
65
 
66
`ifndef FFD
67
  `define FFD 1
68
`endif
69
 
70
 
71
module cmm_errman_cnt_en (
72
                count,                  // Outputs
73
 
74
                index,                  // Inputs
75
                inc_dec_b,
76
                enable,
77
                rst,
78
                clk
79
                );
80
 
81
 
82
  output  [3:0] count;
83
 
84
  input   [2:0] index;       // ftl_num, nfl_num  or cor_num
85
  input         inc_dec_b;   // 1 = increment, 0 = decrement
86
  input         enable;      // err_*_en
87
  input         rst;
88
  input         clk;
89
 
90
 
91
  //******************************************************************//
92
  // Reality check.                                                   //
93
  //******************************************************************//
94
 
95
  parameter FFD       = 1;        // clock to out delay model
96
 
97
 
98
  //******************************************************************//
99
  // There are 2 pipeline stages to help timing.                      //
100
  // Stage 1: a simple add/subtract accumulator with no overflow or   //
101
  //          underflow check.                                        //
102
  // Stage 2: underflow, overflow and counter enable are handled.     //
103
  //******************************************************************//
104
 
105
 
106
  // Stage 1: count up or count down
107
 
108
 
109
  reg     [3:0] reg_cnt;
110
  reg           reg_extra;
111
  reg           reg_inc_dec_b;
112
  reg           reg_uflow;
113
 
114
  //wire    [3:0] cnt;
115
  reg     [3:0] cnt;
116
  wire          oflow;
117
  wire          uflow;
118
 
119
  always @(posedge clk or posedge rst) begin
120
    if (rst)              {reg_extra, reg_cnt} <= #`FFD 5'b00000;
121
    else if (~enable)     {reg_extra, reg_cnt} <= #`FFD 5'b00000;
122
    else if (inc_dec_b)   {reg_extra, reg_cnt} <= #`FFD cnt + index;
123
    else                  {reg_extra, reg_cnt} <= #`FFD cnt - index;
124
  end
125
 
126
  //assign cnt   = oflow ? 4'hF : (uflow ? 4'h0 : reg_cnt);
127
  always @(oflow or uflow or reg_cnt) begin
128
    case ({oflow,uflow})    // synthesis full_case parallel_case
129
      2'b11: cnt = 4'hF;
130
      2'b10: cnt = 4'hF;
131
      2'b01: cnt = 4'h0;
132
      2'b00: cnt = reg_cnt;
133
    endcase
134
  end
135
 
136
 
137
  always @(posedge clk or posedge rst) begin
138
    if (rst)  reg_inc_dec_b <= #`FFD 1'b0;
139
    else      reg_inc_dec_b <= #`FFD inc_dec_b;
140
  end
141
 
142
  assign oflow = reg_extra & reg_inc_dec_b;
143
 
144
 
145
  always @(posedge clk or posedge rst) begin
146
    if (rst)
147
      reg_uflow <= #`FFD 1'b0;
148
    else
149
      //reg_uflow <= #`FFD (count == 4'b0000) & (index[2:0] != 3'b000) & ~inc_dec_b;
150
      reg_uflow <= #`FFD ~|count & |index[2:0] & ~inc_dec_b;
151
  end
152
 
153
  assign uflow = reg_uflow;
154
 
155
 
156
  // Stage 2: if overflow occurs, the counter is set to full scale;
157
  //          if underflow occurs, it is set to zero.
158
  //          if counter is not enable, it is set to zero.
159
 
160
 
161
  reg     [3:0] reg_count;
162
 
163
  always @(posedge clk or posedge rst) begin
164
    if (rst)            reg_count <= #`FFD 4'b0000;
165
    else if (~enable)   reg_count <= #`FFD 4'b0000;
166
    else if (oflow)     reg_count <= #`FFD 4'b1111;
167
    else if (uflow)     reg_count <= #`FFD 4'b0000;
168
    else                reg_count <= #`FFD cnt;
169
  end
170
 
171
  assign count = reg_count;
172
 
173
 
174
  //******************************************************************//
175
  //                                                                  //
176
  //******************************************************************//
177
 
178
endmodule

powered by: WebSVN 2.1.0

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