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 |
|
|
--
|
49 |
|
|
|
50 |
|
|
library ieee;
|
51 |
|
|
use ieee.std_logic_1164.all;
|
52 |
|
|
use work.wb_tb_pack.all;
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
entity tb_rx_spdif is
|
56 |
|
|
|
57 |
|
|
end tb_rx_spdif;
|
58 |
|
|
|
59 |
|
|
architecture behav of tb_rx_spdif is
|
60 |
|
|
|
61 |
|
|
component rx_spdif is
|
62 |
|
|
generic (DATA_WIDTH: integer range 16 to 32;
|
63 |
|
|
ADDR_WIDTH: integer range 8 to 64;
|
64 |
|
|
CH_ST_CAPTURE: integer range 0 to 8;
|
65 |
|
|
WISHBONE_FREQ: natural);
|
66 |
|
|
port (
|
67 |
|
|
-- Wishbone interface
|
68 |
|
|
wb_clk_i: in std_logic;
|
69 |
|
|
wb_rst_i: in std_logic;
|
70 |
|
|
wb_sel_i: in std_logic;
|
71 |
|
|
wb_stb_i: in std_logic;
|
72 |
|
|
wb_we_i: in std_logic;
|
73 |
|
|
wb_cyc_i: in std_logic;
|
74 |
|
|
wb_bte_i: in std_logic_vector(1 downto 0);
|
75 |
|
|
wb_cti_i: in std_logic_vector(2 downto 0);
|
76 |
|
|
wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);
|
77 |
|
|
wb_dat_i: in std_logic_vector(DATA_WIDTH -1 downto 0);
|
78 |
|
|
wb_ack_o: out std_logic;
|
79 |
|
|
wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);
|
80 |
|
|
-- Interrupt line
|
81 |
|
|
rx_int_o: out std_logic;
|
82 |
|
|
-- SPDIF input signal
|
83 |
|
|
spdif_rx_i: in std_logic);
|
84 |
|
|
end component;
|
85 |
|
|
|
86 |
|
|
component gen_spdif
|
87 |
|
|
generic (Freq: natural); -- Sampling frequency in Hz
|
88 |
|
|
port ( -- Bitrate is 64x sampling frequency
|
89 |
|
|
reset: in std_logic;
|
90 |
|
|
spdif: out std_logic); -- Output bi-phase encoded signal
|
91 |
|
|
end component;
|
92 |
|
|
|
93 |
|
|
signal wb_clk_o, wb_rst_o, wb_sel_o, wb_stb_o, wb_we_o : std_logic;
|
94 |
|
|
signal wb_cyc_o, wb_ack_i, rx_int_o, spdif_rx_i : std_logic;
|
95 |
|
|
signal wb_bte_o : std_logic_vector(1 downto 0);
|
96 |
|
|
signal wb_cti_o : std_logic_vector(2 downto 0);
|
97 |
|
|
signal wb_adr_o : std_logic_vector(15 downto 0);
|
98 |
|
|
signal wb_dat_i, wb_dat_o : std_logic_vector(31 downto 0);
|
99 |
|
|
signal wb_stb_16bit_rx : std_logic;
|
100 |
|
|
|
101 |
|
|
begin
|
102 |
|
|
|
103 |
|
|
-- Minimal SPDIF recevier in 16bit mode
|
104 |
|
|
SRX16: rx_spdif
|
105 |
|
|
generic map (
|
106 |
|
|
DATA_WIDTH => 16,
|
107 |
|
|
ADDR_WIDTH => 8, -- 128 byte sample buffer
|
108 |
|
|
CH_ST_CAPTURE => 0, -- no capture in 16bit mode
|
109 |
|
|
WISHBONE_FREQ => 33) -- 33 MHz
|
110 |
|
|
port map (
|
111 |
|
|
wb_clk_i => wb_clk_o,
|
112 |
|
|
wb_rst_i => wb_rst_o,
|
113 |
|
|
wb_sel_i => wb_sel_o,
|
114 |
|
|
wb_stb_i => wb_stb_16bit_rx,
|
115 |
|
|
wb_we_i => wb_we_o,
|
116 |
|
|
wb_cyc_i => wb_cyc_o,
|
117 |
|
|
wb_bte_i => wb_bte_o,
|
118 |
|
|
wb_cti_i => wb_cti_o,
|
119 |
|
|
wb_adr_i => wb_adr_o(7 downto 0),
|
120 |
|
|
wb_dat_i => wb_dat_o(15 downto 0),
|
121 |
|
|
wb_ack_o => wb_ack_i,
|
122 |
|
|
wb_dat_o => wb_dat_i(15 downto 0),
|
123 |
|
|
rx_int_o => rx_int_o,
|
124 |
|
|
spdif_rx_i => spdif_rx_i);
|
125 |
|
|
|
126 |
|
|
-- SPDIF 44.1kHz source
|
127 |
|
|
SP44: gen_spdif
|
128 |
|
|
generic map (Freq => 44100)
|
129 |
|
|
port map (reset => wb_rst_o,
|
130 |
|
|
spdif => spdif_rx_i);
|
131 |
|
|
|
132 |
|
|
-- Main test process
|
133 |
|
|
MAIN: process
|
134 |
|
|
variable read_16bit : std_logic_vector(15 downto 0);
|
135 |
|
|
|
136 |
|
|
-- Make simplified versions of procedures in wb_tb_pack
|
137 |
|
|
procedure wb_write_16 (
|
138 |
|
|
constant ADDRESS: in natural;
|
139 |
|
|
constant DATA: in natural) is
|
140 |
|
|
begin
|
141 |
|
|
wb_write(ADDRESS, DATA, wb_adr_o, wb_dat_o(15 downto 0), wb_cyc_o,
|
142 |
|
|
wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
|
143 |
|
|
end;
|
144 |
|
|
|
145 |
|
|
procedure wb_check_16 (
|
146 |
|
|
constant ADDRESS: in natural;
|
147 |
|
|
constant EXP_DATA : in natural) is
|
148 |
|
|
begin
|
149 |
|
|
wb_check(ADDRESS, EXP_DATA, wb_adr_o, wb_dat_i(15 downto 0), wb_cyc_o,
|
150 |
|
|
wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
|
151 |
|
|
end;
|
152 |
|
|
|
153 |
|
|
procedure wb_read_16 (
|
154 |
|
|
constant ADDRESS: in natural;
|
155 |
|
|
variable READ_DATA : out std_logic_vector) is
|
156 |
|
|
begin
|
157 |
|
|
wb_read(ADDRESS, read_16bit, wb_adr_o, wb_dat_i(15 downto 0), wb_cyc_o,
|
158 |
|
|
wb_sel_o, wb_we_o, wb_clk_o, wb_ack_i);
|
159 |
|
|
end;
|
160 |
|
|
begin
|
161 |
|
|
message("Simulation start with system reset.");
|
162 |
|
|
wb_rst_o <= '1'; -- system reset
|
163 |
|
|
wb_sel_o <= '0';
|
164 |
|
|
wb_stb_o <= '0';
|
165 |
|
|
wb_sel_o <= '0';
|
166 |
|
|
wb_we_o <= '0';
|
167 |
|
|
wb_cyc_o <= '0';
|
168 |
|
|
wb_bte_o <= "00";
|
169 |
|
|
wb_cti_o <= "000";
|
170 |
|
|
wb_adr_o <= (others => '0');
|
171 |
|
|
wb_dat_o <= (others => '0');
|
172 |
|
|
wait for 60 ns;
|
173 |
|
|
wb_rst_o <= '0';
|
174 |
|
|
message("Start with checking version register for correct value:");
|
175 |
|
|
wb_check_16(16#1000#, 16#0101#);
|
176 |
|
|
message("Enable receiver:");
|
177 |
|
|
wb_write_16(16#1001#, 16#0001#);
|
178 |
|
|
wb_read_16(16#1001#, read_16bit);
|
179 |
|
|
|
180 |
|
|
-- lots of stuff coming here soon...
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
wait for 100 us;
|
185 |
|
|
report "End of simulation! (ignore this failure)"
|
186 |
|
|
severity failure;
|
187 |
|
|
wait;
|
188 |
|
|
|
189 |
|
|
end process MAIN;
|
190 |
|
|
|
191 |
|
|
-- Bus strobe generator based on address. 16bit recevier mapped to addr. 0x1000
|
192 |
|
|
wb_stb_16bit_rx <= '1' when wb_adr_o(15 downto 12) = "0001" else '0';
|
193 |
|
|
|
194 |
|
|
-- Clock process, 33Mhz Wishbone master freq.
|
195 |
|
|
CLKGEN: process
|
196 |
|
|
begin
|
197 |
|
|
wb_clk_o <= '0';
|
198 |
|
|
wait for 15.15 ns;
|
199 |
|
|
wb_clk_o <= '1';
|
200 |
|
|
wait for 15.15 ns;
|
201 |
|
|
end process CLKGEN;
|
202 |
|
|
|
203 |
|
|
end behav;
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|