otsdaq_prepmodernization  v2_05_02_indev
buf_one_synth.vhd
1 
2 
3 
4 
5 
6 
7 
8 
9 --------------------------------------------------------------------------------
10 --
11 -- BLK MEM GEN v7_3 Core - Synthesizable Testbench
12 --
13 --------------------------------------------------------------------------------
14 --
15 -- (c) Copyright 2006_3010 Xilinx, Inc. All rights reserved.
16 --
17 -- This file contains confidential and proprietary information
18 -- of Xilinx, Inc. and is protected under U.S. and
19 -- international copyright and other intellectual property
20 -- laws.
21 --
22 -- DISCLAIMER
23 -- This disclaimer is not a license and does not grant any
24 -- rights to the materials distributed herewith. Except as
25 -- otherwise provided in a valid license issued to you by
26 -- Xilinx, and to the maximum extent permitted by applicable
27 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
28 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
29 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
30 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
31 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
32 -- (2) Xilinx shall not be liable (whether in contract or tort,
33 -- including negligence, or under any other theory of
34 -- liability) for any loss or damage of any kind or nature
35 -- related to, arising under or in connection with these
36 -- materials, including for any direct, or any indirect,
37 -- special, incidental, or consequential loss or damage
38 -- (including loss of data, profits, goodwill, or any type of
39 -- loss or damage suffered as a result of any action brought
40 -- by a third party) even if such damage or loss was
41 -- reasonably foreseeable or Xilinx had been advised of the
42 -- possibility of the same.
43 --
44 -- CRITICAL APPLICATIONS
45 -- Xilinx products are not designed or intended to be fail-
46 -- safe, or for use in any application requiring fail-safe
47 -- performance, such as life-support or safety devices or
48 -- systems, Class III medical devices, nuclear facilities,
49 -- applications related to the deployment of airbags, or any
50 -- other applications that could lead to death, personal
51 -- injury, or severe property or environmental damage
52 -- (individually and collectively, "Critical
53 -- Applications"). Customer assumes the sole risk and
54 -- liability of any use of Xilinx products in Critical
55 -- Applications, subject only to applicable laws and
56 -- regulations governing limitations on product liability.
57 --
58 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
59 -- PART OF THIS FILE AT ALL TIMES.
60 
61 --------------------------------------------------------------------------------
62 --
63 -- Filename: buf_one_synth.vhd
64 --
65 -- Description:
66 -- Synthesizable Testbench
67 --------------------------------------------------------------------------------
68 -- Author: IP Solutions Division
69 --
70 -- History: Sep 12, 2011 - First Release
71 --------------------------------------------------------------------------------
72 --
73 --------------------------------------------------------------------------------
74 -- Library Declarations
75 --------------------------------------------------------------------------------
76 
77 LIBRARY IEEE;
78 USE IEEE.STD_LOGIC_1164.ALL;
79 USE IEEE.STD_LOGIC_UNSIGNED.ALL;
80 USE IEEE.STD_LOGIC_ARITH.ALL;
81 USE IEEE.NUMERIC_STD.ALL;
82 USE IEEE.STD_LOGIC_MISC.ALL;
83 
84 LIBRARY STD;
85 USE STD.TEXTIO.ALL;
86 
87 --LIBRARY unisim;
88 --USE unisim.vcomponents.ALL;
89 
90 LIBRARY work;
91 USE work.ALL;
92 USE work.BMG_TB_PKG.ALL;
93 
94 ENTITY buf_one_synth IS
95 PORT(
96  CLK_IN : IN STD_LOGIC;
97  CLKB_IN : IN STD_LOGIC;
98  RESET_IN : IN STD_LOGIC;
99  STATUS : OUT STD_LOGIC_VECTOR(8 DOWNTO 0) := (OTHERS => '0') --ERROR STATUS OUT OF FPGA
100  );
101 END ENTITY;
102 
103 ARCHITECTURE buf_one_synth_ARCH OF buf_one_synth IS
104 
105 
106 COMPONENT buf_one_exdes
107  PORT (
108  --Inputs - Port A
109  WEA : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
110  ADDRA : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
111  DINA : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
112  CLKA : IN STD_LOGIC;
113 
114  --Inputs - Port B
115  ADDRB : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
116  DOUTB : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
117  CLKB : IN STD_LOGIC
118 
119  );
120 
121 END COMPONENT;
122 
123 
124  SIGNAL CLKA: STD_LOGIC := '0';
125  SIGNAL RSTA: STD_LOGIC := '0';
126  SIGNAL WEA: STD_LOGIC_VECTOR(0 DOWNTO 0) := (OTHERS => '0');
127  SIGNAL WEA_R: STD_LOGIC_VECTOR(0 DOWNTO 0) := (OTHERS => '0');
128  SIGNAL ADDRA: STD_LOGIC_VECTOR(9 DOWNTO 0) := (OTHERS => '0');
129  SIGNAL ADDRA_R: STD_LOGIC_VECTOR(9 DOWNTO 0) := (OTHERS => '0');
130  SIGNAL DINA: STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
131  SIGNAL DINA_R: STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
132  SIGNAL CLKB: STD_LOGIC := '0';
133  SIGNAL RSTB: STD_LOGIC := '0';
134  SIGNAL ADDRB: STD_LOGIC_VECTOR(9 DOWNTO 0) := (OTHERS => '0');
135  SIGNAL ADDRB_R: STD_LOGIC_VECTOR(9 DOWNTO 0) := (OTHERS => '0');
136  SIGNAL DOUTB: STD_LOGIC_VECTOR(31 DOWNTO 0);
137  SIGNAL CHECKER_EN : STD_LOGIC:='0';
138  SIGNAL CHECKER_EN_R : STD_LOGIC:='0';
139  SIGNAL STIMULUS_FLOW : STD_LOGIC_VECTOR(22 DOWNTO 0) := (OTHERS =>'0');
140  SIGNAL clk_in_i: STD_LOGIC;
141 
142  SIGNAL RESET_SYNC_R1 : STD_LOGIC:='1';
143  SIGNAL RESET_SYNC_R2 : STD_LOGIC:='1';
144  SIGNAL RESET_SYNC_R3 : STD_LOGIC:='1';
145 
146  SIGNAL clkb_in_i: STD_LOGIC;
147  SIGNAL RESETB_SYNC_R1 : STD_LOGIC := '1';
148  SIGNAL RESETB_SYNC_R2 : STD_LOGIC := '1';
149  SIGNAL RESETB_SYNC_R3 : STD_LOGIC := '1';
150  SIGNAL ITER_R0 : STD_LOGIC := '0';
151  SIGNAL ITER_R1 : STD_LOGIC := '0';
152  SIGNAL ITER_R2 : STD_LOGIC := '0';
153 
154  SIGNAL ISSUE_FLAG : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
155  SIGNAL ISSUE_FLAG_STATUS : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
156 
157  BEGIN
158 
159 -- clk_buf: bufg
160 -- PORT map(
161 -- i => CLK_IN,
162 -- o => clk_in_i
163 -- );
164  clk_in_i <= CLK_IN;
165  CLKA <= clk_in_i;
166 
167 -- clkb_buf: bufg
168 -- PORT map(
169 -- i => CLKB_IN,
170 -- o => clkb_in_i
171 -- );
172  clkb_in_i <= CLKB_IN;
173  CLKB <= clkb_in_i;
174  RSTA <= RESET_SYNC_R3 AFTER 50 ns;
175 
176 
177  PROCESS(clk_in_i)
178  BEGIN
179  IF(RISING_EDGE(clk_in_i)) THEN
180  RESET_SYNC_R1 <= RESET_IN;
181  RESET_SYNC_R2 <= RESET_SYNC_R1;
182  RESET_SYNC_R3 <= RESET_SYNC_R2;
183  END IF;
184  END PROCESS;
185 
186  RSTB <= RESETB_SYNC_R3 AFTER 50 ns;
187 
188  PROCESS(clkb_in_i)
189  BEGIN
190  IF(RISING_EDGE(clkb_in_i)) THEN
191  RESETB_SYNC_R1 <= RESET_IN;
192  RESETB_SYNC_R2 <= RESETB_SYNC_R1;
193  RESETB_SYNC_R3 <= RESETB_SYNC_R2;
194  END IF;
195  END PROCESS;
196 
197 PROCESS(CLKA)
198 BEGIN
199  IF(RISING_EDGE(CLKA)) THEN
200  IF(RESET_SYNC_R3='1') THEN
201  ISSUE_FLAG_STATUS<= (OTHERS => '0');
202  ELSE
203  ISSUE_FLAG_STATUS <= ISSUE_FLAG_STATUS OR ISSUE_FLAG;
204  END IF;
205  END IF;
206 END PROCESS;
207 
208 STATUS(7 DOWNTO 0) <= ISSUE_FLAG_STATUS;
209 
210 
211 
212 
213  BMG_DATA_CHECKER_INST: ENTITY work.CHECKER
214  GENERIC MAP (
215  WRITE_WIDTH => 32,
216  READ_WIDTH => 32 )
217  PORT MAP (
218  CLK => clkb_in_i,
219  RST => RSTB,
220  EN => CHECKER_EN_R ,
221  DATA_IN => DOUTB,
222  STATUS => ISSUE_FLAG(0)
223  );
224 
225  PROCESS(clkb_in_i)
226  BEGIN
227  IF(RISING_EDGE(clkb_in_i)) THEN
228  IF(RSTB='1') THEN
229  CHECKER_EN_R <= '0';
230  ELSE
231  CHECKER_EN_R <= CHECKER_EN AFTER 50 ns;
232  END IF;
233  END IF;
234  END PROCESS;
235 
236 
237  BMG_STIM_GEN_INST:ENTITY work.BMG_STIM_GEN
238  PORT MAP(
239  CLKA => clk_in_i,
240  CLKB => clkb_in_i,
241  TB_RST => RSTA,
242  ADDRA => ADDRA,
243  DINA => DINA,
244  WEA => WEA,
245  ADDRB => ADDRB,
246  CHECK_DATA => CHECKER_EN
247  );
248  PROCESS(CLKA)
249  BEGIN
250  IF(RISING_EDGE(CLKA)) THEN
251  IF(RESET_SYNC_R3='1') THEN
252  STATUS(8) <= '0';
253  iter_r2 <= '0';
254  iter_r1 <= '0';
255  iter_r0 <= '0';
256  ELSE
257  STATUS(8) <= iter_r2;
258  iter_r2 <= iter_r1;
259  iter_r1 <= iter_r0;
260  iter_r0 <= STIMULUS_FLOW(8);
261  END IF;
262  END IF;
263  END PROCESS;
264 
265 
266  PROCESS(CLKA)
267  BEGIN
268  IF(RISING_EDGE(CLKA)) THEN
269  IF(RESET_SYNC_R3='1') THEN
270  STIMULUS_FLOW <= (OTHERS => '0');
271  ELSIF(WEA(0)='1') THEN
272  STIMULUS_FLOW <= STIMULUS_FLOW+1;
273  END IF;
274  END IF;
275  END PROCESS;
276 
277 
278 
279  PROCESS(CLKA)
280  BEGIN
281  IF(RISING_EDGE(CLKA)) THEN
282  IF(RESET_SYNC_R3='1') THEN
283  WEA_R <= (OTHERS=>'0') AFTER 50 ns;
284  DINA_R <= (OTHERS=>'0') AFTER 50 ns;
285 
286 
287  ELSE
288  WEA_R <= WEA AFTER 50 ns;
289  DINA_R <= DINA AFTER 50 ns;
290 
291  END IF;
292  END IF;
293  END PROCESS;
294 
295 
296  PROCESS(CLKA)
297  BEGIN
298  IF(RISING_EDGE(CLKA)) THEN
299  IF(RESET_SYNC_R3='1') THEN
300  ADDRA_R <= (OTHERS=> '0') AFTER 50 ns;
301  ADDRB_R <= (OTHERS=> '0') AFTER 50 ns;
302  ELSE
303  ADDRA_R <= ADDRA AFTER 50 ns;
304  ADDRB_R <= ADDRB AFTER 50 ns;
305  END IF;
306  END IF;
307  END PROCESS;
308 
309 
310  BMG_PORT: buf_one_exdes PORT MAP (
311  --Port A
312  WEA => WEA_R,
313  ADDRA => ADDRA_R,
314  DINA => DINA_R,
315  CLKA => CLKA,
316  --Port B
317  ADDRB => ADDRB_R,
318  DOUTB => DOUTB,
319  CLKB => CLKB
320 
321  );
322 END ARCHITECTURE;