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

Subversion Repositories i2s_interface

[/] [i2s_interface/] [trunk/] [rtl/] [vhdl/] [rx_i2s_topm.vhd] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 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 receiver. Top level entity for the receiver core,        ----
10
---- master mode.                                                 ----
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 12 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.2  2004/08/06 18:55:43  gedra
48
-- De-linting.
49
--
50 18 gedra
-- Revision 1.1  2004/08/04 14:29:34  gedra
51
-- Receiver top level, master mode.
52 12 gedra
--
53
--
54 18 gedra
--
55 12 gedra
 
56
library ieee;
57
use ieee.std_logic_1164.all;
58
use work.rx_i2s_pack.all;
59
 
60 24 gedra
entity rx_i2s_topm is
61
   generic (DATA_WIDTH : integer range 16 to 32;
62
            ADDR_WIDTH : integer range 5 to 32);
63
   port (
64
      wb_clk_i  : in  std_logic;
65
      wb_rst_i  : in  std_logic;
66
      wb_sel_i  : in  std_logic;
67
      wb_stb_i  : in  std_logic;
68
      wb_we_i   : in  std_logic;
69
      wb_cyc_i  : in  std_logic;
70
      wb_bte_i  : in  std_logic_vector(1 downto 0);
71
      wb_cti_i  : in  std_logic_vector(2 downto 0);
72
      wb_adr_i  : in  std_logic_vector(ADDR_WIDTH - 1 downto 0);
73
      wb_dat_i  : in  std_logic_vector(DATA_WIDTH -1 downto 0);
74
      i2s_sd_i  : in  std_logic;        -- I2S data input
75
      wb_ack_o  : out std_logic;
76
      wb_dat_o  : out std_logic_vector(DATA_WIDTH - 1 downto 0);
77
      rx_int_o  : out std_logic;        -- Interrupt line
78
      i2s_sck_o : out std_logic;        -- I2S clock out
79
      i2s_ws_o  : out std_logic);       -- I2S word select out
80 12 gedra
end rx_i2s_topm;
81
 
82
architecture rtl of rx_i2s_topm is
83
 
84 24 gedra
   signal data_out, version_dout             : std_logic_vector(DATA_WIDTH - 1 downto 0);
85
   signal version_rd                         : std_logic;
86
   signal config_rd, config_wr, status_rd    : std_logic;
87
   signal config_dout, status_dout           : std_logic_vector(DATA_WIDTH - 1 downto 0);
88
   signal config_bits                        : std_logic_vector(DATA_WIDTH - 1 downto 0);
89
   signal intmask_bits, intmask_dout         : std_logic_vector(DATA_WIDTH - 1 downto 0);
90
   signal intmask_rd, intmask_wr             : std_logic;
91
   signal intstat_events                     : std_logic_vector(DATA_WIDTH - 1 downto 0);
92
   signal intstat_dout                       : std_logic_vector(DATA_WIDTH - 1 downto 0);
93
   signal intstat_rd, intstat_wr             : std_logic;
94
   signal evt_hsbf, evt_lsbf                 : std_logic;
95
   signal mem_wr, mem_rd                     : std_logic;
96
   signal sbuf_rd_adr, sbuf_wr_adr           : std_logic_vector(ADDR_WIDTH - 2 downto 0);
97
   signal sbuf_dout, sbuf_din, zeros         : std_logic_vector(DATA_WIDTH - 1 downto 0);
98
   signal conf_res                           : std_logic_vector(5 downto 0);
99
   signal conf_ratio                         : std_logic_vector(7 downto 0);
100
   signal conf_rswap, conf_rinten, conf_rxen : std_logic;
101
   signal zero                               : std_logic;
102
 
103 12 gedra
begin
104
 
105
-- Data bus or'ing 
106 24 gedra
   data_out <= version_dout or config_dout or intmask_dout or intstat_dout
