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

Subversion Repositories i2s_interface

[/] [i2s_interface/] [trunk/] [rtl/] [vhdl/] [rx_i2s_wbd.vhd] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 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 Wishbone bus cycle decoder.                     ----
10
----                                                              ----
11
---- To Do:                                                       ----
12
---- -                                                            ----
13
----                                                              ----
14
---- Author(s):                                                   ----
15
---- - Geir Drange, gedra@opencores.org                           ----
16
----                                                              ----
17
----------------------------------------------------------------------
18
----                                                              ----
19
---- Copyright (C) 2004 Authors and OPENCORES.ORG                 ----
20
----                                                              ----
21
---- This source file may be used and distributed without         ----
22
---- restriction provided that this copyright statement is not    ----
23
---- removed from the file and that any derivative work contains  ----
24
---- the original copyright notice and the associated disclaimer. ----
25
----                                                              ----
26
---- This source file is free software; you can redistribute it   ----
27
---- and/or modify it under the terms of the GNU General          ----
28
---- Public License as published by the Free Software Foundation; ----
29
---- either version 2.0 of the License, or (at your option) any   ----
30
---- later version.                                               ----
31
----                                                              ----
32
---- This source is distributed in the hope that it will be       ----
33
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ----
34
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ----
35 18 gedra
---- PURPOSE. See the GNU General Public License for more details.----
36 8 gedra
----                                                              ----
37
---- You should have received a copy of the GNU General           ----
38
---- Public License along with this source; if not, download it   ----
39
---- from http://www.gnu.org/licenses/gpl.txt                     ----
40
----                                                              ----
41
----------------------------------------------------------------------
42
--
43
-- CVS Revision History
44
--
45
-- $Log: not supported by cvs2svn $
46 24 gedra
-- Revision 1.3  2005/01/17 17:26:47  gedra
47
-- Bugfix of register read/write strobes
48
--
49 22 gedra
-- Revision 1.2  2004/08/06 18:55:43  gedra
50
-- De-linting.
51
--
52 18 gedra
-- Revision 1.1  2004/08/03 18:50:29  gedra
53
-- Receiver Wishbone cycle decoder.
54 8 gedra
--
55
--
56 18 gedra
--
57 8 gedra
 
58
library ieee;
59
use ieee.std_logic_1164.all;
60
use ieee.numeric_std.all;
61
 
62 24 gedra
entity rx_i2s_wbd is
63
   generic (DATA_WIDTH : integer;
64
            ADDR_WIDTH : integer);
65
   port (
66
      wb_clk_i   : in  std_logic;       -- wishbone clock
67
      wb_rst_i   : in  std_logic;       -- reset signal
68
      wb_sel_i   : in  std_logic;       -- select input
69
      wb_stb_i   : in  std_logic;       -- strobe input
70
      wb_we_i    : in  std_logic;       -- write enable
71
      wb_cyc_i   : in  std_logic;       -- cycle input
72
      wb_bte_i   : in  std_logic_vector(1 downto 0);  -- burts type extension
73
      wb_cti_i   : in  std_logic_vector(2 downto 0);  -- cycle type identifier
74
      wb_adr_i   : in  std_logic_vector(ADDR_WIDTH - 1 downto 0);  -- address
75
      data_out   : in  std_logic_vector(DATA_WIDTH - 1 downto 0);  -- internal bus
76
      wb_ack_o   : out std_logic;       -- acknowledge
77
      wb_dat_o   : out std_logic_vector(DATA_WIDTH - 1 downto 0);  -- data out
78
      version_rd : out std_logic;       -- Version register read 
79
      config_rd  : out std_logic;       -- Config register read
80
      config_wr  : out std_logic;       -- Config register write
81
      intmask_rd : out std_logic;       -- Interrupt mask register read
82
      intmask_wr : out std_logic;       -- Interrupt mask register write
83
      intstat_rd : out std_logic;       -- Interrupt status register read
84
      intstat_wr : out std_logic;       -- Interrupt status register read
85
      mem_rd     : out std_logic;       -- Sample memory read
86
      mem_addr   : out std_logic_vector(ADDR_WIDTH - 2 downto 0));  -- memory addr.
87 8 gedra
end rx_i2s_wbd;
88
 
89
architecture rtl of rx_i2s_wbd is
90 24 gedra
 
91
   constant REG_RXVERSION : std_logic_vector(3 downto 0) := "0000";
92
   constant REG_RXCONFIG  : std_logic_vector(3 downto 0) := "0001";
93
   constant REG_RXINTMASK : std_logic_vector(3 downto 0) := "0010";
94
   constant REG_RXINTSTAT : std_logic_vector(3 downto 0) := "0011";
95
   signal iack, iwr, ird  : std_logic;
96
   signal acnt            : integer range 0 to 2**(ADDR_WIDTH - 1) - 1;
97
   signal all_ones        : std_logic_vector(ADDR_WIDTH - 1 downto 0);
98
   signal rdout           : std_logic_vector(DATA_WIDTH - 1 downto 0);
