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 12

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

powered by: WebSVN 2.1.0

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