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 73

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

powered by: WebSVN 2.1.0

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