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 70

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

powered by: WebSVN 2.1.0

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