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 18

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

powered by: WebSVN 2.1.0

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