1 |
16 |
gedra |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- WISHBONE I2S Interface IP Core ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- This file is part of the I2S Interface project ----
|
6 |
|
|
---- http://www.opencores.org/cores/i2s_interface/ ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Description ----
|
9 |
|
|
---- I2S top level test bench. Two transmitters and two receivers ----
|
10 |
|
|
---- are instantiated, one each in slave and master mode. ----
|
11 |
|
|
---- Test result is displayed in the log window, there should ----
|
12 |
|
|
---- be no errors. ----
|
13 |
|
|
---- ----
|
14 |
|
|
---- To Do: ----
|
15 |
|
|
---- - ----
|
16 |
|
|
---- ----
|
17 |
|
|
---- Author(s): ----
|
18 |
|
|
---- - Geir Drange, gedra@opencores.org ----
|
19 |
|
|
---- ----
|
20 |
|
|
----------------------------------------------------------------------
|
21 |
|
|
---- ----
|
22 |
|
|
---- Copyright (C) 2004 Authors and OPENCORES.ORG ----
|
23 |
|
|
---- ----
|
24 |
|
|
---- This source file may be used and distributed without ----
|
25 |
|
|
---- restriction provided that this copyright statement is not ----
|
26 |
|
|
---- removed from the file and that any derivative work contains ----
|
27 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
28 |
|
|
---- ----
|
29 |
|
|
---- This source file is free software; you can redistribute it ----
|
30 |
|
|
---- and/or modify it under the terms of the GNU General ----
|
31 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
32 |
|
|
---- either version 2.0 of the License, or (at your option) any ----
|
33 |
|
|
---- later version. ----
|
34 |
|
|
---- ----
|
35 |
|
|
---- This source is distributed in the hope that it will be ----
|
36 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
37 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
38 |
19 |
gedra |
---- PURPOSE. See the GNU General Public License for more details.----
|
39 |
16 |
gedra |
---- ----
|
40 |
|
|
---- You should have received a copy of the GNU General ----
|
41 |
|
|
---- Public License along with this source; if not, download it ----
|
42 |
|
|
---- from http://www.gnu.org/licenses/gpl.txt ----
|
43 |
|
|
---- ----
|
44 |
|
|
----------------------------------------------------------------------
|
45 |
|
|
--
|
46 |
|
|
-- CVS Revision History
|
47 |
|
|
--
|
48 |
|
|
-- $Log: not supported by cvs2svn $
|
49 |
19 |
gedra |
-- Revision 1.1 2004/08/04 14:31:02 gedra
|
50 |
|
|
-- Top level test bench.
|
51 |
16 |
gedra |
--
|
52 |
|
|
--
|
53 |
19 |
gedra |
--
|
54 |
16 |
gedra |
|
55 |
|
|
library ieee;
|
56 |
|
|
use ieee.std_logic_1164.all;
|
57 |
|
|
use ieee.numeric_std.all;
|
58 |
|
|
use work.wb_tb_pack.all;
|
59 |
|
|
|
60 |
|
|
entity tb_i2s is
|
61 |
|
|
|
62 |
|
|
end tb_i2s;
|
63 |
|
|
|
64 |
|
|
architecture behav of tb_i2s is
|
65 |
|
|
|
66 |
|
|
component tx_i2s_topm
|
67 |
|
|
generic (DATA_WIDTH: integer range 16 to 32;
|
68 |
|
|
ADDR_WIDTH: integer range 5 to 32);
|
69 |
|
|
port (
|
70 |
|
|
-- Wishbone interface
|
71 |
|
|
wb_clk_i: in std_logic;
|
72 |
|
|
wb_rst_i: in std_logic;
|
73 |
|
|
wb_sel_i: in std_logic;
|
74 |
|
|
wb_stb_i: in std_logic;
|
75 |
|
|
wb_we_i: in std_logic;
|
76 |
|
|
wb_cyc_i: in std_logic;
|
77 |
|
|
wb_bte_i: in std_logic_vector(1 downto 0);
|
78 |
|
|
wb_cti_i: in std_logic_vector(2 downto 0);
|
79 |
|
|
wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);
|
80 |
|
|
wb_dat_i: in std_logic_vector(DATA_WIDTH -1 downto 0);
|
81 |
|
|
wb_ack_o: out std_logic;
|
82 |
|
|
wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);
|
83 |
|
|
-- Interrupt line
|
84 |
|
|
tx_int_o: out std_logic;
|
85 |
|
|
-- I2S signals
|
86 |
|
|
i2s_sd_o: out std_logic;
|
87 |
|
|
i2s_sck_o: out std_logic;
|
88 |
|
|
i2s_ws_o: out std_logic);
|
89 |
|
|
end component;
|
90 |
|
|
|
91 |
|
|
component tx_i2s_tops
|
92 |
|
|
generic (DATA_WIDTH: integer range 16 to 32;
|
93 |
|
|
ADDR_WIDTH: integer range 5 to 32);
|
94 |
|
|
port (
|
95 |
|
|
wb_clk_i: in std_logic;
|
96 |
|
|
wb_rst_i: in std_logic;
|
97 |
|
|
wb_sel_i: in std_logic;
|
98 |
|
|
wb_stb_i: in std_logic;
|
99 |
|
|
wb_we_i: in std_logic;
|
100 |
|
|
wb_cyc_i: in std_logic;
|
101 |
|
|
wb_bte_i: in std_logic_vector(1 downto 0);
|
102 |
|
|
wb_cti_i: in std_logic_vector(2 downto 0);
|
103 |
|
|
wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);
|
104 |
|
|
wb_dat_i: in std_logic_vector(DATA_WIDTH -1 downto 0);
|
105 |
|
|
i2s_sck_i: in std_logic;
|
106 |
|
|
i2s_ws_i: in std_logic;
|
107 |
|
|
wb_ack_o: out std_logic;
|
108 |
|
|
wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);
|
109 |
|
|
tx_int_o: out std_logic;
|
110 |
|
|
i2s_sd_o: out std_logic);
|
111 |
|
|
end component;
|
112 |
|
|
|
113 |
|
|
component rx_i2s_topm
|
114 |
|
|
generic (DATA_WIDTH: integer range 16 to 32;
|
115 |
|
|
ADDR_WIDTH: integer range 5 to 32);
|
116 |
|
|
port (
|
117 |
|
|
wb_clk_i: in std_logic;
|
118 |
|
|
wb_rst_i: in std_logic;
|
119 |
|
|
wb_sel_i: in std_logic;
|
120 |
|
|
wb_stb_i: in std_logic;
|
121 |
|
|
wb_we_i: in std_logic;
|
122 |
|
|
wb_cyc_i: in std_logic;
|
123 |
|
|
wb_bte_i: in std_logic_vector(1 downto 0);
|
124 |
|
|
wb_cti_i: in std_logic_vector(2 downto 0);
|
125 |
|
|
wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);
|
126 |
|
|
wb_dat_i: in std_logic_vector(DATA_WIDTH -1 downto 0);
|
127 |
|
|
i2s_sd_i: in std_logic; -- I2S data input
|
128 |
|
|
wb_ack_o: out std_logic;
|
129 |
|
|
wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);
|
130 |
|
|
rx_int_o: out std_logic; -- Interrupt line
|
131 |
|
|
i2s_sck_o: out std_logic; -- I2S clock out
|
132 |
|
|
i2s_ws_o: out std_logic); -- I2S word select out
|
133 |
|
|
end component;
|
134 |
|
|
|
135 |
|
|
component rx_i2s_tops
|
136 |
|
|
generic (DATA_WIDTH: integer range 16 to 32;
|
137 |
|
|
ADDR_WIDTH: integer range 5 to 32);
|
138 |
|
|
port (
|
139 |
|
|
wb_clk_i: in std_logic;
|
140 |
|
|
wb_rst_i: in std_logic;
|
141 |
|
|
wb_sel_i: in std_logic;
|
142 |
|
|
wb_stb_i: in std_logic;
|
143 |
|
|
wb_we_i: in std_logic;
|
144 |
|
|
wb_cyc_i: in std_logic;
|
145 |
|
|
wb_bte_i: in std_logic_vector(1 downto 0);
|
146 |
|
|
wb_cti_i: in std_logic_vector(2 downto 0);
|
147 |
|
|
wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);
|
148 |
|
|
wb_dat_i: in std_logic_vector(DATA_WIDTH -1 downto 0);
|
149 |
|
|
i2s_sd_i: in std_logic; -- I2S data input
|
150 |
|
|
i2s_sck_i: in std_logic; -- I2S clock input
|
151 |
|
|
i2s_ws_i: in std_logic; -- I2S word select input
|
152 |
|
|
wb_ack_o: out std_logic;
|
153 |
|
|
wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);
|
154 |
|
|
rx_int_o: out std_logic); -- Interrupt line
|
155 |
|
|
end component;
|
156 |
|
|
|
157 |
|
|
signal wb_clk_o, wb_rst_o, wb_sel_o, wb_stb_o, wb_we_o : std_logic;
|
158 |
|
|
signal wb_cyc_o, wb_ack_i, rx1_int_o: std_logic;
|
159 |
|
|
signal tx_int_o, tx1_ack, rx1_ack, tx2_ack, rx2_ack : std_logic;
|
160 |
|
|
signal rx2_int_o, tx1_int_o, tx2_int_o : std_logic;
|
161 |
|
|
signal wb_bte_o : std_logic_vector(1 downto 0);
|
162 |
|
|
signal wb_cti_o : std_logic_vector(2 downto 0);
|
163 |
|
|
signal wb_adr_o : std_logic_vector(15 downto 0);
|
164 |
|
|
signal wb_dat_i, wb_dat_o, rx1_dat_i: std_logic_vector(31 downto 0);
|
165 |
|
|
signal tx1_dat_i, rx2_dat_i, tx2_dat_i: std_logic_vector(31 downto 0);
|
166 |
|
|
signal wb_stb_32bit_rx1, wb_stb_32bit_tx1 : std_logic;
|
167 |
|
|
signal wb_stb_32bit_rx2, wb_stb_32bit_tx2 : std_logic;
|
168 |
|
|
signal i2s_sd1, i2s_sd2, i2s_sck1, i2s_sck2, i2s_ws1, i2s_ws2: std_logic;
|
169 |
|
|
-- register address definitions
|
170 |
|
|
constant RX1_VERSION : natural := 16#1000#;
|
171 |
|
|
constant RX1_CONFIG : natural := 16#1001#;
|
172 |
|
|
constant RX1_INTMASK : natural := 16#1002#;
|
173 |
|
|
constant RX1_INTSTAT : natural := 16#1003#;
|
174 |
|
|
constant RX1_BUF_BASE: natural := 16#1020#;
|
175 |
|
|
constant TX1_VERSION : natural := 16#2000#;
|
176 |
|
|
constant TX1_CONFIG : natural := 16#2001#;
|
177 |
|
|
constant TX1_INTMASK : natural := 16#2002#;
|
178 |
|
|
constant TX1_INTSTAT : natural := 16#2003#;
|
179 |
|
|
constant TX1_BUF_BASE: natural := 16#2020#;
|
180 |
|
|
constant RX2_VERSION : natural := 16#3000#;
|
181 |
|
|
constant RX2_CONFIG : natural := 16#3001#;
|
182 |
|
|
constant RX2_INTMASK : natural := 16#3002#;
|
183 |
|
|
constant RX2_INTSTAT : natural := 16#3003#;
|
184 |
|
|
constant RX2_BUF_BASE: natural := 16#3020#;
|
185 |
|
|
constant TX2_VERSION : natural := 16#4000#;
|
186 |
|
|
constant TX2_CONFIG : natural := 16#4001#;
|
187 |
|
|
constant TX2_INTMASK : natural := 16#4002#;
|
188 |
|
|
constant TX2_INTSTAT : natural := 16#4003#;
|
189 |
|
|
constant TX2_BUF_BASE: natural := 16#4020#;
|
190 |
|
|
|
191 |
|
|
begin
|
192 |
|
|
|
193 |
|
|
wb_ack_i <= rx1_ack or tx1_ack or rx2_ack or tx2_ack;
|
194 |
|
|
wb_dat_i <= rx1_dat_i when wb_stb_32bit_rx1 = '1'
|
195 |
|
|
else tx1_dat_i when wb_stb_32bit_tx1 = '1'
|
196 |
|
|
else rx2_dat_i when wb_stb_32bit_rx2 = '1'
|
197 |
|
|
else tx2_dat_i when wb_stb_32bit_tx2 = '1'
|
198 |
|
|
else (others => '0');
|
199 |
|
|
|
200 |
|
|
-- I2S transmitter 1, slave mode
|
201 |
|
|
ITX32S: tx_i2s_tops
|
202 |
|
|
generic map (DATA_WIDTH => 32,
|
203 |
|
|
ADDR_WIDTH => 6)
|
204 |
|
|
port map (
|
205 |
|
|
-- Wishbone interface
|
206 |
|
|
wb_clk_i => wb_clk_o,
|
207 |
|
|
wb_rst_i => wb_rst_o,
|
208 |
|
|
wb_sel_i => wb_sel_o,
|
209 |
|
|
wb_stb_i => wb_stb_32bit_tx1,
|
210 |
|
|
wb_we_i => wb_we_o,
|
211 |
|
|
wb_cyc_i => wb_cyc_o,
|
212 |
|
|
wb_bte_i => wb_bte_o,
|
213 |
|
|
wb_cti_i => wb_cti_o,
|
214 |
|
|
wb_adr_i => wb_adr_o(5 downto 0),
|
215 |
|
|
wb_dat_i => wb_dat_o(31 downto 0),
|
216 |
|
|
wb_ack_o => tx1_ack,
|
217 |
|
|
wb_dat_o => tx1_dat_i,
|
218 |
|
|
tx_int_o => tx1_int_o,
|
219 |
|
|
i2s_sd_o => i2s_sd1,
|
220 |
|
|
i2s_sck_i => i2s_sck1,
|
221 |
|
|
i2s_ws_i => i2s_ws1);
|
222 |
|
|
|
223 |
|
|
-- I2S transmitter 2, master mode
|
224 |
|
|
ITX32M: tx_i2s_topm
|
225 |
|
|
generic map (DATA_WIDTH => 32,
|
226 |
|
|
ADDR_WIDTH => 6)
|
227 |
|
|
port map (
|
228 |
|
|
-- Wishbone interface
|
229 |
|
|
wb_clk_i => wb_clk_o,
|
230 |
|
|
wb_rst_i => wb_rst_o,
|
231 |
|
|
wb_sel_i => wb_sel_o,
|
232 |
|
|
wb_stb_i => wb_stb_32bit_tx2,
|
233 |
|
|
wb_we_i => wb_we_o,
|
234 |
|
|
wb_cyc_i => wb_cyc_o,
|
235 |
|
|
wb_bte_i => wb_bte_o,
|
236 |
|
|
wb_cti_i => wb_cti_o,
|
237 |
|
|
wb_adr_i => wb_adr_o(5 downto 0),
|
238 |
|
|
wb_dat_i => wb_dat_o(31 downto 0),
|
239 |
|
|
wb_ack_o => tx2_ack,
|
240 |
|
|
wb_dat_o => tx2_dat_i,
|
241 |
|
|
tx_int_o => tx2_int_o,
|
242 |
|
|
i2s_sd_o => i2s_sd2,
|
243 |
|
|
i2s_sck_o => i2s_sck2,
|
244 |
|
|
i2s_ws_o => i2s_ws2);
|
245 |
|
|
|
246 |
|
|
-- I2S receiver 1, master mode
|
247 |
|
|
IRX32M: rx_i2s_topm
|
248 |
|
|
generic map (DATA_WIDTH => 32,
|
249 |
|
|
ADDR_WIDTH => 6)
|
250 |
|
|
port map (
|
251 |
|
|
-- Wishbone interface
|
252 |
|
|
wb_clk_i => wb_clk_o,
|
253 |
|
|
wb_rst_i => wb_rst_o,
|
254 |
|
|
wb_sel_i => wb_sel_o,
|
255 |
|
|
wb_stb_i => wb_stb_32bit_rx1,
|
256 |
|
|
wb_we_i => wb_we_o,
|
257 |
|
|
wb_cyc_i => wb_cyc_o,
|
258 |
|
|
wb_bte_i => wb_bte_o,
|
259 |
|
|
wb_cti_i => wb_cti_o,
|
260 |
|
|
wb_adr_i => wb_adr_o(5 downto 0),
|
261 |
|
|
wb_dat_i => wb_dat_o(31 downto 0),
|
262 |
|
|
i2s_sd_i => i2s_sd1,
|
263 |
|
|
wb_ack_o => rx1_ack,
|
264 |
|
|
wb_dat_o => rx1_dat_i,
|
265 |
|
|
rx_int_o => rx1_int_o,
|
266 |
|
|
i2s_sck_o => i2s_sck1,
|
267 |
|
|
i2s_ws_o => i2s_ws1);
|
268 |
|
|
|
269 |
|
|
-- I2S receiver 2, slave mode
|
270 |
|
|
IRX32S: rx_i2s_tops
|
271 |
|
|
generic map (DATA_WIDTH => 32,
|
272 |
|
|
ADDR_WIDTH => 6)
|
273 |
|
|
port map (
|
274 |
|
|
-- Wishbone interface
|
275 |
|
|
wb_clk_i => wb_clk_o,
|
276 |
|
|
wb_rst_i => wb_rst_o,
|
277 |
|
|
wb_sel_i => wb_sel_o,
|
278 |
|
|
wb_stb_i => wb_stb_32bit_rx2,
|
279 |
|
|
wb_we_i => wb_we_o,
|
280 |
|
|
wb_cyc_i => wb_cyc_o,
|
281 |
|
|
wb_bte_i => wb_bte_o,
|
282 |
|
|
wb_cti_i => wb_cti_o,
|
283 |
|
|
wb_adr_i => wb_adr_o(5 downto 0),
|
284 |
|
|
wb_dat_i => wb_dat_o(31 downto 0),
|
285 |
|
|
i2s_sd_i => i2s_sd2,
|
286 |
|
|
i2s_sck_i => i2s_sck2,
|
287 |
|
|
i2s_ws_i => i2s_ws2,
|
288 |
|
|
wb_ack_o => rx2_ack,
|
289 |
|
|
wb_dat_o => rx2_dat_i,
|
290 |
|
|
rx_int_o => rx2_int_o);
|
291 |
|
|
|
292 |
|
|
-- Main test process
|
293 |
|
|
MAIN: process
|
294 |
|
|
variable read_32bit : std_logic_vector(31 downto 0);
|
295 |
|
|
variable idx : integer;
|
296 |
|
|
|
297 |
|
|
-- Make simplified versions of procedures in wb_tb_pack
|
298 |
|
|
procedure wb_write_32 (
|
299 |
|
|
constant ADDRESS: in natural;
|
300 |
|
|
constant DATA: in natural) is
|
301 |
|
|
begin
|
302 |
|
|
wb_write(ADDRESS, DATA, wb_adr_o, wb_dat_o(31 downto 0), wb_cyc_o,
|
303 |
|
|
wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
|
304 |
|
|
end;
|
305 |
|
|
|
306 |
|
|
procedure wb_check_32 (
|
307 |
|
|
constant ADDRESS: in natural;
|
308 |
|
|
constant EXP_DATA : in natural) is
|
309 |
|
|
begin
|
310 |
|
|
wb_check(ADDRESS, EXP_DATA, wb_adr_o, wb_dat_i(31 downto 0), wb_cyc_o,
|
311 |
|
|
wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
|
312 |
|
|
end;
|
313 |
|
|
|
314 |
|
|
procedure wb_read_32 (
|
315 |
|
|
constant ADDRESS: in natural) is
|
316 |
|
|
begin
|
317 |
|
|
wb_read(ADDRESS, read_32bit, wb_adr_o, wb_dat_i(31 downto 0), wb_cyc_o,
|
318 |
|
|
wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
|
319 |
|
|
end;
|
320 |
|
|
|
321 |
|
|
begin
|
322 |
|
|
message("Simulation start with system reset.");
|
323 |
|
|
wb_rst_o <= '1'; -- system reset
|
324 |
|
|
wb_sel_o <= '0';
|
325 |
|
|
wb_stb_o <= '0';
|
326 |
|
|
wb_sel_o <= '0';
|
327 |
|
|
wb_we_o <= '0';
|
328 |
|
|
wb_cyc_o <= '0';
|
329 |
|
|
wb_bte_o <= "00";
|
330 |
|
|
wb_cti_o <= "000";
|
331 |
|
|
wb_adr_o <= (others => '0');
|
332 |
|
|
wb_dat_o <= (others => '0');
|
333 |
|
|
wait for 200 ns;
|
334 |
|
|
wb_rst_o <= '0';
|
335 |
|
|
message("Check receiver version registers:");
|
336 |
|
|
wb_check_32(RX1_VERSION, 16#000001b1#);
|
337 |
|
|
wb_check_32(RX2_VERSION, 16#00000191#);
|
338 |
|
|
message("Check transmitter version registers:");
|
339 |
|
|
wb_check_32(TX1_VERSION, 16#00000191#);
|
340 |
|
|
wb_check_32(TX2_VERSION, 16#000001b1#);
|
341 |
|
|
message("Fill up sample buffers with test signal, ");
|
342 |
|
|
message("ramp up in left, ramp down in right:");
|
343 |
|
|
SGEN: for i in 0 to 15 loop
|
344 |
|
|
wb_write_32(TX1_BUF_BASE + 2*i, (32768 + i*497)*256); -- left
|
345 |
|
|
wb_write_32(TX1_BUF_BASE + 2*i + 1, (32767 - i*497)*256); -- right
|
346 |
|
|
wb_write_32(TX2_BUF_BASE + 2*i, (32767 - i*497)*16); -- left
|
347 |
|
|
wb_write_32(TX2_BUF_BASE + 2*i + 1, (32768 + i*497)*16); --right
|
348 |
|
|
end loop;
|
349 |
|
|
message("*** Test of master TX and slave RX ***");
|
350 |
|
|
message("Enable transmitter 2:");
|
351 |
|
|
wb_write_32(TX2_INTMASK, 16#00000003#); -- enable interrupts
|
352 |
|
|
wb_write_32(TX2_CONFIG, 16#00140703#); -- 20bit resolution
|
353 |
|
|
message("Enable recevier 2:");
|
354 |
|
|
wb_write_32(RX2_INTMASK, 16#00000003#); -- enable interrupts
|
355 |
|
|
wb_write_32(RX2_CONFIG, 16#00180003#); -- 24bit resolution
|
356 |
|
|
wait_for_event("Wait for transmitter 2 LSBF interrupt", 150 us, tx2_int_o);
|
357 |
|
|
wait_for_event("Wait for recevier 2 LSBF interrupt", 150 us, rx2_int_o);
|
358 |
|
|
message("Clear transmitter LSBF interrupt:");
|
359 |
|
|
wb_write_32(TX2_INTSTAT, 16#00000001#);
|
360 |
|
|
wb_check_32(TX2_INTSTAT, 16#00000000#);
|
361 |
|
|
signal_check("tx2_int_o", '0', tx2_int_o);
|
362 |
|
|
message("Clear receiver LSBF interrupt:");
|
363 |
|
|
wb_write_32(RX2_INTSTAT, 16#00000001#);
|
364 |
|
|
wb_check_32(RX2_INTSTAT, 16#00000000#);
|
365 |
|
|
signal_check("rx2_int_o", '0', rx2_int_o);
|
366 |
|
|
message("Check received data, lower sample buffer:");
|
367 |
|
|
wb_read_32(RX2_BUF_BASE);
|
368 |
|
|
-- calculate which index this word was generated with
|
369 |
|
|
idx := (32767 - to_integer(unsigned(read_32bit(31 downto 8)))) / 497;
|
370 |
|
|
-- then check for correct values
|
371 |
|
|
CHKL: for i in 0 to 7 - idx loop
|
372 |
|
|
wb_check_32(RX2_BUF_BASE + 2*i, (32767 - (i+idx)*497)*256);
|
373 |
|
|
wb_check_32(RX2_BUF_BASE + 2*i + 1, (32768 + (i+idx)*497)*256);
|
374 |
|
|
end loop;
|
375 |
|
|
wait_for_event("Wait for transmitter 2 HSBF interrupt", 150 us, tx2_int_o);
|
376 |
|
|
wait_for_event("Wait for recevier 2 HSBF interrupt", 150 us, rx2_int_o);
|
377 |
|
|
message("Clear transmitter HSBF interrupt:");
|
378 |
|
|
wb_write_32(TX2_INTSTAT, 16#00000002#);
|
379 |
|
|
wb_check_32(TX2_INTSTAT, 16#00000000#);
|
380 |
|
|
signal_check("tx2_int_o", '0', tx2_int_o);
|
381 |
|
|
message("Clear receiver HSBF interrupt:");
|
382 |
|
|
wb_write_32(RX2_INTSTAT, 16#00000002#);
|
383 |
|
|
wb_check_32(RX2_INTSTAT, 16#00000000#);
|
384 |
|
|
signal_check("rx2_int_o", '0', rx2_int_o);
|
385 |
|
|
message("Check received data, upper sample buffer:");
|
386 |
|
|
CHKH: for i in 8 - idx to 15 - idx loop
|
387 |
|
|
wb_check_32(RX2_BUF_BASE + 2*i, (32767 - (i+idx)*497)*256);
|
388 |
|
|
wb_check_32(RX2_BUF_BASE + 2*i + 1, (32768 + (i+idx)*497)*256);
|
389 |
|
|
end loop;
|
390 |
|
|
|
391 |
|
|
message("*** Test of slave TX and master RX ***");
|
392 |
|
|
message("Enable transmitter 1:");
|
393 |
|
|
wb_write_32(TX1_INTMASK, 16#00000003#); -- enable interrupts
|
394 |
|
|
wb_write_32(TX1_CONFIG, 16#00180007#); -- 24bit resolution
|
395 |
|
|
message("Enable recevier 1:");
|
396 |
|
|
wb_write_32(RX1_INTMASK, 16#00000003#); -- enable interrupts
|
397 |
|
|
wb_write_32(RX1_CONFIG, 16#00100707#); -- 16bit resolution
|
398 |
|
|
wait_for_event("Wait for transmitter 1 LSBF interrupt", 150 us, tx1_int_o);
|
399 |
|
|
message("Clear LSBF interrupt:");
|
400 |
|
|
wb_write_32(TX1_INTSTAT, 16#00000001#);
|
401 |
|
|
wb_check_32(TX1_INTSTAT, 16#00000000#);
|
402 |
|
|
signal_check("tx1_int_o", '0', tx1_int_o);
|
403 |
|
|
wait_for_event("Wait for recevier 1 LSBF interrupt", 150 us, rx1_int_o);
|
404 |
|
|
message("Clear LSBF interrupt:");
|
405 |
|
|
wb_write_32(RX1_INTSTAT, 16#00000001#);
|
406 |
|
|
wb_check_32(RX1_INTSTAT, 16#00000000#);
|
407 |
|
|
signal_check("rx1_int_o", '0', rx1_int_o);
|
408 |
|
|
message("Check received data (#1), lower sample buffer:");
|
409 |
|
|
wb_read_32(RX1_BUF_BASE);
|
410 |
|
|
-- calculate which index this word was generated with
|
411 |
|
|
idx := (32767 - to_integer(unsigned(read_32bit(15 downto 0)))) / 497;
|
412 |
|
|
-- then check for correct values
|
413 |
|
|
CHKL1: for i in 0 to 7 - idx loop
|
414 |
|
|
wb_check_32(RX1_BUF_BASE + 2*i, 32768 + (i+idx)*497);
|
415 |
|
|
wb_check_32(RX1_BUF_BASE + 2*i + 1, 32767 - (i+idx)*497);
|
416 |
|
|
end loop;
|
417 |
|
|
wait_for_event("Wait for transmitter 1 HSBF interrupt", 150 us, tx1_int_o);
|
418 |
|
|
message("Clear HSBF interrupt:");
|
419 |
|
|
wb_write_32(TX1_INTSTAT, 16#00000002#);
|
420 |
|
|
wb_check_32(TX1_INTSTAT, 16#00000000#);
|
421 |
|
|
signal_check("tx1_int_o", '0', tx1_int_o);
|
422 |
|
|
wait_for_event("Wait for recevier 1 HSBF interrupt", 150 us, rx1_int_o);
|
423 |
|
|
message("Clear HSBF interrupt:");
|
424 |
|
|
wb_write_32(RX1_INTSTAT, 16#00000002#);
|
425 |
|
|
wb_check_32(RX1_INTSTAT, 16#00000000#);
|
426 |
|
|
signal_check("rx1_int_o", '0', rx1_int_o);
|
427 |
|
|
message("Check received data (#1), higher sample buffer:");
|
428 |
|
|
CHKH1: for i in 8 - idx to 15 - idx loop
|
429 |
|
|
wb_check_32(RX1_BUF_BASE + 2*i, 32768 + (i+idx)*497);
|
430 |
|
|
wb_check_32(RX1_BUF_BASE + 2*i + 1, 32767 - (i+idx)*497);
|
431 |
|
|
end loop;
|
432 |
|
|
|
433 |
|
|
sim_report("");
|
434 |
|
|
report "End of simulation! (ignore this failure)"
|
435 |
|
|
severity failure;
|
436 |
|
|
wait;
|
437 |
|
|
end process MAIN;
|
438 |
|
|
|
439 |
|
|
-- Bus strobe generator based on address. 32bit recevier mapped to addr. 0x1000
|
440 |
|
|
-- 32bit transmitter mapped to address 0x2000
|
441 |
|
|
wb_stb_32bit_rx1 <= '1' when wb_adr_o(15 downto 12) = "0001" else '0';
|
442 |
|
|
wb_stb_32bit_tx1 <= '1' when wb_adr_o(15 downto 12) = "0010" else '0';
|
443 |
|
|
wb_stb_32bit_rx2 <= '1' when wb_adr_o(15 downto 12) = "0011" else '0';
|
444 |
|
|
wb_stb_32bit_tx2 <= '1' when wb_adr_o(15 downto 12) = "0100" else '0';
|
445 |
|
|
|
446 |
|
|
-- Clock process, 50Mhz Wishbone master freq.
|
447 |
|
|
CLKGEN: process
|
448 |
|
|
begin
|
449 |
|
|
wb_clk_o <= '0';
|
450 |
|
|
wait for 10 ns;
|
451 |
|
|
wb_clk_o <= '1';
|
452 |
|
|
wait for 10 ns;
|
453 |
|
|
end process CLKGEN;
|
454 |
|
|
|
455 |
|
|
end behav;
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
|