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 18

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

powered by: WebSVN 2.1.0

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