1 |
29 |
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 |
|
|
---- SPDIF receiver: Wishbone bus cycle decoder. ----
|
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 |
31 |
gedra |
-- Revision 1.1 2004/06/23 18:09:57 gedra
|
49 |
|
|
-- Wishbone bus cycle decoder.
|
50 |
29 |
gedra |
--
|
51 |
31 |
gedra |
--
|
52 |
29 |
gedra |
|
53 |
|
|
library IEEE;
|
54 |
|
|
use IEEE.std_logic_1164.all;
|
55 |
|
|
use IEEE.std_logic_arith.all;
|
56 |
31 |
gedra |
use ieee.std_logic_unsigned.all;
|
57 |
29 |
gedra |
|
58 |
|
|
entity rx_wb_decoder is
|
59 |
|
|
generic (DATA_WIDTH: integer;
|
60 |
|
|
ADDR_WIDTH: integer);
|
61 |
|
|
port (
|
62 |
|
|
wb_clk_i: in std_logic; -- wishbone clock
|
63 |
|
|
wb_rst_i: in std_logic; -- reset signal
|
64 |
|
|
wb_sel_i: in std_logic; -- select input
|
65 |
|
|
wb_stb_i: in std_logic; -- strobe input
|
66 |
|
|
wb_we_i: in std_logic; -- write enable
|
67 |
|
|
wb_cyc_i: in std_logic; -- cycle input
|
68 |
|
|
wb_bte_i: in std_logic_vector(1 downto 0); -- burts type extension
|
69 |
|
|
wb_cti_i: in std_logic_vector(2 downto 0); -- cycle type identifier
|
70 |
|
|
wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0); -- address
|
71 |
|
|
data_out: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- internal bus
|
72 |
|
|
wb_ack_o: out std_logic; -- acknowledge
|
73 |
|
|
wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0); -- data out
|
74 |
|
|
version_rd: out std_logic; -- Version register read
|
75 |
|
|
config_rd: out std_logic; -- Config register read
|
76 |
|
|
config_wr: out std_logic; -- Config register write
|
77 |
|
|
status_rd: out std_logic; -- Status register read
|
78 |
|
|
intmask_rd: out std_logic; -- Interrupt mask register read
|
79 |
|
|
intmask_wr: out std_logic; -- Interrupt mask register write
|
80 |
|
|
intstat_rd: out std_logic; -- Interrupt status register read
|
81 |
|
|
intstat_wr: out std_logic; -- Interrupt status register read
|
82 |
|
|
mem_rd: out std_logic; -- Sample memory read
|
83 |
|
|
mem_addr: out std_logic_vector(ADDR_WIDTH - 2 downto 0); -- memory addr.
|
84 |
|
|
ch_st_cap_rd: out std_logic_vector(7 downto 0); -- Ch. status cap. read
|
85 |
|
|
ch_st_cap_wr: out std_logic_vector(7 downto 0); -- Ch. status cap. write
|
86 |
|
|
ch_st_data_rd: out std_logic_vector(7 downto 0)); -- Ch. status data read
|
87 |
|
|
end rx_wb_decoder;
|
88 |
|
|
|
89 |
|
|
architecture rtl of rx_wb_decoder is
|
90 |
|
|
|
91 |
|
|
constant REG_RXVERSION : std_logic_vector(6 downto 0) := "0000000";
|
92 |
|
|
constant REG_RXCONFIG : std_logic_vector(6 downto 0) := "0000001";
|
93 |
|
|
constant REG_RXSTATUS : std_logic_vector(6 downto 0) := "0000010";
|
94 |
|
|
constant REG_RXINTMASK : std_logic_vector(6 downto 0) := "0000011";
|
95 |
|
|
constant REG_RXINTSTAT : std_logic_vector(6 downto 0) := "0000100";
|
96 |
|
|
signal iack, iwr, ird : std_logic;
|
97 |
|
|
signal acnt: integer range 0 to 2**(ADDR_WIDTH - 1) - 1;
|
98 |
|
|
signal all_ones : std_logic_vector(ADDR_WIDTH - 1 downto 0);
|
99 |
31 |
gedra |
signal rdout : std_logic_vector(DATA_WIDTH - 1 downto 0);
|
100 |
29 |
gedra |
|
101 |
|
|
begin
|
102 |
|
|
|
103 |
|
|
wb_ack_o <= iack;
|
104 |
|
|
|
105 |
|
|
-- acknowledge generation
|
106 |
|
|
ACK: process (wb_clk_i, wb_rst_i)
|
107 |
|
|
begin
|
108 |
|
|
if wb_rst_i = '1' then
|
109 |
|
|
iack <= '0';
|
110 |
|
|
elsif rising_edge(wb_clk_i) then
|
111 |
|
|
if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' then
|
112 |
|
|
case wb_cti_i is
|
113 |
|
|
when "010" => -- incrementing burst
|
114 |
|
|
case wb_bte_i is -- burst extension
|
115 |
|
|
when "00" => -- linear burst
|
116 |
|
|
iack <= '1';
|
117 |
|
|
when others => -- all other treated assert classic cycle
|
118 |
|
|
iack <= not iack;
|
119 |
|
|
end case;
|
120 |
|
|
when "111" => -- end of burst
|
121 |
|
|
iack <= not iack;
|
122 |
|
|
when others => -- all other treated assert classic cycle
|
123 |
|
|
iack <= not iack;
|
124 |
|
|
end case;
|
125 |
|
|
else
|
126 |
|
|
iack <= '0';
|
127 |
|
|
end if;
|
128 |
|
|
end if;
|
129 |
|
|
end process ACK;
|
130 |
|
|
|
131 |
|
|
-- write generation
|
132 |
|
|
WR: process (wb_clk_i, wb_rst_i)
|
133 |
|
|
begin
|
134 |
|
|
if wb_rst_i = '1' then
|
135 |
|
|
iwr <= '0';
|
136 |
|
|
elsif rising_edge(wb_clk_i) then
|
137 |
|
|
if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
|
138 |
|
|
wb_we_i = '1' then
|
139 |
|
|
case wb_cti_i is
|
140 |
|
|
when "010" => -- incrementing burst
|
141 |
|
|
case wb_bte_i is -- burst extension
|
142 |
|
|
when "00" => -- linear burst
|
143 |
|
|
iwr <= '1';
|
144 |
|
|
when others => -- all other treated assert classic cycle
|
145 |
|
|
iwr <= not iwr;
|
146 |
|
|
end case;
|
147 |
|
|
when "111" => -- end of burst
|
148 |
|
|
iwr <= not iwr;
|
149 |
|
|
when others => -- all other treated assert classic cycle
|
150 |
|
|
iwr <= not iwr;
|
151 |
|
|
end case;
|
152 |
|
|
else
|
153 |
|
|
iwr <= '0';
|
154 |
|
|
end if;
|
155 |
|
|
end if;
|
156 |
|
|
end process WR;
|
157 |
|
|
|
158 |
|
|
-- read generation
|
159 |
|
|
ird <= '1' when wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
|
160 |
31 |
gedra |
wb_we_i = '0' else '0';
|
161 |
29 |
gedra |
|
162 |
31 |
gedra |
wb_dat_o <= data_out when wb_adr_i(ADDR_WIDTH - 1) = '1' else rdout;
|
163 |
|
|
|
164 |
|
|
DREG: process (wb_clk_i) -- clock data from registers
|
165 |
|
|
begin
|
166 |
|
|
if rising_edge(wb_clk_i) then
|
167 |
|
|
rdout <= data_out;
|
168 |
|
|
end if;
|
169 |
|
|
end process DREG;
|
170 |
|
|
|
171 |
29 |
gedra |
-- sample memory read address. This needs special attention due to read latency
|
172 |
|
|
mem_addr <= CONV_STD_LOGIC_VECTOR(acnt, ADDR_WIDTH - 1) when
|
173 |
|
|
wb_cti_i = "010" and wb_we_i = '0' and iack = '1' and
|
174 |
|
|
wb_bte_i = "00" else wb_adr_i(ADDR_WIDTH - 2 downto 0);
|
175 |
|
|
|
176 |
31 |
gedra |
all_ones(ADDR_WIDTH - 1 downto 0) <= (others => '1');
|
177 |
29 |
gedra |
|
178 |
|
|
SMA: process (wb_clk_i, wb_rst_i)
|
179 |
|
|
begin
|
180 |
|
|
if wb_rst_i = '1' then
|
181 |
|
|
acnt <= 0;
|
182 |
|
|
elsif rising_edge(wb_clk_i) then
|
183 |
|
|
if wb_cti_i = "010" and wb_we_i = '0' and wb_bte_i = "00" then
|
184 |
|
|
if iack = '0' then
|
185 |
|
|
if wb_adr_i = all_ones then
|
186 |
|
|
acnt <= 0;
|
187 |
|
|
else
|
188 |
|
|
acnt <= CONV_INTEGER(wb_adr_i) + 1;
|
189 |
|
|
end if;
|
190 |
|
|
else
|
191 |
|
|
if acnt < 2**(ADDR_WIDTH - 1) - 1 then
|
192 |
|
|
acnt <= acnt + 1;
|
193 |
|
|
else
|
194 |
|
|
acnt <= 0;
|
195 |
|
|
end if;
|
196 |
|
|
end if;
|
197 |
|
|
end if;
|
198 |
|
|
end if;
|
199 |
|
|
end process SMA;
|
200 |
|
|
|
201 |
|
|
-- read and write strobe generation
|
202 |
|
|
|
203 |
|
|
version_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXVERSION and ird = '1'
|
204 |
|
|
else '0';
|
205 |
|
|
config_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXCONFIG and ird = '1'
|
206 |
|
|
else '0';
|
207 |
|
|
config_wr <= '1' when wb_adr_i(6 downto 0) = REG_RXCONFIG and iwr = '1'
|
208 |
|
|
else '0';
|
209 |
|
|
status_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXSTATUS and ird = '1'
|
210 |
|
|
else '0';
|
211 |
|
|
intmask_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXINTMASK and ird = '1'
|
212 |
|
|
else '0';
|
213 |
|
|
intmask_wr <= '1' when wb_adr_i(6 downto 0) = REG_RXINTMASK and iwr = '1'
|
214 |
|
|
else '0';
|
215 |
|
|
intstat_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXINTSTAT and ird = '1'
|
216 |
|
|
else '0';
|
217 |
|
|
intstat_wr <= '1' when wb_adr_i(6 downto 0) = REG_RXINTSTAT and iwr = '1'
|
218 |
|
|
else '0';
|
219 |
|
|
mem_rd <= '1' when wb_adr_i(ADDR_WIDTH - 1) = '1' and ird = '1' else '0';
|
220 |
|
|
|
221 |
|
|
-- capture register strobes
|
222 |
|
|
CR32: if DATA_WIDTH = 32 generate
|
223 |
|
|
CRST: for k in 0 to 7 generate
|
224 |
|
|
ch_st_cap_rd(k) <= '1' when ird = '1' and wb_adr_i(6 downto 4) = "001"
|
225 |
|
|
and wb_adr_i(3 downto 0) = CONV_STD_LOGIC_VECTOR(2*k,4)
|
226 |
|
|
else '0';
|
227 |
|
|
ch_st_cap_wr(k) <= '1' when iwr = '1' and wb_adr_i(6 downto 4) = "001"
|
228 |
|
|
and wb_adr_i(3 downto 0) = CONV_STD_LOGIC_VECTOR(2*k,4)
|
229 |
|
|
else '0';
|
230 |
|
|
ch_st_data_rd(k) <= '1' when ird = '1' and wb_adr_i(6 downto 4) = "001"
|
231 |
|
|
and wb_adr_i(3 downto 0) = CONV_STD_LOGIC_VECTOR(2*k+1,4)
|
232 |
|
|
else '0';
|
233 |
|
|
end generate CRST;
|
234 |
|
|
end generate CR32;
|
235 |
|
|
CR16: if DATA_WIDTH = 16 generate
|
236 |
|
|
ch_st_cap_rd(7 downto 0) <= (others => '0');
|
237 |
|
|
ch_st_cap_wr(7 downto 0) <= (others => '0');
|
238 |
|
|
ch_st_data_rd(7 downto 0) <= (others => '0');
|
239 |
|
|
end generate CR16;
|
240 |
|
|
|
241 |
|
|
end rtl;
|