107
               when wb_adr_i(ADDR_WIDTH - 1) = '0' else sbuf_dout;
108
 
109 12 gedra
-- Wishbone bus cycle decoder
110 24 gedra
   WB : rx_i2s_wbd
111 12 gedra
      generic map (
112 24 gedra
         DATA_WIDTH => DATA_WIDTH,
113
         ADDR_WIDTH => ADDR_WIDTH)
114 12 gedra
      port map (
115 24 gedra
         wb_clk_i   => wb_clk_i,
116
         wb_rst_i   => wb_rst_i,
117
         wb_sel_i   => wb_sel_i,
118
         wb_stb_i   => wb_stb_i,
119
         wb_we_i    => wb_we_i,
120
         wb_cyc_i   => wb_cyc_i,
121
         wb_bte_i   => wb_bte_i,
122
         wb_cti_i   => wb_cti_i,
123
         wb_adr_i   => wb_adr_i,
124
         data_out   => data_out,
125
         wb_ack_o   => wb_ack_o,
126
         wb_dat_o   => wb_dat_o,
127
         version_rd => version_rd,
128
         config_rd  => config_rd,
129
         config_wr  => config_wr,
130
         intmask_rd => intmask_rd,
131
         intmask_wr => intmask_wr,
132
         intstat_rd => intstat_rd,
133
         intstat_wr => intstat_wr,
134
         mem_rd     => mem_rd,
135
         mem_addr   => sbuf_rd_adr);
136
 
137
-- TxVersion - Version register
138
   VER : i2s_version
139 12 gedra
      generic map (
140 24 gedra
         DATA_WIDTH => DATA_WIDTH,
141
         ADDR_WIDTH => ADDR_WIDTH,
142
         IS_MASTER  => 1)
143 12 gedra
      port map (
144 24 gedra
         ver_rd   => version_rd,
145
         ver_dout => version_dout);
146
 
147
-- TxConfig - Configuration register
148
   CG32 : if DATA_WIDTH = 32 generate
149
      CONF : gen_control_reg
150
         generic map (
151
            DATA_WIDTH      => 32,
152
            ACTIVE_BIT_MASK => "11100000111111111111110000000000")
153
         port map (
154
            clk       => wb_clk_i,
155
            rst       => wb_rst_i,
156
            ctrl_wr   => config_wr,
157
            ctrl_rd   => config_rd,
158
            ctrl_din  => wb_dat_i,
159
            ctrl_dout => config_dout,
160
            ctrl_bits => config_bits);
161
      conf_res(5 downto 0) <= config_bits(21 downto 16);
162
   end generate CG32;
163
   CG16 : if DATA_WIDTH = 16 generate
164
      CONF : gen_control_reg
165
         generic map (
166
            DATA_WIDTH      => 16,
167
            ACTIVE_BIT_MASK => "1110000011111111")
168
         port map (
169
            clk       => wb_clk_i,
170
            rst       => wb_rst_i,
171
            ctrl_wr   => config_wr,
172
            ctrl_rd   => config_rd,
173
            ctrl_din  => wb_dat_i,
174
            ctrl_dout => config_dout,
175
            ctrl_bits => config_bits);
176
      conf_res(5 downto 0) <= "010000";  -- 16bit only
177
   end generate CG16;
178
   conf_ratio(7 downto 0) <= config_bits(15 downto 8);
179
   conf_rswap             <= config_bits(2);
180
   conf_rinten            <= config_bits(1);
181
   conf_rxen              <= config_bits(0);
182
 
183 12 gedra
-- TxIntMask - interrupt mask register
184 24 gedra
   IM32 : if DATA_WIDTH = 32 generate
185
      IMASK : gen_control_reg
186
         generic map (
187
            DATA_WIDTH      => 32,
188
            ACTIVE_BIT_MASK => "11000000000000000000000000000000")
