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 18

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

powered by: WebSVN 2.1.0

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