99
 
100
begin
101 8 gedra
 
102 24 gedra
   wb_ack_o <= iack;
103 8 gedra
 
104
-- acknowledge generation
105 24 gedra
   ACK : process (wb_clk_i, wb_rst_i)
106
   begin
107
      if wb_rst_i = '1' then
108
         iack <= '0';
109
      elsif rising_edge(wb_clk_i) then
110
         if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' then
111
            case wb_cti_i is
112
               when "010" =>            -- incrementing burst
113
                  case wb_bte_i is      -- burst extension
114
                     when "00" =>       -- linear burst
115
                        iack <= '1';
116
                     when others =>  -- all other treated assert classic cycle
117
                        iack <= not iack;
118
                  end case;
119
               when "111" =>            -- end of burst
120
                  iack <= not iack;
121
               when others =>        -- all other treated assert classic cycle 
122
                  iack <= not iack;
123
            end case;
124
         else
125
            iack <= '0';
126
         end if;
127
      end if;
128
   end process ACK;
129 8 gedra
 
130
-- write generation      
131 24 gedra
   WR : process (wb_clk_i, wb_rst_i)
132
   begin
133
      if wb_rst_i = '1' then
134
         iwr <= '0';
135
      elsif rising_edge(wb_clk_i) then
136
         if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
137
            wb_we_i = '1' then
138
            case wb_cti_i is
139
               when "010" =>            -- incrementing burst
140
                  case wb_bte_i is      -- burst extension
141
                     when "00" =>       -- linear burst
142
                        iwr <= '1';
143
                     when others =>  -- all other treated assert classic cycle
144
                        iwr <= not iwr;
145
                  end case;
146
               when "111" =>            -- end of burst
147
                  iwr <= not iwr;
148
               when others =>  -- all other treated assert classic cycle   
149
                  iwr <= not iwr;
150
            end case;
151
         else
152
            iwr <= '0';
153
         end if;
154
      end if;
155
   end process WR;
156 8 gedra
 
157
-- read generation
158 24 gedra
   ird <= '1' when wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
159
          wb_we_i = '0' else '0';
160 8 gedra
 
161 24 gedra
   wb_dat_o <= data_out when wb_adr_i(ADDR_WIDTH - 1) = '1' else rdout;
162 8 gedra
 
163 24 gedra
   DREG : process (wb_clk_i)            -- clock data from registers
164
   begin
165
      if rising_edge(wb_clk_i) then
166
         rdout <= data_out;
167
      end if;
168
   end process DREG;
169
 
170 8 gedra
-- sample memory read address. This needs special attention due to read latency
171 24 gedra
   mem_addr <= std_logic_vector(to_unsigned(acnt, ADDR_WIDTH - 1)) when
172
               wb_cti_i = "010" and wb_we_i = '0' and iack = '1' and
173
               wb_bte_i = "00" else wb_adr_i(ADDR_WIDTH - 2 downto 0);
174
 
175
   all_ones(ADDR_WIDTH - 1 downto 0) <= (others => '1');
176
 
177
   SMA : process (wb_clk_i, wb_rst_i)
178
   begin
179
      if wb_rst_i = '1' then
180
         acnt <= 0;
181
      elsif rising_edge(wb_clk_i) then
182
         if wb_cti_i = "010" and wb_we_i = '0' and wb_bte_i = "00" then
183
            if iack = '0' then
184
               if wb_adr_i = all_ones then
185
                  acnt <= 0;
186
               else
187
                  acnt <= to_integer(unsigned(wb_adr_i)) + 1;
188
               end if;
189
            else
190
               if acnt < 2**(ADDR_WIDTH - 1) - 1 then
191
                  acnt <= acnt + 1;
192
               else
193
                  acnt <= 0;
194
               end if;
195
            end if;
196
         end if;
197 8 gedra
      end if;
198 24 gedra
   end process SMA;
199
 
200 8 gedra
-- read and write strobe generation
201 24 gedra
 
202
   version_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXVERSION and ird = '1'
203
                 and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
204
   config_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXCONFIG and ird = '1'
205 22 gedra
                and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
206 24 gedra
   config_wr <= '1' when wb_adr_i(3 downto 0) = REG_RXCONFIG and iwr = '1'
207 22 gedra
                and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
208 24 gedra
   intmask_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXINTMASK and ird = '1'
209
                 and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
210
   intmask_wr <= '1' when wb_adr_i(3 downto 0) = REG_RXINTMASK and iwr = '1'
211
                 and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
212
   intstat_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXINTSTAT and ird = '1'
213
                 and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
214
   intstat_wr <= '1' when wb_adr_i(3 downto 0) = REG_RXINTSTAT and iwr = '1'
215
                 and wb_adr_i(ADDR_WIDTH - 1) = '0' else '0';
216
   mem_rd <= '1' when wb_adr_i(ADDR_WIDTH - 1) = '1' and ird = '1' else '0';
217
 
218 8 gedra
end rtl;

powered by: WebSVN 2.1.0

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