189
         port map (
190
            clk       => wb_clk_i,
191
            rst       => wb_rst_i,
192
            ctrl_wr   => intmask_wr,
193
            ctrl_rd   => intmask_rd,
194
            ctrl_din  => wb_dat_i,
195
            ctrl_dout => intmask_dout,
196
            ctrl_bits => intmask_bits);
197
   end generate IM32;
198
   IM16 : if DATA_WIDTH = 16 generate
199
      IMASK : gen_control_reg
200
         generic map (
201
            DATA_WIDTH      => 16,
202
            ACTIVE_BIT_MASK => "1100000000000000")
203
         port map (
204
            clk       => wb_clk_i,
205
            rst       => wb_rst_i,
206
            ctrl_wr   => intmask_wr,
207
            ctrl_rd   => intmask_rd,
208
            ctrl_din  => wb_dat_i,
209
            ctrl_dout => intmask_dout,
210
            ctrl_bits => intmask_bits);
211
   end generate IM16;
212
 
213
-- TxIntStat - interrupt status register
214
   ISTAT : gen_event_reg
215 12 gedra
      generic map (
216 24 gedra
         DATA_WIDTH => DATA_WIDTH)
217 12 gedra
      port map (
218 24 gedra
         clk      => wb_clk_i,
219
         rst      => wb_rst_i,
220
         evt_wr   => intstat_wr,
221
         evt_rd   => intstat_rd,
222
         evt_din  => wb_dat_i,
223
         evt_dout => intstat_dout,
224
         event    => intstat_events,
225
         evt_mask => intmask_bits,
226
         evt_en   => conf_rinten,
227
         evt_irq  => rx_int_o);
228
   intstat_events(0)                       <= evt_lsbf;  -- lower sample buffer empty
229
   intstat_events(1)                       <= evt_hsbf;  -- higher sampel buffer empty
230
   intstat_events(DATA_WIDTH - 1 downto 2) <= (others => '0');
231
 
232
-- Sample buffer memory
233
   MEM : dpram
234 12 gedra
      generic map (
235 24 gedra
         DATA_WIDTH => DATA_WIDTH,
236
         RAM_WIDTH  => ADDR_WIDTH - 1)
237 12 gedra
      port map (
238 24 gedra
         clk     => wb_clk_i,
239
         rst     => wb_rst_i,
240
         din     => sbuf_din,
241
         wr_en   => mem_wr,
242
         rd_en   => mem_rd,
243
         wr_addr => sbuf_wr_adr,
244
         rd_addr => sbuf_rd_adr,
245
         dout    => sbuf_dout);
246 12 gedra
 
247
-- Receive decoder
248 24 gedra
   zero  <= '0';
249
   zeros <= (others => '0');
250
 
251
   DEC : i2s_codec
252
      generic map (DATA_WIDTH  => DATA_WIDTH,
253
                   ADDR_WIDTH  => ADDR_WIDTH,
254
                   IS_MASTER   => 1,
255
                   IS_RECEIVER => 1)
256
      port map (
257
         wb_clk_i     => wb_clk_i,
258
         conf_res     => conf_res,
259
         conf_ratio   => conf_ratio,
260
         conf_swap    => conf_rswap,
261
         conf_en      => conf_rxen,
262
         i2s_sd_i     => i2s_sd_i,
263
         i2s_sck_i    => zero,
264
         i2s_ws_i     => zero,
265
         sample_dat_i => zeros,
266
         sample_dat_o => sbuf_din,
267
         mem_rdwr     => mem_wr,
268
         sample_addr  => sbuf_wr_adr,
269
         evt_hsbf     => evt_hsbf,
270
         evt_lsbf     => evt_lsbf,
271
         i2s_sd_o     => open,
272
         i2s_sck_o    => i2s_sck_o,
273
         i2s_ws_o     => i2s_ws_o);
274
 
275 12 gedra
end rtl;
276
 

powered by: WebSVN 2.1.0

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