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

Subversion Repositories spdif_interface

[/] [spdif_interface/] [trunk/] [rtl/] [vhdl/] [rx_wb_decoder.vhd] - Blame information for rev 37

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

Line No. Rev Author Line
1 29 gedra
----------------------------------------------------------------------
2
----                                                              ----
3
---- WISHBONE SPDIF IP Core                                       ----
4
----                                                              ----
5
---- This file is part of the SPDIF project                       ----
6
---- http://www.opencores.org/cores/spdif_interface/              ----
7
----                                                              ----
8
---- Description                                                  ----
9
---- SPDIF receiver: 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 Lesser General   ----
29
---- Public License as published by the Free Software Foundation; ----
30
---- either version 2.1 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 Lesser General Public License for more  ----
37
---- details.                                                     ----
38
----                                                              ----
39
---- You should have received a copy of the GNU Lesser General    ----
40
---- Public License along with this source; if not, download it   ----
41
---- from http://www.opencores.org/lgpl.shtml                     ----
42
----                                                              ----
43
----------------------------------------------------------------------
44
--
45
-- CVS Revision History
46
--
47
-- $Log: not supported by cvs2svn $
48 37 gedra
-- Revision 1.2  2004/06/24 19:25:03  gedra
49
-- Added data output.
50
--
51 31 gedra
-- Revision 1.1  2004/06/23 18:09:57  gedra
52
-- Wishbone bus cycle decoder.
53 29 gedra
--
54 31 gedra
--
55 29 gedra
 
56 37 gedra
library ieee;
57
use ieee.std_logic_1164.all;
58
use ieee.numeric_std.all;
59 29 gedra
 
60
entity rx_wb_decoder is
61
  generic (DATA_WIDTH: integer;
62
           ADDR_WIDTH: integer);
63
  port (
64
    wb_clk_i: in std_logic;             -- wishbone clock
65
    wb_rst_i: in std_logic;             -- reset signal
66
    wb_sel_i: in std_logic;             -- select input
67
    wb_stb_i: in std_logic;             -- strobe input
68
    wb_we_i: in std_logic;              -- write enable
69
    wb_cyc_i: in std_logic;             -- cycle input
70
    wb_bte_i: in std_logic_vector(1 downto 0);  -- burts type extension
71
    wb_cti_i: in std_logic_vector(2 downto 0);  -- cycle type identifier
72
    wb_adr_i: in std_logic_vector(ADDR_WIDTH - 1 downto 0);  -- address
73
    data_out: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- internal bus
74
    wb_ack_o: out std_logic;            -- acknowledge
75
    wb_dat_o: out std_logic_vector(DATA_WIDTH - 1 downto 0);  -- data out
76
    version_rd: out std_logic;          -- Version register read 
77
    config_rd: out std_logic;           -- Config register read
78
    config_wr: out std_logic;           -- Config register write
79
    status_rd: out std_logic;           -- Status register read
80
    intmask_rd: out std_logic;          -- Interrupt mask register read
81
    intmask_wr: out std_logic;          -- Interrupt mask register write
82
    intstat_rd: out std_logic;          -- Interrupt status register read
83
    intstat_wr: out std_logic;          -- Interrupt status register read
84
    mem_rd: out std_logic;              -- Sample memory read
85
    mem_addr: out std_logic_vector(ADDR_WIDTH - 2 downto 0);  -- memory addr.
86
    ch_st_cap_rd: out std_logic_vector(7 downto 0);  -- Ch. status cap. read
87
    ch_st_cap_wr: out std_logic_vector(7 downto 0);  -- Ch. status cap. write
88
    ch_st_data_rd: out std_logic_vector(7 downto 0));  -- Ch. status data read
89
end rx_wb_decoder;
90
 
91
architecture rtl of rx_wb_decoder is
92
 
93
  constant REG_RXVERSION : std_logic_vector(6 downto 0) := "0000000";
94
  constant REG_RXCONFIG  : std_logic_vector(6 downto 0) := "0000001";
95
  constant REG_RXSTATUS  : std_logic_vector(6 downto 0) := "0000010";
96
  constant REG_RXINTMASK : std_logic_vector(6 downto 0) := "0000011";
97
  constant REG_RXINTSTAT : std_logic_vector(6 downto 0) := "0000100";
98
  signal iack, iwr, ird : std_logic;
99
  signal acnt: integer range 0 to 2**(ADDR_WIDTH - 1) - 1;
100
  signal all_ones : std_logic_vector(ADDR_WIDTH - 1 downto 0);
101 31 gedra
  signal rdout : std_logic_vector(DATA_WIDTH - 1 downto 0);
102 29 gedra
 
103
begin
104
 
105
  wb_ack_o <= iack;
106
 
107
-- acknowledge generation
108
  ACK: process (wb_clk_i, wb_rst_i)
109
  begin
110
    if wb_rst_i = '1' then
111
      iack <= '0';
112
    elsif rising_edge(wb_clk_i) then
113
      if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' then
114
        case wb_cti_i is
115
          when "010" => -- incrementing burst
116
            case wb_bte_i is -- burst extension
117
              when "00" => -- linear burst
118
                iack <= '1';
119
              when others => -- all other treated assert classic cycle
120
                iack <= not iack;
121
            end case;
122
          when "111" => -- end of burst
123
            iack <= not iack;
124
          when others => -- all other treated assert classic cycle 
125
            iack <= not iack;
126
        end case;
127
      else
