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

Subversion Repositories spdif_interface

[/] [spdif_interface/] [trunk/] [bench/] [vhdl/] [tb_rx_spdif.vhd] - Blame information for rev 73

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 gedra
----------------------------------------------------------------------
2
----                                                              ----
3
---- WISHBONE SPDIF IP Core                                       ----
4
----                                                              ----
5
---- This file is part of the SPDIF project                       ----
6
---- http://www.opencores.org/cores/spdif_interface/              ----
7
----                                                              ----
8
---- Description                                                  ----
9
---- Test bench for SPDIF recevier.                               ----
10
----                                                              ----
11
----                                                              ----
12
---- To Do:                                                       ----
13
---- -                                                            ----
14
----                                                              ----
15
---- Author(s):                                                   ----
16
---- - Geir Drange, gedra@opencores.org                           ----
17
----                                                              ----
18
----------------------------------------------------------------------
19
----                                                              ----
20
---- Copyright (C) 2004 Authors and OPENCORES.ORG                 ----
21
----                                                              ----
22
---- This source file may be used and distributed without         ----
23
---- restriction provided that this copyright statement is not    ----
24
---- removed from the file and that any derivative work contains  ----
25
---- the original copyright notice and the associated disclaimer. ----
26
----                                                              ----
27
---- This source file is free software; you can redistribute it   ----
28
---- and/or modify it under the terms of the GNU Lesser General   ----
29
---- Public License as published by the Free Software Foundation; ----
30
---- either version 2.1 of the License, or (at your option) any   ----
31
---- later version.                                               ----
32
----                                                              ----
33
---- This source is distributed in the hope that it will be       ----
34
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
35
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
36
---- PURPOSE. See the GNU Lesser General Public License for more  ----
37
---- details.                                                     ----
38
----                                                              ----
39
---- You should have received a copy of the GNU Lesser General    ----
40
---- Public License along with this source; if not, download it   ----
41
---- from http://www.opencores.org/lgpl.shtml                     ----
42
----                                                              ----
43
----------------------------------------------------------------------
44
--
45
-- CVS Revision History
46
--
47
-- $Log: not supported by cvs2svn $
48 72 gedra
-- Revision 1.3  2004/07/12 17:06:07  gedra
49
-- Test bench update.
50
--
51 41 gedra
-- Revision 1.2  2004/07/11 16:20:16  gedra
52
-- Improved test bench.
53
--
54 40 gedra
-- Revision 1.1  2004/06/26 14:12:51  gedra
55
-- Top level test bench for receiver. NB! Not complete.
56 35 gedra
--
57 40 gedra
--
58 72 gedra
 
59 35 gedra
library ieee;
60
use ieee.std_logic_1164.all;
61
use work.wb_tb_pack.all;
62
 
63
 
64 72 gedra
entity tb_rx_spdif is
65
 
66 35 gedra
end tb_rx_spdif;
67
 
68
architecture behav of tb_rx_spdif is
69
 
70 72 gedra
   component rx_spdif is
71
      generic (DATA_WIDTH    : integer range 16 to 32;
72
               ADDR_WIDTH    : integer range 8 to 64;
73
               CH_ST_CAPTURE : integer range 0 to 8;
74
               WISHBONE_FREQ : natural);
75
      port (
76
         -- Wishbone interface
77
         wb_clk_i   : in  std_logic;
78
         wb_rst_i   : in  std_logic;
79
         wb_sel_i   : in  std_logic;
80
         wb_stb_i   : in  std_logic;
81
         wb_we_i    : in  std_logic;
82
         wb_cyc_i   : in  std_logic;
83
         wb_bte_i   : in  std_logic_vector(1 downto 0);
84
         wb_cti_i   : in  std_logic_vector(2 downto 0);
85
         wb_adr_i   : in  std_logic_vector(ADDR_WIDTH - 1 downto 0);
86
         wb_dat_i   : in  std_logic_vector(DATA_WIDTH -1 downto 0);
87
         wb_ack_o   : out std_logic;
88
         wb_dat_o   : out std_logic_vector(DATA_WIDTH - 1 downto 0);
89
         -- Interrupt line
90
         rx_int_o   : out std_logic;
91
         -- SPDIF input signal
92
         spdif_rx_i : in  std_logic);
