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 8

Go to most recent revision | 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
---- PURPOSE. See the GNU General Public License for more details.----                                          
36
----                                                              ----
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
--
47
--
48
 
49
library ieee;
50
use ieee.std_logic_1164.all;
51
use ieee.numeric_std.all;
52
 
53
entity rx_i2s_wbd is
54
  generic (DATA_WIDTH: integer;
55
           ADDR_WIDTH: integer);
56
  port (
57
    wb_clk_i: in std_logic;             -- wishbone clock
58
    wb_rst_i: in std_logic;             -- reset signal
59
    wb_sel_i: in std_logic;             -- select input
60
    wb_stb_i: in std_logic;             -- strobe input
61
    wb_we_i: in std_logic;              -- write enable
62
    wb_cyc_i: in std_logic;             -- cycle input
63
    wb_bte_i: in std_logic_vector(1 downto 0);  -- burts type extension
64
    wb_cti_i: in std_logic_vector(2 downto 0);  -- cycle type identifier
65
    wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);  -- address
66
    data_out: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- internal bus
67
    wb_ack_o: out std_logic;            -- acknowledge
68
    wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);  -- data out
69
    version_rd: out std_logic;          -- Version register read 
70
    config_rd: out std_logic;           -- Config register read
71
    config_wr: out std_logic;           -- Config register write
72
    intmask_rd: out std_logic;          -- Interrupt mask register read
73
    intmask_wr: out std_logic;          -- Interrupt mask register write
74
    intstat_rd: out std_logic;          -- Interrupt status register read
75
    intstat_wr: out std_logic;          -- Interrupt status register read
76
    mem_rd: out std_logic;              -- Sample memory read
77
    mem_addr: out std_logic_vector(ADDR_WIDTH - 2 downto 0));  -- memory addr.
78
end rx_i2s_wbd;
79
 
80
architecture rtl of rx_i2s_wbd is
81
 
82
  constant REG_RXVERSION : std_logic_vector(3 downto 0) := "0000";
83
  constant REG_RXCONFIG  : std_logic_vector(3 downto 0) := "0001";
84
  constant REG_RXINTMASK : std_logic_vector(3 downto 0) := "0010";
85
  constant REG_RXINTSTAT : std_logic_vector(3 downto 0) := "0011";
86
  signal iack, iwr, ird : std_logic;
87
  signal acnt: integer range 0 to 2**(ADDR_WIDTH - 1) - 1;
88
  signal all_ones : std_logic_vector(ADDR_WIDTH - 1 downto 0);
89
  signal rdout : std_logic_vector(DATA_WIDTH - 1 downto 0);
90
 
91
begin
92
 
93
  wb_ack_o <= iack;
94
 
95
-- acknowledge generation
96
  ACK: process (wb_clk_i, wb_rst_i)
97
  begin
98
    if wb_rst_i = '1' then
99
      iack <= '0';
100
    elsif rising_edge(wb_clk_i) then
101
      if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' then
102
        case wb_cti_i is
103
          when "010" => -- incrementing burst
104
            case wb_bte_i is -- burst extension
105
              when "00" => -- linear burst
106
                iack <= '1';
107
              when others => -- all other treated assert classic cycle
108
                iack <= not iack;
109
            end case;
110
          when "111" => -- end of burst
111
            iack <= not iack;
112
          when others => -- all other treated assert classic cycle 
113
            iack <= not iack;
114
        end case;
115
      else
116
        iack <= '0';
117
      end if;
118
    end if;
119
  end process ACK;
120
 
121
-- write generation      
122
  WR: process (wb_clk_i, wb_rst_i)
123
  begin
124
    if wb_rst_i = '1' then
125
      iwr <= '0';
126
    elsif rising_edge(wb_clk_i) then
127
      if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
128
        wb_we_i = '1' then
129
        case wb_cti_i is
130
          when "010" => -- incrementing burst
131
            case wb_bte_i is -- burst extension
132
              when "00" => -- linear burst
133
                iwr <= '1';
134
              when others => -- all other treated assert classic cycle
135
                iwr <= not iwr;
136
            end case;
137
          when "111" => -- end of burst
138
            iwr <= not iwr;
139
          when others => -- all other treated assert classic cycle   
140
            iwr <= not iwr;
141
        end case;
142
      else
143
        iwr <= '0';
144
      end if;
145
    end if;
146
  end process WR;
147
 
148
-- read generation
149
  ird <= '1' when wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
150
         wb_we_i = '0' else '0';
151
 
152
  wb_dat_o <= data_out when wb_adr_i(ADDR_WIDTH - 1) = '1' else rdout;
153
 
154
  DREG: process (wb_clk_i)              -- clock data from registers
155
  begin
156
    if rising_edge(wb_clk_i) then
157
      rdout <= data_out;
158
    end if;
159
  end process DREG;
160
 
161
-- sample memory read address. This needs special attention due to read latency
162
  mem_addr <= std_logic_vector(to_unsigned(acnt, ADDR_WIDTH - 1)) when
163
              wb_cti_i = "010" and wb_we_i = '0' and iack = '1' and
164
              wb_bte_i = "00" else wb_adr_i(ADDR_WIDTH - 2 downto 0);
165
 
166
  all_ones(ADDR_WIDTH - 1 downto 0) <= (others => '1');
167
 
168
  SMA: process (wb_clk_i, wb_rst_i)
169
  begin
170
    if wb_rst_i = '1' then
171
      acnt <= 0;
172
    elsif rising_edge(wb_clk_i) then
173
      if wb_cti_i = "010" and wb_we_i = '0' and wb_bte_i = "00" then
174
        if iack = '0' then
175
          if wb_adr_i = all_ones then
176
            acnt <= 0;
177
          else
178
            acnt <= to_integer(unsigned(wb_adr_i)) + 1;
179
          end if;
180
        else
181
          if acnt < 2**(ADDR_WIDTH - 1) - 1 then
182
            acnt <= acnt + 1;
183
          else
184
            acnt <= 0;
185
          end if;
186
        end if;
187
      end if;
188
    end if;
189
  end process SMA;
190
 
191
-- read and write strobe generation
192
 
193
  version_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXVERSION and ird = '1'
194
                else '0';
195
  config_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXCONFIG and ird = '1'
196
               else '0';
197
  config_wr <= '1' when wb_adr_i(3 downto 0) = REG_RXCONFIG and iwr = '1'
198
               else '0';
199
  intmask_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXINTMASK and ird = '1'
200
                else '0';
201
  intmask_wr <= '1' when wb_adr_i(3 downto 0) = REG_RXINTMASK and iwr = '1'
202
                else '0';
203
  intstat_rd <= '1' when wb_adr_i(3 downto 0) = REG_RXINTSTAT and ird = '1'
204
                else '0';
205
  intstat_wr <= '1' when wb_adr_i(3 downto 0) = REG_RXINTSTAT and iwr = '1'
206
                else '0';
207
  mem_rd <= '1' when wb_adr_i(ADDR_WIDTH - 1) = '1' and ird = '1' else '0';
208
 
209
end rtl;

powered by: WebSVN 2.1.0

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