1 |
9 |
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 transmitter 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 General ----
|
29 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
30 |
|
|
---- either version 2.0 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 |
18 |
gedra |
---- PURPOSE. See the GNU General Public License for more details.----
|
37 |
9 |
gedra |
---- ----
|
38 |
|
|
---- You should have received a copy of the GNU General ----
|
39 |
|
|
---- Public License along with this source; if not, download it ----
|
40 |
|
|
---- from http://www.gnu.org/licenses/gpl.txt ----
|
41 |
|
|
---- ----
|
42 |
|
|
----------------------------------------------------------------------
|
43 |
|
|
--
|
44 |
|
|
-- CVS Revision History
|
45 |
|
|
--
|
46 |
|
|
-- $Log: not supported by cvs2svn $
|
47 |
24 |
gedra |
-- Revision 1.3 2005/01/17 17:26:49 gedra
|
48 |
|
|
-- Bugfix of register read/write strobes
|
49 |
|
|
--
|
50 |
22 |
gedra |
-- Revision 1.2 2004/08/06 18:55:43 gedra
|
51 |
|
|
-- De-linting.
|
52 |
|
|
--
|
53 |
18 |
gedra |
-- Revision 1.1 2004/08/03 18:50:51 gedra
|
54 |
|
|
-- Transmitter Wishbone cycle decoder.
|
55 |
9 |
gedra |
--
|
56 |
|
|
--
|
57 |
18 |
gedra |
--
|
58 |
9 |
gedra |
|
59 |
|
|
library ieee;
|
60 |
|
|
use ieee.std_logic_1164.all;
|
61 |
|
|
use ieee.numeric_std.all;
|
62 |
|
|
|
63 |
24 |
gedra |
entity tx_i2s_wbd is
|
64 |
|
|
generic (DATA_WIDTH : integer;
|
65 |
|
|
ADDR_WIDTH : integer);
|
66 |
|
|
port (
|
67 |
|
|
wb_clk_i : in std_logic; -- wishbone clock
|
68 |
|
|
wb_rst_i : in std_logic; -- reset signal
|
69 |
|
|
wb_sel_i : in std_logic; -- select input
|
70 |
|
|
wb_stb_i : in std_logic; -- strobe input
|
71 |
|
|
wb_we_i : in std_logic; -- write enable
|
72 |
|
|
wb_cyc_i : in std_logic; -- cycle input
|
73 |
|
|
wb_bte_i : in std_logic_vector(1 downto 0); -- burts type extension
|
74 |
|
|
wb_cti_i : in std_logic_vector(2 downto 0); -- cycle type identifier
|
75 |
|
|
wb_adr_i : in std_logic_vector(ADDR_WIDTH - 1 downto 0); -- address
|
76 |
|
|
data_out : in std_logic_vector(DATA_WIDTH - 1 downto 0); -- internal bus
|
77 |
|
|
wb_ack_o : out std_logic; -- acknowledge
|
78 |
|
|
wb_dat_o : out std_logic_vector(DATA_WIDTH - 1 downto 0); -- data out
|
79 |
|
|
version_rd : out std_logic; -- Version register read
|
80 |
|
|
config_rd : out std_logic; -- Config register read
|
81 |
|
|
config_wr : out std_logic; -- Config register write
|
82 |
|
|
intmask_rd : out std_logic; -- Interrupt mask register read
|
83 |
|
|
intmask_wr : out std_logic; -- Interrupt mask register write
|
84 |
|
|
intstat_rd : out std_logic; -- Interrupt status register read
|
85 |
|
|
intstat_wr : out std_logic; -- Interrupt status register read
|
86 |
|
|
mem_wr : out std_logic); -- Sample memory write
|
87 |
9 |
gedra |
end tx_i2s_wbd;
|
88 |
|
|
|
89 |
|
|
architecture rtl of tx_i2s_wbd is
|
90 |
24 |
gedra |
|
91 |
|
|
constant REG_TXVERSION : std_logic_vector(3 downto 0) := "0000";
|
92 |
|
|
constant REG_TXCONFIG : std_logic_vector(3 downto 0) := "0001";
|
93 |
|
|
constant REG_TXINTMASK : std_logic_vector(3 downto 0) := "0010";
|
94 |
|
|
constant REG_TXINTSTAT : std_logic_vector(3 downto 0) := "0011";
|
95 |
|
|
signal iack, iwr, ird : std_logic;
|
96 |
|
|
signal acnt : integer range 0 to 2**(ADDR_WIDTH - 1) - 1;
|
97 |
|
|
signal rdout : std_logic_vector(DATA_WIDTH - 1 downto 0);
|
98 |
|
|
|
99 |
|
|
begin
|
100 |
9 |
gedra |
|
101 |
24 |
gedra |
wb_ack_o <= iack;
|
102 |
9 |
gedra |
|
103 |
|
|
-- acknowledge generation
|
104 |
24 |
gedra |
ACK : process (wb_clk_i, wb_rst_i)
|
105 |
|
|
begin
|
106 |
|
|
if wb_rst_i = '1' then
|
107 |
|
|
iack <= '0';
|
108 |
|
|
elsif rising_edge(wb_clk_i) then
|
109 |
|
|
if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' then
|
110 |
|
|
case wb_cti_i is
|
111 |
|
|
when "010" => -- incrementing burst
|
112 |
|
|
case wb_bte_i is -- burst extension
|
113 |
|
|
when "00" => -- linear burst
|
114 |
|
|
iack <= '1';
|
115 |
|
|
when others => -- all other treated assert classic cycle
|
116 |
|
|
iack <= not iack;
|
117 |
|
|
end case;
|
118 |
|
|
when "111" => -- end of burst
|
119 |
|
|
iack <= not iack;
|
120 |
|
|
when others => -- all other treated assert classic cycle
|
121 |
|
|
iack <= not iack;
|
122 |
|
|
end case;
|
123 |
|
|
else
|
124 |
|
|
iack <= '0';
|
125 |
|
|
end if;
|
126 |
|
|
end if;
|
127 |
|
|
end process ACK;
|
128 |
9 |
gedra |
|
129 |
|
|
-- write generation
|
130 |
24 |
gedra |
WR : process (wb_clk_i, wb_rst_i)
|
131 |
|
|
begin
|
132 |
|
|
if wb_rst_i = '1' then
|
133 |
|
|
iwr <= '0';
|
134 |
|
|
elsif rising_edge(wb_clk_i) then
|
135 |
|
|
if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
|
136 |
|
|
wb_we_i = '1' then
|
137 |
|
|
case wb_cti_i is
|
138 |
|
|
when "010" => -- incrementing burst
|
139 |
|
|
case wb_bte_i is -- burst extension
|
140 |
|
|
when "00" => -- linear burst
|
141 |
|
|
iwr <= '1';
|
142 |
|
|
when others => -- all other treated as classic cycle
|
143 |
|
|
iwr <= not iwr;
|
144 |
|
|
end case;
|
145 |
|
|
when "111" => -- end of burst
|
146 |
|
|
iwr <= not iwr;
|
147 |
|
|
when others => -- all other treated as classic cycle
|
148 |
|
|
iwr <= not iwr;
|
149 |
|
|
end case;
|
150 |
|
|
else
|
151 |
|
|
iwr <= '0';
|
152 |
|
|
end if;
|
153 |
|
|
end if;
|
154 |
|
|
end process WR;
|
155 |
9 |
gedra |
|
156 |
|
|
-- read generation
|
157 |
24 |
gedra |
ird <= '1' when wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
|
158 |
|
|
wb_we_i = '0' else '0';
|
159 |
9 |
gedra |
|
160 |
24 |
gedra |
wb_dat_o <= data_out when wb_adr_i(ADDR_WIDTH - 1) = '1' else rdout;
|
161 |
9 |
gedra |
|
162 |
24 |
gedra |
DREG : process (wb_clk_i) -- clock data from registers
|
163 |
|
|
begin
|
164 |
|
|
if rising_edge(wb_clk_i) then
|
165 |
|
|
rdout <= data_out;
|
166 |
|
|
end if;
|
167 |
|
|
end process DREG;
|
168 |
|
|
|
169 |
9 |
gedra |
-- read and write strobe generation
|
170 |
24 |
gedra |
|
171 |
|
|
version_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXVERSION and ird = '1'
|
172 |
|
|
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
173 |
|
|
config_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXCONFIG and ird = '1'
|
174 |
22 |
gedra |
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
175 |
24 |
gedra |
config_wr <= '1' when wb_adr_i(3 downto 0) = REG_TXCONFIG and iwr = '1'
|
176 |
22 |
gedra |
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
177 |
24 |
gedra |
intmask_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXINTMASK and ird = '1'
|
178 |
|
|
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
179 |
|
|
intmask_wr <= '1' when wb_adr_i(3 downto 0) = REG_TXINTMASK and iwr = '1'
|
180 |
|
|
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
181 |
|
|
intstat_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXINTSTAT and ird = '1'
|
182 |
|
|
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
183 |
|
|
intstat_wr <= '1' when wb_adr_i(3 downto 0) = REG_TXINTSTAT and iwr = '1'
|
184 |
29 |
gedra |
and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
|
185 |
24 |
gedra |
mem_wr <= '1' when wb_adr_i(ADDR_WIDTH - 1) = '1' and iwr = '1' else '0';
|
186 |
|
|
|
187 |
9 |
gedra |
end rtl;
|