93
   end component;
94 35 gedra
 
95 72 gedra
   component gen_spdif
96
      generic (Freq : natural);         -- Sampling frequency in Hz
97
      port (                            -- Bitrate is 64x sampling frequency
98
         reset : in  std_logic;
99
         spdif : out std_logic);        -- Output bi-phase encoded signal
100
   end component;
101 35 gedra
 
102 72 gedra
   signal wb_clk_o, wb_rst_o, wb_sel_o, wb_stb_o, wb_we_o : std_logic;
103
   signal wb_cyc_o, wb_ack_i, rx_int_o, spdif_rx_i        : std_logic;
104
   signal wb_bte_o                                        : std_logic_vector(1 downto 0);
105
   signal wb_cti_o                                        : std_logic_vector(2 downto 0);
106
   signal wb_adr_o                                        : std_logic_vector(15 downto 0);
107
   signal wb_dat_i, wb_dat_o                              : std_logic_vector(31 downto 0);
108
   signal wb_stb_16bit_rx                                 : std_logic;
109
   constant RX_VERSION                                    : natural := 16#1000#;
110
   constant RX_CONFIG                                     : natural := 16#1001#;
111
   constant RX_STATUS                                     : natural := 16#1002#;
112
   constant RX_INTMASK                                    : natural := 16#1003#;
113
   constant RX_INTSTAT                                    : natural := 16#1004#;
114
 
115 35 gedra
begin
116
 
117
-- Minimal SPDIF recevier in 16bit mode
118 72 gedra
   SRX16 : rx_spdif
119
      generic map (
120
         DATA_WIDTH    => 16,
121
         ADDR_WIDTH    => 8,            -- 128 byte sample buffer
122
         CH_ST_CAPTURE => 0,            -- no capture in 16bit mode
123
         WISHBONE_FREQ => 33)           -- 33 MHz
124
      port map (
125
         wb_clk_i   => wb_clk_o,
126
         wb_rst_i   => wb_rst_o,
127
         wb_sel_i   => wb_sel_o,
128
         wb_stb_i   => wb_stb_16bit_rx,
129
         wb_we_i    => wb_we_o,
130
         wb_cyc_i   => wb_cyc_o,
131
         wb_bte_i   => wb_bte_o,
132
         wb_cti_i   => wb_cti_o,
133
         wb_adr_i   => wb_adr_o(7 downto 0),
134
         wb_dat_i   => wb_dat_o(15 downto 0),
135
         wb_ack_o   => wb_ack_i,
136
         wb_dat_o   => wb_dat_i(15 downto 0),
137
         rx_int_o   => rx_int_o,
138
         spdif_rx_i => spdif_rx_i);
139 35 gedra
 
140
-- SPDIF 44.1kHz source
141 72 gedra
   SP44 : gen_spdif
142
      generic map (FREQ => 44100)
143
      port map (reset => wb_rst_o,
144
                spdif => spdif_rx_i);
145
 
146 35 gedra
-- Main test process
147 72 gedra
   MAIN : process
148
      variable read_16bit : std_logic_vector(15 downto 0);
149 35 gedra
 
150 72 gedra
      -- Make simplified versions of procedures in wb_tb_pack
151
      procedure wb_write_16 (
152
         constant ADDRESS : in natural;
153
         constant DATA    : in natural) is
154
      begin