128
        iack <= '0';
129
      end if;
130
    end if;
131
  end process ACK;
132
 
133
-- write generation      
134
  WR: process (wb_clk_i, wb_rst_i)
135
  begin
136
    if wb_rst_i = '1' then
137
      iwr <= '0';
138
    elsif rising_edge(wb_clk_i) then
139
      if wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
140
        wb_we_i = '1' then
141
        case wb_cti_i is
142
          when "010" => -- incrementing burst
143
            case wb_bte_i is -- burst extension
144
              when "00" => -- linear burst
145
                iwr <= '1';
146
              when others => -- all other treated assert classic cycle
147
                iwr <= not iwr;
148
            end case;
149
          when "111" => -- end of burst
150
            iwr <= not iwr;
151
          when others => -- all other treated assert classic cycle   
152
            iwr <= not iwr;
153
        end case;
154
      else
155
        iwr <= '0';
156
      end if;
157
    end if;
158
  end process WR;
159
 
160
-- read generation
161
  ird <= '1' when wb_cyc_i = '1' and wb_sel_i = '1' and wb_stb_i = '1' and
162 31 gedra
         wb_we_i = '0' else '0';
163 29 gedra
 
164 31 gedra
  wb_dat_o <= data_out when wb_adr_i(ADDR_WIDTH - 1) = '1' else rdout;
165
 
166
  DREG: process (wb_clk_i)              -- clock data from registers
167
  begin
168
    if rising_edge(wb_clk_i) then
169
      rdout <= data_out;
170
    end if;
171
  end process DREG;
172
 
173 29 gedra
-- sample memory read address. This needs special attention due to read latency
174 37 gedra
  mem_addr <= std_logic_vector(to_unsigned(acnt, ADDR_WIDTH - 1)) when
175 29 gedra
              wb_cti_i = "010" and wb_we_i = '0' and iack = '1' and
176
              wb_bte_i = "00" else wb_adr_i(ADDR_WIDTH - 2 downto 0);
177
 
178 31 gedra
  all_ones(ADDR_WIDTH - 1 downto 0) <= (others => '1');
179 29 gedra
 
180
  SMA: process (wb_clk_i, wb_rst_i)
181
  begin
182
    if wb_rst_i = '1' then
183
      acnt <= 0;
184
    elsif rising_edge(wb_clk_i) then
185
      if wb_cti_i = "010" and wb_we_i = '0' and wb_bte_i = "00" then
186
        if iack = '0' then
187
          if wb_adr_i = all_ones then
188
            acnt <= 0;
189
          else
190 37 gedra
            acnt <= to_integer(unsigned(wb_adr_i)) + 1;
191 29 gedra
          end if;
192
        else
193
          if acnt < 2**(ADDR_WIDTH - 1) - 1 then
194
            acnt <= acnt + 1;
195
          else
196
            acnt <= 0;
197
          end if;
198
        end if;
199
      end if;
200
    end if;
201
  end process SMA;
202
 
203
-- read and write strobe generation
204
 
205
  version_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXVERSION and ird = '1'
206
                else '0';
207
  config_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXCONFIG and ird = '1'
208
               else '0';
209
  config_wr <= '1' when wb_adr_i(6 downto 0) = REG_RXCONFIG and iwr = '1'
210
               else '0';
211
  status_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXSTATUS and ird = '1'
212
               else '0';
213
  intmask_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXINTMASK and ird = '1'
214
                else '0';
215
  intmask_wr <= '1' when wb_adr_i(6 downto 0) = REG_RXINTMASK and iwr = '1'
216
                else '0';
217
  intstat_rd <= '1' when wb_adr_i(6 downto 0) = REG_RXINTSTAT and ird = '1'
218
                else '0';
219
  intstat_wr <= '1' when wb_adr_i(6 downto 0) = REG_RXINTSTAT and iwr = '1'
220
                else '0';
221
  mem_rd <= '1' when wb_adr_i(ADDR_WIDTH - 1) = '1' and ird = '1' else '0';
222
 
223
-- capture register strobes
224
  CR32: if DATA_WIDTH = 32 generate
225
    CRST: for k in 0 to 7 generate
226
      ch_st_cap_rd(k) <= '1' when ird = '1' and wb_adr_i(6 downto 4) = "001"
227 37 gedra
                         and wb_adr_i(3 downto 0) = std_logic_vector(to_unsigned(2*k,4))
228 29 gedra
                         else '0';
229
      ch_st_cap_wr(k) <= '1' when iwr = '1' and wb_adr_i(6 downto 4) = "001"
230 37 gedra
                         and wb_adr_i(3 downto 0) = std_logic_vector(to_unsigned(2*k,4))
231 29 gedra
                         else '0';
232
      ch_st_data_rd(k) <= '1' when ird = '1' and wb_adr_i(6 downto 4) = "001"
233 37 gedra
                          and wb_adr_i(3 downto 0) = std_logic_vector(to_unsigned(2*k+1,4))
234 29 gedra
                          else '0';
235
    end generate CRST;
236
  end generate CR32;
237
  CR16: if DATA_WIDTH = 16 generate
238
    ch_st_cap_rd(7 downto 0) <= (others => '0');
239
    ch_st_cap_wr(7 downto 0) <= (others => '0');
240
    ch_st_data_rd(7 downto 0) <= (others => '0');
241
  end generate CR16;
242
 
243
end rtl;

powered by: WebSVN 2.1.0

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