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

Subversion Repositories pcie_sg_dma

[/] [pcie_sg_dma/] [branches/] [Virtex6/] [ML605_ISE13.3/] [ipcore_dir_ISE13.3/] [v6_pcie_v1_7_x4/] [source/] [gtx_rx_valid_filter_v6.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 barabba
 
2
-------------------------------------------------------------------------------
3
--
4
-- (c) Copyright 2009-2011 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    : Virtex-6 Integrated Block for PCI Express
52
-- File       : gtx_rx_valid_filter_v6.vhd
53
-- Version    : 1.7
54
-------------------------------------------------------------------------------
55
library ieee;
56
   use ieee.std_logic_1164.all;
57
   use ieee.std_logic_unsigned.all;
58
 
59
library unisim;
60
use unisim.vcomponents.all;
61
 
62
entity GTX_RX_VALID_FILTER_V6 is
63
   generic (
64
 
65
      CLK_COR_MIN_LAT                           : integer := 28
66
   );
67
   port (
68
      USER_RXCHARISK                            : out std_logic_vector(1 downto 0);
69
      USER_RXDATA                               : out std_logic_vector(15 downto 0);
70
      USER_RXVALID                              : out std_logic;
71
      USER_RXELECIDLE                           : out std_logic;
72
      USER_RX_STATUS                            : out std_logic_vector(2 downto 0);
73
      USER_RX_PHY_STATUS                        : out std_logic;
74
      GT_RXCHARISK                              : in std_logic_vector(1 downto 0);
75
      GT_RXDATA                                 : in std_logic_vector(15 downto 0);
76
      GT_RXVALID                                : in std_logic;
77
      GT_RXELECIDLE                             : in std_logic;
78
      GT_RX_STATUS                              : in std_logic_vector(2 downto 0);
79
      GT_RX_PHY_STATUS                          : in std_logic;
80
      PLM_IN_L0                                 : in std_logic;
81
      PLM_IN_RS                                 : in std_logic;
82
      USER_CLK                                  : in std_logic;
83
      RESET                                     : in std_logic
84
   );
85
end GTX_RX_VALID_FILTER_V6;
86
 
87
architecture v6_pcie of GTX_RX_VALID_FILTER_V6 is
88
 
89
   constant TCQ                                   : integer := 1;
90
 
91
   constant EIOS_DET_IDL                          : std_logic_vector(4 downto 0) := "00001";
92
   constant EIOS_DET_NO_STR0                      : std_logic_vector(4 downto 0) := "00010";
93
   constant EIOS_DET_STR0                         : std_logic_vector(4 downto 0) := "00100";
94
   constant EIOS_DET_STR1                         : std_logic_vector(4 downto 0) := "01000";
95
   constant EIOS_DET_DONE                         : std_logic_vector(4 downto 0) := "10000";
96
 
97
   constant EIOS_COM                              : std_logic_vector(7 downto 0) := "10111100";
98
   constant EIOS_IDL                              : std_logic_vector(7 downto 0) := "01111100";
99
   constant FTSOS_COM                             : std_logic_vector(7 downto 0) := "10111100";
100
   constant FTSOS_FTS                             : std_logic_vector(7 downto 0) := "00111100";
101
 
102
   constant USER_RXVLD_IDL                        : std_logic_vector(3 downto 0) := "0001";
103
   constant USER_RXVLD_EI                         : std_logic_vector(3 downto 0) := "0010";
104
   constant USER_RXVLD_EI_DB0                     : std_logic_vector(3 downto 0) := "0100";
105
   constant USER_RXVLD_EI_DB1                     : std_logic_vector(3 downto 0) := "1000";
106
 
107
   constant TS1_FILTER_IDLE                       : std_logic_vector(2 downto 0) := "001";
108
   constant TS1_FILTER_WAITVALID                  : std_logic_vector(2 downto 0) := "010";
109
   constant TS1_FILTER_DB                         : std_logic_vector(2 downto 0) := "100";
110
 
111
   FUNCTION to_stdlogicvector (
112
      val_in      : IN integer;
113
      length      : IN integer) RETURN std_logic_vector IS
114
 
115
      VARIABLE ret      : std_logic_vector(length-1 DOWNTO 0) := (OTHERS => '0');
116
      VARIABLE num      : integer := val_in;
117
      VARIABLE x        : integer;
118
   BEGIN
119
      FOR index IN 0 TO length-1 LOOP
120
         x := num rem 2;
121
         num := num/2;
122
         IF (x = 1) THEN
123
            ret(index) := '1';
124
         ELSE
125
            ret(index) := '0';
126
         END IF;
127
      END LOOP;
128
      RETURN(ret);
129
   END to_stdlogicvector;
130
 
131
  FUNCTION to_stdlogic (
132
    in_val      : IN boolean) RETURN std_logic IS
133
  BEGIN
134
    IF (in_val) THEN
135
      RETURN('1');
136
    ELSE
137
      RETURN('0');
138
    END IF;
139
  END to_stdlogic;
140
 
141
   signal reg_state_eios_det                      : std_logic_vector(4 downto 0);
142
   signal state_eios_det                          : std_logic_vector(4 downto 0);
143
   signal reg_eios_detected                       : std_logic;
144
   signal eios_detected                           : std_logic;
145
   signal reg_symbol_after_eios                   : std_logic;
146
   signal symbol_after_eios                       : std_logic;
147
 
148
   signal reg_state_rxvld_ei                      : std_logic_vector(3 downto 0);
149
   signal state_rxvld_ei                          : std_logic_vector(3 downto 0);
150
 
151
   signal reg_rxvld_count                         : std_logic_vector(4 downto 0);
152
   signal rxvld_count                             : std_logic_vector(4 downto 0);
153
 
154
   signal reg_rxvld_fallback                      : std_logic_vector(3 downto 0);
155
   signal rxvld_fallback                          : std_logic_vector(3 downto 0);
156
 
157
   signal gt_rxcharisk_q                          : std_logic_vector(1 downto 0);
158
   signal gt_rxdata_q                             : std_logic_vector(15 downto 0);
159
   signal gt_rxvalid_q                            : std_logic;
160
   signal gt_rxelecidle_q                         : std_logic;
161
   signal gt_rxelecidle_qq                        : std_logic;
162
 
163
   signal gt_rx_status_q                          : std_logic_vector(2 downto 0);
164
   signal gt_rx_phy_status_q                      : std_logic;
165
   signal gt_rx_is_skp0_q                         : std_logic;
166
   signal gt_rx_is_skp1_q                         : std_logic;
167
 
168
   signal ts1_state                               : std_logic_vector(2 downto 0);
169
   signal next_ts1_state                          : std_logic_vector(2 downto 0);
170
   signal ts1_resetcount                          : std_logic;
171
   signal ts1_count                               : std_logic_vector(8 downto 0);
172
   signal ts1_filter_done                         : std_logic;
173
   signal next_ts1_filter_done                    : std_logic;
174
 
175
   signal awake_in_progress_q                     : std_logic := '0';
176
   signal awake_in_progress                       : std_logic := '0';
177
   signal awake_see_com_q                         : std_logic := '0';
178
   signal awake_com_count_q                       : std_logic_vector(3 downto 0) := "0000";
179
   signal awake_com_count                         : std_logic_vector(3 downto 0) := "0000";
180
   signal awake_com_count_inced                   : std_logic_vector(3 downto 0) := "0000";
181
 
182
   signal awake_see_com_0                         : std_logic;
183
   signal awake_see_com_1                         : std_logic;
184
   signal awake_see_com                           : std_logic;
185
   signal awake_done                              : std_logic;
186
   signal awake_start                             : std_logic;
187
 
188
   signal rst_l                                   : std_logic;
189
 
190
 
191
   -- Declare intermediate signals for referenced outputs
192
   signal USER_RXVALID_v6pcie1                    : std_logic;
193
   signal USER_RXELECIDLE_v6pcie0                 : std_logic;
194
 
195
begin
196
   -- Drive referenced outputs
197
   USER_RXVALID <= USER_RXVALID_v6pcie1;
198
   USER_RXELECIDLE <= USER_RXELECIDLE_v6pcie0;
199
 
200
   -- EIOS detector
201
 
202
   process (USER_CLK)
203
   begin
204
      if (USER_CLK'event and USER_CLK = '1') then
205
 
206
         if (RESET = '1') then
207
 
208
            reg_eios_detected <= '0' after (TCQ)*1 ps;
209
            reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
210
            reg_symbol_after_eios <= '0' after (TCQ)*1 ps;
211
            gt_rxcharisk_q <= "00" after (TCQ)*1 ps;
212
            gt_rxdata_q <= "0000000000000000" after (TCQ)*1 ps;
213
            gt_rxvalid_q <= '0' after (TCQ)*1 ps;
214
            gt_rxelecidle_q <= '0' after (TCQ)*1 ps;
215
            gt_rxelecidle_qq <= '0' after (TCQ)*1 ps;
216
            gt_rx_status_q <= "000" after (TCQ)*1 ps;
217
 
218
            gt_rx_phy_status_q <= '0' after (TCQ)*1 ps;
219
            gt_rx_is_skp0_q <= '0' after (TCQ)*1 ps;
220
            gt_rx_is_skp1_q <= '0' after (TCQ)*1 ps;
221
 
222
         else
223
 
224
            reg_eios_detected <= '0' after (TCQ)*1 ps;
225
            reg_symbol_after_eios <= '0' after (TCQ)*1 ps;
226
            gt_rxcharisk_q <= GT_RXCHARISK after (TCQ)*1 ps;
227
            gt_rxdata_q <= GT_RXDATA after (TCQ)*1 ps;
228
            gt_rxvalid_q <= GT_RXVALID after (TCQ)*1 ps;
229
            gt_rxelecidle_q <= GT_RXELECIDLE after (TCQ)*1 ps;
230
            gt_rxelecidle_qq <= gt_rxelecidle_q after (TCQ)*1 ps;
231
            gt_rx_status_q <= GT_RX_STATUS after (TCQ)*1 ps;
232
 
233
            gt_rx_phy_status_q <= GT_RX_PHY_STATUS after (TCQ)*1 ps;
234
 
235
            if ((GT_RXCHARISK(0) = '1') and (GT_RXDATA(7 downto 0) = FTSOS_FTS)) then
236
              gt_rx_is_skp0_q  <= '1' after (TCQ)*1 ps;
237
            else
238
              gt_rx_is_skp0_q  <= '0' after (TCQ)*1 ps;
239
            end if;
240
 
241
            if ((GT_RXCHARISK(1) = '1') and (GT_RXDATA(15 downto 8) = FTSOS_FTS)) then
242
              gt_rx_is_skp1_q  <= '1' after (TCQ)*1 ps;
243
            else
244
              gt_rx_is_skp1_q  <= '0' after (TCQ)*1 ps;
245
            end if;
246
 
247
            case state_eios_det is
248
 
249
               when EIOS_DET_IDL =>
250
                  if ((gt_rxcharisk_q(0) = '1') and (gt_rxdata_q(7 downto 0) = EIOS_COM) and (gt_rxcharisk_q(1) = '1') and (gt_rxdata_q(15 downto 8) = EIOS_IDL)) then
251
                     reg_state_eios_det <= EIOS_DET_NO_STR0 after (TCQ)*1 ps;
252
                     reg_eios_detected <= '1' after (TCQ)*1 ps;
253
                  elsif ((gt_rxcharisk_q(1) = '1') and (gt_rxdata_q(15 downto 8) = EIOS_COM)) then
254
                     reg_state_eios_det <= EIOS_DET_STR0 after (TCQ)*1 ps;
255
                  else
256
                     reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
257
                  end if;
258
 
259
               when EIOS_DET_NO_STR0 =>
260
                  if ((gt_rxcharisk_q(0) = '1') and (gt_rxdata_q(7 downto 0) = EIOS_IDL) and (gt_rxcharisk_q(1) = '1') and (gt_rxdata_q(15 downto 8) = EIOS_IDL)) then
261
                     reg_state_eios_det <= EIOS_DET_DONE after (TCQ)*1 ps;
262
                  else
263
                     reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
264
                  end if;
265
 
266
               when EIOS_DET_STR0 =>
267
                  if ((gt_rxcharisk_q(0) = '1') and (gt_rxdata_q(7 downto 0) = EIOS_IDL) and (gt_rxcharisk_q(1) = '1') and (gt_rxdata_q(15 downto 8) = EIOS_IDL)) then
268
                     reg_state_eios_det <= EIOS_DET_STR1 after (TCQ)*1 ps;
269
                     reg_eios_detected <= '1' after (TCQ)*1 ps;
270
                     reg_symbol_after_eios <= '1' after (TCQ)*1 ps;
271
                  else
272
                     reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
273
                  end if;
274
 
275
               when EIOS_DET_STR1 =>
276
                  if ((gt_rxcharisk_q(0) = '1') and (gt_rxdata_q(7 downto 0) = EIOS_IDL)) then
277
                     reg_state_eios_det <= EIOS_DET_DONE after (TCQ)*1 ps;
278
                  else
279
                     reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
280
                  end if;
281
 
282
               when EIOS_DET_DONE =>
283
                  reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
284
 
285
              when others =>
286
                  reg_state_eios_det <= EIOS_DET_IDL after (TCQ)*1 ps;
287
            end case;
288
         end if;
289
      end if;
290
   end process;
291
 
292
   state_eios_det <= reg_state_eios_det;
293
   eios_detected <= reg_eios_detected;
294
   symbol_after_eios <= reg_symbol_after_eios;
295
 
296
   -- user_rxvalid generation
297
 
298
   process (USER_CLK)
299
   begin
300
      if (USER_CLK'event and USER_CLK = '1') then
301
 
302
         if (RESET = '1') then
303
            reg_state_rxvld_ei <= USER_RXVLD_IDL after (TCQ)*1 ps;
304
         else
305
            case state_rxvld_ei is
306
 
307
               when USER_RXVLD_IDL =>
308
                  if (eios_detected = '1') then
309
                     reg_state_rxvld_ei <= USER_RXVLD_EI after (TCQ)*1 ps;
310
                  else
311
                     reg_state_rxvld_ei <= USER_RXVLD_IDL after (TCQ)*1 ps;
312
                  end if;
313
 
314
               when USER_RXVLD_EI =>
315
                  if ((not(gt_rxvalid_q)) = '1') then
316
                     reg_state_rxvld_ei <= USER_RXVLD_EI_DB0 after (TCQ)*1 ps;
317
                  elsif (rxvld_fallback = "1111") then
318
                     reg_state_rxvld_ei <= USER_RXVLD_IDL after (TCQ)*1 ps;
319
                  else
320
                     reg_state_rxvld_ei <= USER_RXVLD_EI after (TCQ)*1 ps;
321
                  end if;
322
 
323
               when USER_RXVLD_EI_DB0 =>
324
                  if (gt_rxvalid_q = '1') then
325
                     reg_state_rxvld_ei <= USER_RXVLD_EI_DB1 after (TCQ)*1 ps;
326
                  elsif ((not(PLM_IN_L0)) = '1') then
327
                     reg_state_rxvld_ei <= USER_RXVLD_IDL after (TCQ)*1 ps;
328
                  else
329
                     reg_state_rxvld_ei <= USER_RXVLD_EI_DB0 after (TCQ)*1 ps;
330
                  end if;
331
 
332
               when USER_RXVLD_EI_DB1 =>
333
                  if (rxvld_count > to_stdlogicvector(CLK_COR_MIN_LAT, 5)) then
334
                     reg_state_rxvld_ei <= USER_RXVLD_IDL after (TCQ)*1 ps;
335
                  else
336
                     reg_state_rxvld_ei <= USER_RXVLD_EI_DB1 after (TCQ)*1 ps;
337
                  end if;
338
              when others =>
339
                 reg_state_rxvld_ei <= USER_RXVLD_IDL after (TCQ)*1 ps;
340
            end case;
341
         end if;
342
      end if;
343
   end process;
344
 
345
 
346
   state_rxvld_ei <= reg_state_rxvld_ei;
347
 
348
   -- RxValid counter
349
 
350
   process (USER_CLK)
351
   begin
352
      if (USER_CLK'event and USER_CLK = '1') then
353
 
354
         if (RESET = '1') then
355
            reg_rxvld_count <= "00000" after (TCQ)*1 ps;
356
         else
357
 
358
            if ((gt_rxvalid_q = '1') and (state_rxvld_ei = USER_RXVLD_EI_DB1)) then
359
               reg_rxvld_count <= reg_rxvld_count + "00001" after (TCQ)*1 ps;
360
            else
361
               reg_rxvld_count <= "00000" after (TCQ)*1 ps;
362
            end if;
363
 
364
         end if;
365
      end if;
366
   end process;
367
 
368
 
369
   rxvld_count <= reg_rxvld_count;
370
 
371
   -- RxValid fallback
372
 
373
   process (USER_CLK)
374
   begin
375
      if (USER_CLK'event and USER_CLK = '1') then
376
         if (RESET = '1') then
377
            reg_rxvld_fallback <= "0000" after (TCQ)*1 ps;
378
         else
379
            if (state_rxvld_ei = USER_RXVLD_EI) then
380
               reg_rxvld_fallback <= reg_rxvld_fallback + "0001" after (TCQ)*1 ps;
381
            else
382
               reg_rxvld_fallback <= "0000" after (TCQ)*1 ps;
383
            end if;
384
         end if;
385
      end if;
386
   end process;
387
 
388
   rxvld_fallback <= reg_rxvld_fallback;
389
 
390
   -- Delay pipe_rx_elec_idle
391
 
392
   rx_elec_idle_delay : SRL16E
393
      generic map (
394
         INIT  => X"0000"
395
      )
396
      port map (
397
         Q    => USER_RXELECIDLE_v6pcie0,
398
         D    => gt_rxelecidle_q,
399
         CLK  => USER_CLK,
400
         CE   => '1',
401
         A3   => '1',
402
         A2   => '1',
403
         A1   => '1',
404
         A0   => '1'
405
      );
406
 
407
   awake_see_com_0      <= GT_RXVALID and (gt_rxcharisk_q(0) and to_stdlogic(gt_rxdata_q(7 downto 0) = EIOS_COM));
408
 
409
   awake_see_com_1      <= GT_RXVALID and (gt_rxcharisk_q(1) and to_stdlogic(gt_rxdata_q(15 downto 8) = EIOS_COM));
410
 
411
   awake_see_com        <= (awake_see_com_0 or awake_see_com_1) and not(awake_see_com_q);
412
 
413
-- Count 8 COMs, (not back-to-back), when waking up from electrical idle
414
--  but not for L0s (which is L0).
415
 
416
   awake_done  <= awake_in_progress_q and to_stdlogic(awake_com_count_q(3 downto 0) >= X"b");
417
 
418
   awake_start <= (not(gt_rxelecidle_q) and gt_rxelecidle_qq) or PLM_IN_RS;
419
 
420
   awake_in_progress <= awake_start or (not(awake_done) and awake_in_progress_q);
421
 
422
   awake_com_count_inced <= awake_com_count_q(3 downto 0) + "0001";
423
 
424
   awake_com_count <= "0000" when (not(awake_in_progress_q) = '1') else
425
                      "0000" when (awake_start = '1') else
426
                      awake_com_count_inced(3 downto 0) when (awake_see_com_q = '1') else
427
                      awake_com_count_q(3 downto 0);
428
 
429
   rst_l  <= not(RESET);
430
 
431
   process (USER_CLK)
432
   begin
433
      if (USER_CLK'event and USER_CLK = '1') then
434
         if (rst_l = '0') then
435
            awake_see_com_q <= '0';
436
            awake_in_progress_q <= '0';
437
            awake_com_count_q(3 downto 0) <= "0000";
438
         else
439
            awake_see_com_q <= awake_see_com;
440
            awake_in_progress_q <= awake_in_progress;
441
            awake_com_count_q(3 downto 0) <= awake_com_count(3 downto 0);
442
         end if;
443
      end if;
444
   end process;
445
 
446
   USER_RXVALID_v6pcie1 <= gt_rxvalid_q when ((state_rxvld_ei = USER_RXVLD_IDL) and (not(awake_in_progress_q) = '1')) else
447
                           '0';
448
   USER_RXCHARISK(0)    <= gt_rxcharisk_q(0) when (USER_RXVALID_v6pcie1 = '1') else
449
                           '0';
450
   USER_RXCHARISK(1)    <= gt_rxcharisk_q(1) when ((USER_RXVALID_v6pcie1 and not(symbol_after_eios)) = '1') else
451
                           '0';
452
   USER_RXDATA(7 downto 0) <= FTSOS_COM when (gt_rx_is_skp0_q = '1') else
453
                             gt_rxdata_q(7 downto 0);
454
 
455
   USER_RXDATA(15 downto 8) <= FTSOS_COM when (gt_rx_is_skp1_q = '1') else
456
                             gt_rxdata_q(15 downto 8);
457
 
458
   USER_RX_STATUS       <= gt_rx_status_q when (state_rxvld_ei = USER_RXVLD_IDL) else
459
                           "000";
460
   USER_RX_PHY_STATUS   <= gt_rx_phy_status_q;
461
 
462
end v6_pcie;
463
 
464
 

powered by: WebSVN 2.1.0

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