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 22

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

powered by: WebSVN 2.1.0

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