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 26

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

powered by: WebSVN 2.1.0

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