otsdaq_prepmodernization  v2_05_02_indev
ethernetFIFO_pctrl.vhd
1 
2 --------------------------------------------------------------------------------
3 --
4 -- FIFO Generator Core Demo Testbench
5 --
6 --------------------------------------------------------------------------------
7 --
8 -- (c) Copyright 2009 - 2010 Xilinx, Inc. All rights reserved.
9 --
10 -- This file contains confidential and proprietary information
11 -- of Xilinx, Inc. and is protected under U.S. and
12 -- international copyright and other intellectual property
13 -- laws.
14 --
15 -- DISCLAIMER
16 -- This disclaimer is not a license and does not grant any
17 -- rights to the materials distributed herewith. Except as
18 -- otherwise provided in a valid license issued to you by
19 -- Xilinx, and to the maximum extent permitted by applicable
20 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
21 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
22 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
23 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
24 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
25 -- (2) Xilinx shall not be liable (whether in contract or tort,
26 -- including negligence, or under any other theory of
27 -- liability) for any loss or damage of any kind or nature
28 -- related to, arising under or in connection with these
29 -- materials, including for any direct, or any indirect,
30 -- special, incidental, or consequential loss or damage
31 -- (including loss of data, profits, goodwill, or any type of
32 -- loss or damage suffered as a result of any action brought
33 -- by a third party) even if such damage or loss was
34 -- reasonably foreseeable or Xilinx had been advised of the
35 -- possibility of the same.
36 --
37 -- CRITICAL APPLICATIONS
38 -- Xilinx products are not designed or intended to be fail-
39 -- safe, or for use in any application requiring fail-safe
40 -- performance, such as life-support or safety devices or
41 -- systems, Class III medical devices, nuclear facilities,
42 -- applications related to the deployment of airbags, or any
43 -- other applications that could lead to death, personal
44 -- injury, or severe property or environmental damage
45 -- (individually and collectively, "Critical
46 -- Applications"). Customer assumes the sole risk and
47 -- liability of any use of Xilinx products in Critical
48 -- Applications, subject only to applicable laws and
49 -- regulations governing limitations on product liability.
50 --
51 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
52 -- PART OF THIS FILE AT ALL TIMES.
53 --------------------------------------------------------------------------------
54 --
55 -- Filename: ethernetFIFO_pctrl.vhd
56 --
57 -- Description:
58 -- Used for protocol control on write and read interface stimulus and status generation
59 --
60 --------------------------------------------------------------------------------
61 -- Library Declarations
62 --------------------------------------------------------------------------------
63 LIBRARY ieee;
64 USE ieee.std_logic_1164.ALL;
65 USE ieee.std_logic_unsigned.all;
66 USE IEEE.std_logic_arith.all;
67 USE IEEE.std_logic_misc.all;
68 
69 LIBRARY work;
70 USE work.ethernetFIFO_pkg.ALL;
71 
73  GENERIC(
74  AXI_CHANNEL : STRING :="NONE";
75  C_APPLICATION_TYPE : INTEGER := 0;
76  C_DIN_WIDTH : INTEGER := 0;
77  C_DOUT_WIDTH : INTEGER := 0;
78  C_WR_PNTR_WIDTH : INTEGER := 0;
79  C_RD_PNTR_WIDTH : INTEGER := 0;
80  C_CH_TYPE : INTEGER := 0;
81  FREEZEON_ERROR : INTEGER := 0;
82  TB_STOP_CNT : INTEGER := 2;
83  TB_SEED : INTEGER := 2
84  );
85  PORT(
86  RESET_WR : IN STD_LOGIC;
87  RESET_RD : IN STD_LOGIC;
88  WR_CLK : IN STD_LOGIC;
89  RD_CLK : IN STD_LOGIC;
90  FULL : IN STD_LOGIC;
91  EMPTY : IN STD_LOGIC;
92  ALMOST_FULL : IN STD_LOGIC;
93  ALMOST_EMPTY : IN STD_LOGIC;
94  DATA_IN : IN STD_LOGIC_VECTOR(C_DIN_WIDTH-1 DOWNTO 0);
95  DATA_OUT : IN STD_LOGIC_VECTOR(C_DOUT_WIDTH-1 DOWNTO 0);
96  DOUT_CHK : IN STD_LOGIC;
97  PRC_WR_EN : OUT STD_LOGIC;
98  PRC_RD_EN : OUT STD_LOGIC;
99  RESET_EN : OUT STD_LOGIC;
100  SIM_DONE : OUT STD_LOGIC;
101  STATUS : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
102  );
103 END ENTITY;
104 
105 
106 ARCHITECTURE fg_pc_arch OF ethernetFIFO_pctrl IS
107 
108  CONSTANT C_DATA_WIDTH : INTEGER := if_then_else(C_DIN_WIDTH > C_DOUT_WIDTH,C_DIN_WIDTH,C_DOUT_WIDTH);
109  CONSTANT LOOP_COUNT : INTEGER := divroundup(C_DATA_WIDTH,8);
110  CONSTANT D_WIDTH_DIFF : INTEGER := log2roundup(C_DOUT_WIDTH/C_DIN_WIDTH);
111 
112  SIGNAL data_chk_i : STD_LOGIC := if_then_else(C_CH_TYPE /= 2,'1','0');
113  SIGNAL full_chk_i : STD_LOGIC := if_then_else(C_CH_TYPE /= 2,'1','0');
114  SIGNAL empty_chk_i : STD_LOGIC := if_then_else(C_CH_TYPE /= 2,'1','0');
115  SIGNAL status_i : STD_LOGIC_VECTOR(4 DOWNTO 0):= (OTHERS => '0');
116  SIGNAL status_d1_i : STD_LOGIC_VECTOR(4 DOWNTO 0):= (OTHERS => '0');
117  SIGNAL wr_en_gen : STD_LOGIC_VECTOR(7 DOWNTO 0):= (OTHERS => '0');
118  SIGNAL rd_en_gen : STD_LOGIC_VECTOR(7 DOWNTO 0):= (OTHERS => '0');
119  SIGNAL wr_cntr : STD_LOGIC_VECTOR(C_WR_PNTR_WIDTH-2 DOWNTO 0) := (OTHERS => '0');
120  SIGNAL full_as_timeout : STD_LOGIC_VECTOR(C_WR_PNTR_WIDTH DOWNTO 0) := (OTHERS => '0');
121  SIGNAL full_ds_timeout : STD_LOGIC_VECTOR(C_WR_PNTR_WIDTH DOWNTO 0) := (OTHERS => '0');
122  SIGNAL rd_cntr : STD_LOGIC_VECTOR(C_RD_PNTR_WIDTH-2 DOWNTO 0) := (OTHERS => '0');
123  SIGNAL empty_as_timeout : STD_LOGIC_VECTOR(C_RD_PNTR_WIDTH DOWNTO 0) := (OTHERS => '0');
124  SIGNAL empty_ds_timeout : STD_LOGIC_VECTOR(C_RD_PNTR_WIDTH DOWNTO 0):= (OTHERS => '0');
125  SIGNAL wr_en_i : STD_LOGIC := '0';
126  SIGNAL rd_en_i : STD_LOGIC := '0';
127  SIGNAL state : STD_LOGIC := '0';
128  SIGNAL wr_control : STD_LOGIC := '0';
129  SIGNAL rd_control : STD_LOGIC := '0';
130  SIGNAL stop_on_err : STD_LOGIC := '0';
131  SIGNAL sim_stop_cntr : STD_LOGIC_VECTOR(7 DOWNTO 0):= conv_std_logic_vector(if_then_else(C_CH_TYPE=2,64,TB_STOP_CNT),8);
132  SIGNAL sim_done_i : STD_LOGIC := '0';
133  SIGNAL rdw_gt_wrw : STD_LOGIC_VECTOR(D_WIDTH_DIFF-1 DOWNTO 0) := (OTHERS => '1');
134  SIGNAL wrw_gt_rdw : STD_LOGIC_VECTOR(D_WIDTH_DIFF-1 DOWNTO 0) := (OTHERS => '1');
135  SIGNAL rd_activ_cont : STD_LOGIC_VECTOR(25 downto 0):= (OTHERS => '0');
136  SIGNAL prc_we_i : STD_LOGIC := '0';
137  SIGNAL prc_re_i : STD_LOGIC := '0';
138  SIGNAL reset_en_i : STD_LOGIC := '0';
139  SIGNAL sim_done_d1 : STD_LOGIC := '0';
140  SIGNAL sim_done_wr1 : STD_LOGIC := '0';
141  SIGNAL sim_done_wr2 : STD_LOGIC := '0';
142  SIGNAL empty_d1 : STD_LOGIC := '0';
143  SIGNAL empty_wr_dom1 : STD_LOGIC := '0';
144  SIGNAL state_d1 : STD_LOGIC := '0';
145  SIGNAL state_rd_dom1 : STD_LOGIC := '0';
146  SIGNAL rd_en_d1 : STD_LOGIC := '0';
147  SIGNAL rd_en_wr1 : STD_LOGIC := '0';
148  SIGNAL wr_en_d1 : STD_LOGIC := '0';
149  SIGNAL wr_en_rd1 : STD_LOGIC := '0';
150  SIGNAL full_chk_d1 : STD_LOGIC := '0';
151  SIGNAL full_chk_rd1 : STD_LOGIC := '0';
152  SIGNAL empty_wr_dom2 : STD_LOGIC := '0';
153 
154  SIGNAL state_rd_dom2 : STD_LOGIC := '0';
155  SIGNAL state_rd_dom3 : STD_LOGIC := '0';
156  SIGNAL rd_en_wr2 : STD_LOGIC := '0';
157  SIGNAL wr_en_rd2 : STD_LOGIC := '0';
158  SIGNAL full_chk_rd2 : STD_LOGIC := '0';
159  SIGNAL reset_en_d1 : STD_LOGIC := '0';
160  SIGNAL reset_en_rd1 : STD_LOGIC := '0';
161  SIGNAL reset_en_rd2 : STD_LOGIC := '0';
162 
163  SIGNAL data_chk_wr_d1 : STD_LOGIC := '0';
164  SIGNAL data_chk_rd1 : STD_LOGIC := '0';
165  SIGNAL data_chk_rd2 : STD_LOGIC := '0';
166  SIGNAL post_rst_dly_wr : STD_LOGIC_VECTOR(4 DOWNTO 0) := (OTHERS => '1');
167  SIGNAL post_rst_dly_rd : STD_LOGIC_VECTOR(4 DOWNTO 0) := (OTHERS => '1');
168 BEGIN
169  status_i <= data_chk_i & full_chk_rd2 & empty_chk_i & '0' & '0';
170  STATUS <= status_d1_i & '0' & '0' & rd_activ_cont(rd_activ_cont'high);
171 
172  prc_we_i <= wr_en_i WHEN sim_done_wr2 = '0' ELSE '0';
173  prc_re_i <= rd_en_i WHEN sim_done_i = '0' ELSE '0';
174 
175  SIM_DONE <= sim_done_i;
176  wrw_gt_rdw <= (OTHERS => '1');
177 
178  PROCESS(RD_CLK)
179  BEGIN
180  IF (RD_CLK'event AND RD_CLK='1') THEN
181  IF(prc_re_i = '1') THEN
182  rd_activ_cont <= rd_activ_cont + "1";
183  END IF;
184  END IF;
185  END PROCESS;
186 
187 
188  PROCESS(sim_done_i)
189  BEGIN
190  assert sim_done_i = '0'
191  report "Simulation Complete for:" & AXI_CHANNEL
192  severity note;
193  END PROCESS;
194 
195 -----------------------------------------------------
196 -- SIM_DONE SIGNAL GENERATION
197 -----------------------------------------------------
198 PROCESS (RD_CLK,RESET_RD)
199 BEGIN
200  IF(RESET_RD = '1') THEN
201  --sim_done_i <= '0';
202  ELSIF(RD_CLK'event AND RD_CLK='1') THEN
203  IF((OR_REDUCE(sim_stop_cntr) = '0' AND TB_STOP_CNT /= 0) OR stop_on_err = '1') THEN
204  sim_done_i <= '1';
205  END IF;
206  END IF;
207 END PROCESS;
208 
209  -- TB Timeout/Stop
210  fifo_tb_stop_run:IF(TB_STOP_CNT /= 0) GENERATE
211  PROCESS (RD_CLK)
212  BEGIN
213  IF (RD_CLK'event AND RD_CLK='1') THEN
214  IF(state_rd_dom2 = '0' AND state_rd_dom3 = '1') THEN
215  sim_stop_cntr <= sim_stop_cntr - "1";
216  END IF;
217  END IF;
218  END PROCESS;
219  END GENERATE fifo_tb_stop_run;
220 
221 
222  -- Stop when error found
223  PROCESS (RD_CLK)
224  BEGIN
225  IF (RD_CLK'event AND RD_CLK='1') THEN
226  IF(sim_done_i = '0') THEN
227  status_d1_i <= status_i OR status_d1_i;
228  END IF;
229  IF(FREEZEON_ERROR = 1 AND status_i /= "0") THEN
230  stop_on_err <= '1';
231  END IF;
232  END IF;
233  END PROCESS;
234  -----------------------------------------------------
235 
236  -----------------------------------------------------
237  -- CHECKS FOR FIFO
238  -----------------------------------------------------
239 
240 
241  PROCESS(RD_CLK,RESET_RD)
242  BEGIN
243  IF(RESET_RD = '1') THEN
244  post_rst_dly_rd <= (OTHERS => '1');
245  ELSIF (RD_CLK'event AND RD_CLK='1') THEN
246  post_rst_dly_rd <= post_rst_dly_rd-post_rst_dly_rd(4);
247  END IF;
248  END PROCESS;
249 
250  PROCESS(WR_CLK,RESET_WR)
251  BEGIN
252  IF(RESET_WR = '1') THEN
253  post_rst_dly_wr <= (OTHERS => '1');
254  ELSIF (WR_CLK'event AND WR_CLK='1') THEN
255  post_rst_dly_wr <= post_rst_dly_wr-post_rst_dly_wr(4);
256  END IF;
257  END PROCESS;
258 
259 
260  -- FULL de-assert Counter
261  PROCESS(WR_CLK,RESET_WR)
262  BEGIN
263  IF(RESET_WR = '1') THEN
264  full_ds_timeout <= (OTHERS => '0');
265  ELSIF(WR_CLK'event AND WR_CLK='1') THEN
266  IF(state = '1') THEN
267  IF(rd_en_wr2 = '1' AND wr_en_i = '0' AND FULL = '1' AND AND_REDUCE(wrw_gt_rdw) = '1') THEN
268  full_ds_timeout <= full_ds_timeout + '1';
269  END IF;
270  ELSE
271  full_ds_timeout <= (OTHERS => '0');
272  END IF;
273  END IF;
274  END PROCESS;
275 
276 
277  PROCESS(RD_CLK,RESET_RD)
278  BEGIN
279  IF(RESET_RD = '1') THEN
280  rdw_gt_wrw <= (OTHERS => '1');
281  ELSIF (RD_CLK'event AND RD_CLK='1') THEN
282  IF(wr_en_rd2 = '1' AND rd_en_i= '0' AND EMPTY = '1') THEN
283  rdw_gt_wrw <= rdw_gt_wrw + '1';
284  END IF;
285  END IF;
286  END PROCESS;
287 
288  -- EMPTY deassert counter
289  PROCESS(RD_CLK,RESET_RD)
290  BEGIN
291  IF(RESET_RD = '1') THEN
292  empty_ds_timeout <= (OTHERS => '0');
293  ELSIF(RD_CLK'event AND RD_CLK='1') THEN
294  IF(state = '0') THEN
295  IF(wr_en_rd2 = '1' AND rd_en_i = '0' AND EMPTY = '1' AND AND_REDUCE(rdw_gt_wrw) = '1') THEN
296  empty_ds_timeout <= empty_ds_timeout + '1';
297  END IF;
298  ELSE
299  empty_ds_timeout <= (OTHERS => '0');
300  END IF;
301  END IF;
302  END PROCESS;
303 
304  -- Full check signal generation
305  PROCESS(WR_CLK,RESET_WR)
306  BEGIN
307  IF(RESET_WR = '1') THEN
308  full_chk_i <= '0';
309  ELSIF(WR_CLK'event AND WR_CLK='1') THEN
310  IF(C_APPLICATION_TYPE = 1 AND (AXI_CHANNEL = "WACH" OR AXI_CHANNEL = "RACH" OR AXI_CHANNEL = "AXI4_Stream")) THEN
311  full_chk_i <= '0';
312  ELSE
313  full_chk_i <= AND_REDUCE(full_as_timeout) OR
314  AND_REDUCE(full_ds_timeout);
315  END IF;
316  END IF;
317  END PROCESS;
318 
319  -- Empty checks
320  PROCESS(RD_CLK,RESET_RD)
321  BEGIN
322  IF(RESET_RD = '1') THEN
323  empty_chk_i <= '0';
324  ELSIF(RD_CLK'event AND RD_CLK='1') THEN
325  IF(C_APPLICATION_TYPE = 1 AND (AXI_CHANNEL = "WACH" OR AXI_CHANNEL = "RACH" OR AXI_CHANNEL = "AXI4_Stream")) THEN
326  empty_chk_i <= '0';
327  ELSE
328  empty_chk_i <= AND_REDUCE(empty_as_timeout) OR
329  AND_REDUCE(empty_ds_timeout);
330  END IF;
331  END IF;
332  END PROCESS;
333 
334  fifo_d_chk:IF(C_CH_TYPE /= 2) GENERATE
335  PRC_WR_EN <= prc_we_i AFTER 100 ns;
336  PRC_RD_EN <= prc_re_i AFTER 50 ns;
337  data_chk_i <= dout_chk;
338  END GENERATE fifo_d_chk;
339  -----------------------------------------------------
340 
341 
342  -----------------------------------------------------
343  -- SYNCHRONIZERS B/W WRITE AND READ DOMAINS
344  -----------------------------------------------------
345  PROCESS(WR_CLK,RESET_WR)
346  BEGIN
347  IF(RESET_WR = '1') THEN
348  empty_wr_dom1 <= '1';
349  empty_wr_dom2 <= '1';
350  state_d1 <= '0';
351  wr_en_d1 <= '0';
352  rd_en_wr1 <= '0';
353  rd_en_wr2 <= '0';
354  full_chk_d1 <= '0';
355  reset_en_d1 <= '0';
356  sim_done_wr1 <= '0';
357  sim_done_wr2 <= '0';
358  ELSIF (WR_CLK'event AND WR_CLK='1') THEN
359  sim_done_wr1 <= sim_done_d1;
360  sim_done_wr2 <= sim_done_wr1;
361  reset_en_d1 <= reset_en_i;
362  state_d1 <= state;
363  empty_wr_dom1 <= empty_d1;
364  empty_wr_dom2 <= empty_wr_dom1;
365  wr_en_d1 <= wr_en_i;
366  rd_en_wr1 <= rd_en_d1;
367  rd_en_wr2 <= rd_en_wr1;
368  full_chk_d1 <= full_chk_i;
369  END IF;
370  END PROCESS;
371 
372  PROCESS(RD_CLK,RESET_RD)
373  BEGIN
374  IF(RESET_RD = '1') THEN
375  empty_d1 <= '1';
376  state_rd_dom1 <= '0';
377  state_rd_dom2 <= '0';
378  state_rd_dom3 <= '0';
379  wr_en_rd1 <= '0';
380  wr_en_rd2 <= '0';
381  rd_en_d1 <= '0';
382  full_chk_rd1 <= '0';
383  full_chk_rd2 <= '0';
384  reset_en_rd1 <= '0';
385  reset_en_rd2 <= '0';
386  sim_done_d1 <= '0';
387  ELSIF (RD_CLK'event AND RD_CLK='1') THEN
388  sim_done_d1 <= sim_done_i;
389  reset_en_rd1 <= reset_en_d1;
390  reset_en_rd2 <= reset_en_rd1;
391  empty_d1 <= EMPTY;
392  rd_en_d1 <= rd_en_i;
393  state_rd_dom1 <= state_d1;
394  state_rd_dom2 <= state_rd_dom1;
395  state_rd_dom3 <= state_rd_dom2;
396  wr_en_rd1 <= wr_en_d1;
397  wr_en_rd2 <= wr_en_rd1;
398  full_chk_rd1 <= full_chk_d1;
399  full_chk_rd2 <= full_chk_rd1;
400  END IF;
401  END PROCESS;
402 
403  RESET_EN <= reset_en_rd2;
404 
405 
406  data_fifo_en:IF(C_CH_TYPE /= 2) GENERATE
407  -----------------------------------------------------
408  -- WR_EN GENERATION
409  -----------------------------------------------------
410  gen_rand_wr_en:ethernetFIFO_rng
411  GENERIC MAP(
412  WIDTH => 8,
413  SEED => TB_SEED+1
414  )
415  PORT MAP(
416  CLK => WR_CLK,
417  RESET => RESET_WR,
418  RANDOM_NUM => wr_en_gen,
419  ENABLE => '1'
420  );
421 
422  PROCESS(WR_CLK,RESET_WR)
423  BEGIN
424  IF(RESET_WR = '1') THEN
425  wr_en_i <= '0';
426  ELSIF(WR_CLK'event AND WR_CLK='1') THEN
427  IF(state = '1') THEN
428  wr_en_i <= wr_en_gen(0) AND wr_en_gen(7) AND wr_en_gen(2) AND wr_control;
429  ELSE
430  wr_en_i <= (wr_en_gen(3) OR wr_en_gen(4) OR wr_en_gen(2)) AND (NOT post_rst_dly_wr(4));
431  END IF;
432  END IF;
433  END PROCESS;
434 
435  -----------------------------------------------------
436  -- WR_EN CONTROL
437  -----------------------------------------------------
438  PROCESS(WR_CLK,RESET_WR)
439  BEGIN
440  IF(RESET_WR = '1') THEN
441  wr_cntr <= (OTHERS => '0');
442  wr_control <= '1';
443  full_as_timeout <= (OTHERS => '0');
444  ELSIF(WR_CLK'event AND WR_CLK='1') THEN
445  IF(state = '1') THEN
446  IF(wr_en_i = '1') THEN
447  wr_cntr <= wr_cntr + "1";
448  END IF;
449  full_as_timeout <= (OTHERS => '0');
450  ELSE
451  wr_cntr <= (OTHERS => '0');
452  IF(rd_en_wr2 = '0') THEN
453  IF(wr_en_i = '1') THEN
454  full_as_timeout <= full_as_timeout + "1";
455  END IF;
456  ELSE
457  full_as_timeout <= (OTHERS => '0');
458  END IF;
459  END IF;
460 
461  wr_control <= NOT wr_cntr(wr_cntr'high);
462 
463  END IF;
464  END PROCESS;
465 
466  -----------------------------------------------------
467  -- RD_EN GENERATION
468  -----------------------------------------------------
469  gen_rand_rd_en:ethernetFIFO_rng
470  GENERIC MAP(
471  WIDTH => 8,
472  SEED => TB_SEED
473  )
474  PORT MAP(
475  CLK => RD_CLK,
476  RESET => RESET_RD,
477  RANDOM_NUM => rd_en_gen,
478  ENABLE => '1'
479  );
480 
481  PROCESS(RD_CLK,RESET_RD)
482  BEGIN
483  IF(RESET_RD = '1') THEN
484  rd_en_i <= '0';
485  ELSIF(RD_CLK'event AND RD_CLK='1') THEN
486  IF(state_rd_dom2 = '0') THEN
487  rd_en_i <= rd_en_gen(1) AND rd_en_gen(5) AND rd_en_gen(3) AND rd_control AND (NOT post_rst_dly_rd(4));
488  ELSE
489  rd_en_i <= rd_en_gen(0) OR rd_en_gen(6);
490  END IF;
491  END IF;
492  END PROCESS;
493 
494  -----------------------------------------------------
495  -- RD_EN CONTROL
496  -----------------------------------------------------
497  PROCESS(RD_CLK,RESET_RD)
498  BEGIN
499  IF(RESET_RD = '1') THEN
500  rd_cntr <= (OTHERS => '0');
501  rd_control <= '1';
502  empty_as_timeout <= (OTHERS => '0');
503  ELSIF(RD_CLK'event AND RD_CLK='1') THEN
504  IF(state_rd_dom2 = '0') THEN
505  IF(rd_en_i = '1') THEN
506  rd_cntr <= rd_cntr + "1";
507  END IF;
508  empty_as_timeout <= (OTHERS => '0');
509  ELSE
510  rd_cntr <= (OTHERS => '0');
511  IF(wr_en_rd2 = '0') THEN
512  IF(rd_en_i = '1') THEN
513  empty_as_timeout <= empty_as_timeout + "1";
514  END IF;
515  ELSE
516  empty_as_timeout <= (OTHERS => '0');
517  END IF;
518  END IF;
519 
520  rd_control <= NOT rd_cntr(rd_cntr'high);
521 
522  END IF;
523  END PROCESS;
524 
525  -----------------------------------------------------
526  -- STIMULUS CONTROL
527  -----------------------------------------------------
528  PROCESS(WR_CLK,RESET_WR)
529  BEGIN
530  IF(RESET_WR = '1') THEN
531  state <= '0';
532  reset_en_i <= '0';
533  ELSIF(WR_CLK'event AND WR_CLK='1') THEN
534  CASE state IS
535  WHEN '0' =>
536  IF(FULL = '1' AND empty_wr_dom2 = '0') THEN
537  state <= '1';
538  reset_en_i <= '0';
539  END IF;
540  WHEN '1' =>
541  IF(empty_wr_dom2 = '1' AND FULL = '0') THEN
542  state <= '0';
543  reset_en_i <= '1';
544  END IF;
545  WHEN OTHERS => state <= state;
546  END CASE;
547  END IF;
548  END PROCESS;
549  END GENERATE data_fifo_en;
550 
551 END ARCHITECTURE;