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

Subversion Repositories i2s_interface

[/] [i2s_interface/] [trunk/] [rtl/] [vhdl/] [tx_i2s_wbd.vhd] - Blame information for rev 9

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 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 Wishbone bus cycle decoder.                  ----
10
----                                                              ----
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
---- PURPOSE. See the GNU General Public License for more details.----                                          
37
----                                                              ----
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
--
48
--
49
 
50
library ieee;
51
use ieee.std_logic_1164.all;
52
use ieee.numeric_std.all;
53
 
54
entity tx_i2s_wbd is
55
  generic (DATA_WIDTH: integer;
56
           ADDR_WIDTH: integer);
57
  port (
58
    wb_clk_i: in std_logic;             -- wishbone clock
59
    wb_rst_i: in std_logic;             -- reset signal
60
    wb_sel_i: in std_logic;             -- select input
61
    wb_stb_i: in std_logic;             -- strobe input
62
    wb_we_i: in std_logic;              -- write enable
63
    wb_cyc_i: in std_logic;             -- cycle input
64
    wb_bte_i: in std_logic_vector(1 downto 0);  -- burts type extension
65
    wb_cti_i: in std_logic_vector(2 downto 0);  -- cycle type identifier
66
    wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);  -- address
67
    data_out: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- internal bus
68
    wb_ack_o: out std_logic;            -- acknowledge
69
    wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);  -- data out
70
    version_rd: out std_logic;          -- Version register read 
71
    config_rd: out std_logic;           -- Config register read
72
    config_wr: out std_logic;           -- Config register write
73
    intmask_rd: out std_logic;          -- Interrupt mask register read
74
    intmask_wr: out std_logic;          -- Interrupt mask register write
75
    intstat_rd: out std_logic;          -- Interrupt status register read
76
    intstat_wr: out std_logic;          -- Interrupt status register read
77
    mem_wr: out std_logic);             -- Sample memory write
78
end tx_i2s_wbd;
79
 
80
architecture rtl of tx_i2s_wbd is
81
 
82
  constant REG_TXVERSION : std_logic_vector(3 downto 0) := "0000";
83
  constant REG_TXCONFIG  : std_logic_vector(3 downto 0) := "0001";
84
  constant REG_TXINTMASK : std_logic_vector(3 downto 0) := "0010";
85
  constant REG_TXINTSTAT : 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 rdout : std_logic_vector(DATA_WIDTH - 1 downto 0);
89
 
90
begin
91
 
92
  wb_ack_o <= iack;
93
 
94
-- acknowledge generation
95
  ACK: process (wb_clk_i, wb_rst_i)
96
  begin
97
    if wb_rst_i = '1' then
98
      iack <= '0';
99
    elsif rising_edge(wb_clk_i) then
100
      if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' then
101
        case wb_cti_i is
102
          when "010" => -- incrementing burst
103
            case wb_bte_i is -- burst extension
104
              when "00" => -- linear burst
105
                iack <= '1';
106
              when others => -- all other treated assert classic cycle
107
                iack <= not iack;
108
            end case;
109
          when "111" => -- end of burst
110
            iack <= not iack;
111
          when others => -- all other treated assert classic cycle 
112
            iack <= not iack;
113
        end case;
114
      else
115
        iack <= '0';
116
      end if;
117
    end if;
118
  end process ACK;
119
 
120
-- write generation      
121
  WR: process (wb_clk_i, wb_rst_i)
122
  begin
123
    if wb_rst_i = '1' then
124
      iwr <= '0';
125
    elsif rising_edge(wb_clk_i) then
126
      if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
127
        wb_we_i = '1' then
128
        case wb_cti_i is
129
          when "010" => -- incrementing burst
130
            case wb_bte_i is -- burst extension
131
              when "00" => -- linear burst
132
                iwr <= '1';
133
              when others => -- all other treated as classic cycle
134
                iwr <= not iwr;
135
            end case;
136
          when "111" => -- end of burst
137
            iwr <= not iwr;
138
          when others => -- all other treated as classic cycle   
139
            iwr <= not iwr;
140
        end case;
141
      else
142
        iwr <= '0';
143
      end if;
144
    end if;
145
  end process WR;
146
 
147
-- read generation
148
  ird <= '1' when wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
149
         wb_we_i = '0' else '0';
150
 
151
  wb_dat_o <= data_out when wb_adr_i(ADDR_WIDTH - 1) = '1' else rdout;
152
 
153
  DREG: process (wb_clk_i)              -- clock data from registers
154
  begin
155
    if rising_edge(wb_clk_i) then
156
      rdout <= data_out;
157
    end if;
158
  end process DREG;
159
 
160
-- read and write strobe generation
161
 
162
  version_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXVERSION and ird = '1'
163
                else '0';
164
  config_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXCONFIG and ird = '1'
165
               else '0';
166
  config_wr <= '1' when wb_adr_i(3 downto 0) = REG_TXCONFIG and iwr = '1'
167
               else '0';
168
  intmask_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXINTMASK and ird = '1'
169
                else '0';
170
  intmask_wr <= '1' when wb_adr_i(3 downto 0) = REG_TXINTMASK and iwr = '1'
171
                else '0';
172
  intstat_rd <= '1' when wb_adr_i(3 downto 0) = REG_TXINTSTAT and ird = '1'
173
                else '0';
174
  intstat_wr <= '1' when wb_adr_i(3 downto 0) = REG_TXINTSTAT and iwr = '1'
175
                else '0';
176
  mem_wr <= '1' when wb_adr_i(ADDR_WIDTH - 1) = '1' and iwr = '1' else '0';
177
 
178
end rtl;

powered by: WebSVN 2.1.0

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