otsdaq_prepmodernization  v2_05_02_indev
Ethernet_RAM_tb_synth.vhd
1 
2 --------------------------------------------------------------------------------
3 --
4 -- DIST MEM GEN Core - Synthesizable Testbench
5 --
6 --------------------------------------------------------------------------------
7 --
8 -- (c) Copyright 2006_3010 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 --
56 -- Filename: Ethernet_RAM_tb_synth.vhd
57 --
58 -- Description:
59 -- Synthesizable Testbench
60 --------------------------------------------------------------------------------
61 -- Author: IP Solutions Division
62 --
63 -- History: Sep 12, 2011 - First Release
64 --------------------------------------------------------------------------------
65 --
66 --------------------------------------------------------------------------------
67 -- Library Declarations
68 --------------------------------------------------------------------------------
69 
70 LIBRARY IEEE;
71 USE IEEE.STD_LOGIC_1164.ALL;
72 USE IEEE.STD_LOGIC_UNSIGNED.ALL;
73 USE IEEE.STD_LOGIC_ARITH.ALL;
74 USE IEEE.NUMERIC_STD.ALL;
75 USE IEEE.STD_LOGIC_MISC.ALL;
76 
77 LIBRARY STD;
78 USE STD.TEXTIO.ALL;
79 
80 --LIBRARY unisim;
81 --USE unisim.vcomponents.ALL;
82 
83 LIBRARY work;
84 USE work.ALL;
85 USE work.Ethernet_RAM_TB_PKG.ALL;
86 
88 GENERIC (
89  C_ROM_SYNTH : INTEGER := 0
90  );
91 PORT(
92  CLK_IN : IN STD_LOGIC;
93  RESET_IN : IN STD_LOGIC;
94  STATUS : OUT STD_LOGIC_VECTOR(8 DOWNTO 0) := (OTHERS => '0') --ERROR STATUS OUT OF FPGA
95  );
96 END Ethernet_RAM_tb_synth;
97 
98 ARCHITECTURE Ethernet_RAM_synth_ARCH OF Ethernet_RAM_tb_synth IS
99 
100 COMPONENT Ethernet_RAM_exdes
101  PORT (
102  CLK : IN STD_LOGIC := '0';
103  WE : IN STD_LOGIC := '0';
104  SPO : OUT STD_LOGIC_VECTOR(64-1 downto 0);
105  A : IN STD_LOGIC_VECTOR(11-1-(4*0*boolean'pos(11>4)) downto 0)
106  := (OTHERS => '0');
107  D : IN STD_LOGIC_VECTOR(64-1 downto 0) := (OTHERS => '0')
108  );
109 
110 END COMPONENT;
111 
112  CONSTANT STIM_CNT : INTEGER := if_then_else(C_ROM_SYNTH = 0, 8, 22);
113 
114  SIGNAL CLKA: STD_LOGIC := '0';
115  SIGNAL RSTA: STD_LOGIC := '0';
116  SIGNAL STIMULUS_FLOW : STD_LOGIC_VECTOR(22 DOWNTO 0) := (OTHERS =>'0');
117  SIGNAL clk_in_i : STD_LOGIC;
118 
119  SIGNAL RESET_SYNC_R1 : STD_LOGIC:='1';
120  SIGNAL RESET_SYNC_R2 : STD_LOGIC:='1';
121  SIGNAL RESET_SYNC_R3 : STD_LOGIC:='1';
122 
123  SIGNAL ADDR: STD_LOGIC_VECTOR(10 DOWNTO 0) := (OTHERS => '0');
124  SIGNAL ADDR_R: STD_LOGIC_VECTOR(10 DOWNTO 0) := (OTHERS => '0');
125  SIGNAL WE : STD_LOGIC:='0';
126  SIGNAL WE_R : STD_LOGIC:='0';
127  SIGNAL SPO: STD_LOGIC_VECTOR(63 DOWNTO 0) := (OTHERS => '0');
128  SIGNAL SPO_R: STD_LOGIC_VECTOR(63 DOWNTO 0) := (OTHERS => '0');
129  SIGNAL D: STD_LOGIC_VECTOR(63 DOWNTO 0) := (OTHERS => '0');
130  SIGNAL D_R: STD_LOGIC_VECTOR(63 DOWNTO 0) := (OTHERS => '0');
131  SIGNAL CHECKER_EN: STD_LOGIC:='0';
132  SIGNAL CHECKER_EN_R: STD_LOGIC:='0';
133  SIGNAL ITER_R0 : STD_LOGIC := '0';
134  SIGNAL ITER_R1 : STD_LOGIC := '0';
135  SIGNAL ITER_R2 : STD_LOGIC := '0';
136 
137  SIGNAL ISSUE_FLAG : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
138  SIGNAL ISSUE_FLAG_STATUS : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
139 
140 BEGIN
141 
142  clk_in_i <= CLK_IN;
143  CLKA <= clk_in_i;
144  RSTA <= RESET_SYNC_R3 AFTER 50 ns;
145 
146  PROCESS(clk_in_i)
147  BEGIN
148  IF(RISING_EDGE(clk_in_i)) THEN
149  RESET_SYNC_R1 <= RESET_IN;
150  RESET_SYNC_R2 <= RESET_SYNC_R1;
151  RESET_SYNC_R3 <= RESET_SYNC_R2;
152  END IF;
153  END PROCESS;
154 
155 PROCESS(CLKA)
156 BEGIN
157  IF(RISING_EDGE(CLKA)) THEN
158  IF(RESET_SYNC_R3='1') THEN
159  ISSUE_FLAG_STATUS<= (OTHERS => '0');
160  ELSE
161  ISSUE_FLAG_STATUS <= ISSUE_FLAG_STATUS OR ISSUE_FLAG;
162  END IF;
163  END IF;
164 END PROCESS;
165 
166 STATUS(7 DOWNTO 0) <= ISSUE_FLAG_STATUS;
167 
168  Ethernet_RAM_TB_STIM_GEN_INST:ENTITY work.Ethernet_RAM_TB_STIM_GEN
169  PORT MAP(
170  CLK => clk_in_i ,
171  RST => RSTA,
172  A => ADDR,
173  D => D,
174  WE => WE,
175  DATA_IN => SPO_R,
176  CHECK_DATA => CHECKER_EN
177  );
178  DMG_DATA_CHECKER_INST: ENTITY work.Ethernet_RAM_TB_CHECKER
179  GENERIC MAP (
180  WRITE_WIDTH => 64,
181  READ_WIDTH => 64 )
182  PORT MAP (
183  CLK => CLKA,
184  RST => RSTA,
185  EN => CHECKER_EN_R ,
186  DATA_IN => SPO_R,
187  STATUS => ISSUE_FLAG(0)
188  );
189 
190  PROCESS(CLKA)
191  BEGIN
192  IF(RISING_EDGE(CLKA)) THEN
193  IF(RSTA='1') THEN
194  CHECKER_EN_R <= '0';
195  ELSE
196  CHECKER_EN_R <= CHECKER_EN AFTER 50 ns;
197  END IF;
198  END IF;
199  END PROCESS;
200 
201 
202 
203  PROCESS(CLKA)
204  BEGIN
205  IF(RISING_EDGE(CLKA)) THEN
206  IF(RESET_SYNC_R3='1') THEN
207  STATUS(8) <= '0';
208  iter_r2 <= '0';
209  iter_r1 <= '0';
210  iter_r0 <= '0';
211  ELSE
212  STATUS(8) <= iter_r2;
213  iter_r2 <= iter_r1;
214  iter_r1 <= iter_r0;
215  iter_r0 <= STIMULUS_FLOW(STIM_CNT);
216  END IF;
217  END IF;
218  END PROCESS;
219 
220  PROCESS(CLKA)
221  BEGIN
222  IF(RISING_EDGE(CLKA)) THEN
223  IF(RESET_SYNC_R3='1') THEN
224  STIMULUS_FLOW <= (OTHERS => '0');
225  ELSIF(ADDR(0)='1') THEN
226  STIMULUS_FLOW <= STIMULUS_FLOW + 1;
227  END IF;
228  END IF;
229  END PROCESS;
230 
231  PROCESS(CLKA)
232  BEGIN
233  IF(RISING_EDGE(CLKA)) THEN
234  IF(RESET_SYNC_R3='1') THEN
235  WE_R <= '0' AFTER 50 ns;
236  SPO_R <= (OTHERS=>'0') AFTER 50 ns;
237  D_R <= (OTHERS=>'0') AFTER 50 ns;
238  ELSE
239  WE_R <= WE AFTER 50 ns;
240  SPO_R <= SPO AFTER 50 ns;
241  D_R <= D AFTER 50 ns;
242  END IF;
243  END IF;
244  END PROCESS;
245 
246  PROCESS(CLKA)
247  BEGIN
248  IF(RISING_EDGE(CLKA)) THEN
249  IF(RESET_SYNC_R3='1') THEN
250  ADDR_R <= (OTHERS=> '0') AFTER 50 ns;
251  ELSE
252  ADDR_R <= ADDR AFTER 50 ns;
253  END IF;
254  END IF;
255  END PROCESS;
256 
257  DMG_PORT: Ethernet_RAM_exdes PORT MAP (
258  CLK => CLKA,
259  WE => WE_R,
260  SPO => SPO,
261  A => ADDR_R,
262  D => D_R
263 
264  );
265 END ARCHITECTURE;