155
         wb_write(ADDRESS, DATA, wb_adr_o, wb_dat_o(15 downto 0), wb_cyc_o,
156
                  wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
157
      end;
158 35 gedra
 
159 72 gedra
      procedure wb_check_16 (
160
         constant ADDRESS  : in natural;
161
         constant EXP_DATA : in natural) is
162
      begin
163
         wb_check(ADDRESS, EXP_DATA, wb_adr_o, wb_dat_i(15 downto 0), wb_cyc_o,
164
                  wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
165
      end;
166
 
167
      procedure wb_read_16 (
168
         constant ADDRESS   : in  natural;
169
         variable READ_DATA : out std_logic_vector) is
170
      begin
171
         wb_read(ADDRESS, read_16bit, wb_adr_o, wb_dat_i(15 downto 0), wb_cyc_o,
172
                 wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
173
      end;
174
   begin
175
      message("Simulation start with system reset.");
176
      wb_rst_o <= '1';                  -- system reset
177
      wb_sel_o <= '0';
178
      wb_stb_o <= '0';
179
      wb_sel_o <= '0';
180
      wb_we_o  <= '0';
181
      wb_cyc_o <= '0';
182
      wb_bte_o <= "00";
183
      wb_cti_o <= "000";
184
      wb_adr_o <= (others => '0');
185
      wb_dat_o <= (others => '0');
186
      wait for 200 ns;
187
      wb_rst_o <= '0';
188
      message("Start with checking version register for correct value:");
189
      wb_check_16(RX_VERSION, 16#0101#);
190
      message("Enable interrupt on lock:");
191
      wb_write_16(RX_INTMASK, 16#0001#);
192
      message("Enable receiver:");
193
      wb_write_16(RX_CONFIG, 16#0005#);
194
      wb_read_16(RX_CONFIG, read_16bit);
195
      wait_for_event("Wait for LOCK interrupt", 60 us, rx_int_o);
196
      message("Check status register:");
197
      wb_check_16(RX_STATUS, 16#0001#);
198
      message("Clear interrupt:");
199
      wb_write_16(RX_INTSTAT, 16#0001#);
200
      wb_check_16(RX_INTSTAT, 16#0000#);
201
      signal_check("rx_int_o", '0', rx_int_o);
202
      message("Enable sample buffer");
203
      wb_write_16(RX_CONFIG, 16#0007#);
204
      message("Enable sample buffer interrupts");
205
      wb_write_16(RX_INTMASK, 16#0007#);
206
      wait_for_event("Wait for LSBF interrupt", 750 us, rx_int_o);
207
      message("Check LSBF interrupt, and read some data");
208
      wb_check_16(RX_INTSTAT, 16#0002#);
209
      wb_write_16(RX_INTSTAT, 16#0002#);
210
      wb_check_16(RX_INTSTAT, 16#0000#);
211
      signal_check("rx_int_o", '0', rx_int_o);
212
      wb_read_16(16#1080#, read_16bit);
213
      wb_read_16(16#1081#, read_16bit);
214
      wb_read_16(16#1082#, read_16bit);
215
      wb_read_16(16#1083#, read_16bit);
216
      wait_for_event("Wait for HSBF interrupt", 750 us, rx_int_o);
217
      message("Check HSBF interrupt, and read some data");
218
      wb_check_16(RX_INTSTAT, 16#0004#);
219
      wb_write_16(RX_INTSTAT, 16#0004#);
220
      wb_check_16(RX_INTSTAT, 16#0000#);
221
      signal_check("rx_int_o", '0', rx_int_o);
222
 
223
 
224
      report "End of simulation! (ignore this failure)"
225
         severity failure;
226
      wait;
227
 
228
   end process MAIN;
229
 
230 35 gedra
-- Bus strobe generator based on address. 16bit recevier mapped to addr. 0x1000
231 72 gedra
   wb_stb_16bit_rx <= '1' when wb_adr_o(15 downto 12) = "0001" else '0';
232
 
233 35 gedra
-- Clock process, 33Mhz Wishbone master freq.
234 72 gedra
   CLKGEN : process
235
   begin
236
      wb_clk_o <= '0';
237
      wait for 15.15 ns;
238
      wb_clk_o <= '1';
239
      wait for 15.15 ns;
240
   end process CLKGEN;
241
 
242 35 gedra
end behav;
243
 
244
 
245
 

powered by: WebSVN 2.1.0

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