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

Subversion Repositories i2s_interface

[/] [i2s_interface/] [trunk/] [rtl/] [vhdl/] [tx_i2s_tops.vhd] - Blame information for rev 18

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

Line No. Rev Author Line
1 15 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. Top level entity for the transmitter core,  ----
10
---- slave 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 15 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:30:28  gedra
48
-- Transmitter top level, slave mode.
49 15 gedra
--
50
--
51 18 gedra
--
52 15 gedra
 
53
library ieee;
54
use ieee.std_logic_1164.all;
55
use work.tx_i2s_pack.all;
56
 
57
entity tx_i2s_tops 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_sck_i: in std_logic;
72
    i2s_ws_i: in std_logic;
73
    wb_ack_o: out std_logic;
74
    wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);
75
    tx_int_o: out std_logic;
76
    i2s_sd_o: out std_logic);
77
end tx_i2s_tops;
78
 
79
architecture rtl of tx_i2s_tops 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 15 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 sample_addr : std_logic_vector(ADDR_WIDTH - 2 downto 0);
94
  signal sample_data: std_logic_vector(DATA_WIDTH - 1 downto 0);
95
  signal conf_ratio : std_logic_vector(7 downto 0);
96
  signal conf_res : std_logic_vector(5 downto 0);
97
  signal conf_tswap, conf_tinten, conf_txen : 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 (others => '0');
105
 
106
-- Wishbone bus cycle decoder
107
  WB: tx_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_wr => mem_wr);
132
 
133
-- TxVersion - Version register
134
  VER : i2s_version
135
    generic map (
136
      DATA_WIDTH => DATA_WIDTH,
137
      ADDR_WIDTH => ADDR_WIDTH,
138
      IS_MASTER => 0)
139
    port map (
140
      ver_rd => version_rd,
141
      ver_dout => version_dout);
142
 
143
-- TxConfig - Configuration register
144
  CG32: if DATA_WIDTH = 32 generate
145
    CONF: gen_control_reg
146
      generic map (
147
        DATA_WIDTH => 32,
148
        ACTIVE_BIT_MASK => "11100000111111111111110000000000")
149
      port map (
150
        clk => wb_clk_i,
151
        rst => wb_rst_i,
152
        ctrl_wr => config_wr,
153
        ctrl_rd => config_rd,
154
        ctrl_din => wb_dat_i,
155
        ctrl_dout => config_dout,
156
        ctrl_bits => config_bits);
157
    conf_res(5 downto 0) <= config_bits(21 downto 16);
158
  end generate CG32;
159
  CG16: if DATA_WIDTH = 16 generate
160
    CONF: gen_control_reg
161
      generic map (
162
        DATA_WIDTH => 16,
163
        ACTIVE_BIT_MASK => "1110000011111111")
164
      port map (
165
        clk => wb_clk_i,
166
        rst => wb_rst_i,
167
        ctrl_wr => config_wr,
168
        ctrl_rd => config_rd,
169
        ctrl_din => wb_dat_i,
170
        ctrl_dout => config_dout,
171
        ctrl_bits => config_bits);
172
    conf_res(5 downto 0) <= "010000";    -- 16bit only
173
  end generate CG16;
174
    conf_ratio(7 downto 0) <= config_bits(15 downto 8);
175
    conf_tswap <= config_bits(2);
176
    conf_tinten <= config_bits(1);
177
    conf_txen <= config_bits(0);
178
 
179
-- TxIntMask - interrupt mask register
180
  IM32: if DATA_WIDTH = 32 generate
181
    IMASK: gen_control_reg
182
      generic map (
183
        DATA_WIDTH => 32,
184
        ACTIVE_BIT_MASK => "11000000000000000000000000000000")
185
      port map (
186
        clk => wb_clk_i,
187
        rst => wb_rst_i,
188
        ctrl_wr => intmask_wr,
189
        ctrl_rd => intmask_rd,
190
        ctrl_din => wb_dat_i,
191
        ctrl_dout => intmask_dout,
192
        ctrl_bits => intmask_bits);
193
  end generate IM32;
194
  IM16: if DATA_WIDTH = 16 generate
195
    IMASK: gen_control_reg
196
      generic map (
197
        DATA_WIDTH => 16,
198
        ACTIVE_BIT_MASK => "1100000000000000")
199
      port map (
200
        clk => wb_clk_i,
201
        rst => wb_rst_i,
202
        ctrl_wr => intmask_wr,
203
        ctrl_rd => intmask_rd,
204
        ctrl_din => wb_dat_i,
205
        ctrl_dout => intmask_dout,
206
        ctrl_bits => intmask_bits);
207
  end generate IM16;
208
 
209
-- TxIntStat - interrupt status register
210
  ISTAT: gen_event_reg
211
    generic map (
212
      DATA_WIDTH => DATA_WIDTH)
213
    port map (
214
      clk => wb_clk_i,
215
      rst => wb_rst_i,
216
      evt_wr => intstat_wr,
217
      evt_rd => intstat_rd,
218
      evt_din => wb_dat_i,
219
      evt_dout => intstat_dout,
220
      event => intstat_events,
221
      evt_mask => intmask_bits,
222
      evt_en => conf_tinten,
223
      evt_irq => tx_int_o);
224
    intstat_events(0) <= evt_lsbf;        -- lower sample buffer empty
225
    intstat_events(1) <= evt_hsbf;        -- higher sampel buffer empty
226
    intstat_events(DATA_WIDTH - 1 downto 2) <= (others => '0');
227
 
228
-- Sample buffer memory
229
  MEM: dpram
230
    generic map (
231
      DATA_WIDTH => DATA_WIDTH,
232
      RAM_WIDTH => ADDR_WIDTH - 1)
233
    port map (
234
      clk => wb_clk_i,
235
      rst => wb_rst_i,
236
      din => wb_dat_i(DATA_WIDTH - 1 downto 0),
237
      wr_en => mem_wr,
238
      rd_en => mem_rd,
239
      wr_addr => wb_adr_i(ADDR_WIDTH - 2 downto 0),
240
      rd_addr => sample_addr,
241
      dout => sample_data);
242
 
243
-- Transmit encoder
244
    zero <= '0';
245
 
246
    ENC: i2s_codec
247
    generic map (DATA_WIDTH => DATA_WIDTH,
248
                 ADDR_WIDTH => ADDR_WIDTH,
249
                 IS_MASTER => 0,
250
                 IS_RECEIVER => 0)
251
    port map (
252
      wb_clk_i => wb_clk_i,
253
      conf_res => conf_res,
254
      conf_ratio => conf_ratio,
255
      conf_swap => conf_tswap,
256
      conf_en => conf_txen,
257
      i2s_sd_i => zero,
258
      i2s_sck_i => i2s_sck_i,
259
      i2s_ws_i => i2s_ws_i,
260
      sample_dat_i => sample_data,
261
      sample_dat_o => open,
262
      mem_rdwr => mem_rd,
263
      sample_addr => sample_addr,
264
      evt_hsbf => evt_hsbf,
265
      evt_lsbf => evt_lsbf,
266
      i2s_sd_o => i2s_sd_o,
267
      i2s_sck_o => open,
268
      i2s_ws_o => open);
269
 
270
end rtl;
271
 

powered by: WebSVN 2.1.0

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