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

Subversion Repositories i2s_interface

[/] [i2s_interface/] [trunk/] [rtl/] [vhdl/] [tx_i2s_topm.vhd] - Blame information for rev 14

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

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

powered by: WebSVN 2.1.0

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