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

Subversion Repositories spdif_interface

[/] [spdif_interface/] [trunk/] [rtl/] [vhdl/] [rx_status_reg.vhd] - Blame information for rev 73

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 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 status register                               ----
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.5  2004/07/11 16:19:50  gedra
49
-- Bug-fix.
50
--
51 39 gedra
-- Revision 1.4  2004/06/27 16:16:55  gedra
52
-- Signal renaming and bug fix.
53
--
54 38 gedra
-- Revision 1.3  2004/06/26 14:14:47  gedra
55
-- Converted to numeric_std and fixed a few bugs.
56
--
57 37 gedra
-- Revision 1.2  2004/06/16 19:03:10  gedra
58
-- Added channel status decoding.
59
--
60 24 gedra
-- Revision 1.1  2004/06/05 17:17:12  gedra
61
-- Recevier status register
62 10 gedra
--
63 24 gedra
--
64 10 gedra
 
65 37 gedra
library ieee;
66 72 gedra
use ieee.std_logic_1164.all;
67 10 gedra
 
68 72 gedra
entity rx_status_reg is
69
   generic (DATA_WIDTH : integer);
70
   port (
71
      wb_clk_i       : in  std_logic;   -- clock
72
      status_rd      : in  std_logic;   -- status register read
73
      lock           : in  std_logic;   -- signal lock status
74
      chas           : in  std_logic;   -- channel A or B select
75
      rx_block_start : in  std_logic;   -- start of block signal
76
      ch_data        : in  std_logic;   -- channel status/user data
77
      cs_a_en        : in  std_logic;   -- channel status ch. A enable
78
      cs_b_en        : in  std_logic;   -- channel status ch. B enable
79
      status_dout    : out std_logic_vector(DATA_WIDTH - 1 downto 0));
80 10 gedra
end rx_status_reg;
81
 
82
architecture rtl of rx_status_reg is
83
 
84 72 gedra
   signal status_vector : std_logic_vector(DATA_WIDTH - 1 downto 0);
85
   signal cur_pos       : integer range 0 to 255;
86
   signal pro_mode      : std_logic;
87
 
88 10 gedra
begin
89 72 gedra
 
90
   status_dout <= status_vector when status_rd = '1' else (others => '0');
91 24 gedra
 
92 72 gedra
   D32 : if DATA_WIDTH = 32 generate
93
      status_vector(31 downto 16) <= (others => '0');
94
   end generate D32;
95 24 gedra
 
96 72 gedra
   status_vector(0)           <= lock;
97
   status_vector(15 downto 7) <= (others => '0');
98
 
99 24 gedra
-- extract channel status bits to be used
100 72 gedra
   CDAT : process (wb_clk_i, lock)
101
   begin
102 39 gedra
      if lock = '0' then
103 72 gedra
         cur_pos                   <= 0;
104
         pro_mode                  <= '0';
105
         status_vector(6 downto 1) <= (others => '0');
106 24 gedra
      else
107 72 gedra
         if rising_edge(wb_clk_i) then
108
            -- bit counter, 0 to 191
109
            if rx_block_start = '1' then
110
               cur_pos <= 0;
111
            elsif cs_b_en = '1' then    -- ch. status #2 comes last, count then
112
               cur_pos <= cur_pos + 1;
113
            end if;
114
            -- extract status bits used in status register
115
            if (chas = '0' and cs_b_en = '1') or
116
               (chas = '1' and cs_a_en = '1') then
117
               case cur_pos is
118
                  when 0 =>             -- PRO bit
119
                     status_vector(1) <= ch_data;
120
                     pro_mode         <= ch_data;
121
                  when 1 =>             -- AUDIO bit
122
                     status_vector(2) <= not ch_data;
123
                  when 2 =>             -- emphasis/copy bit
124
                     if pro_mode = '1' then
125
                        status_vector(5) <= ch_data;
126
                     else
127
                        status_vector(6) <= ch_data;
128
                     end if;
129
                  when 3 =>             -- emphasis
130
                     if pro_mode = '1' then
131
                        status_vector(4) <= ch_data;
132
                     else
133
                        status_vector(5) <= ch_data;
134
                     end if;
135
                  when 4 =>             -- emphasis
136
                     if pro_mode = '1' then
137
                        status_vector(3) <= ch_data;
138
                     else
139
                        status_vector(4) <= ch_data;
140
                     end if;
141
                  when 5 =>             -- emphasis
142
                     if pro_mode = '0' then
143
                        status_vector(3) <= ch_data;
144
                     end if;
145
                  when others =>
146
                     null;
147
               end case;
148
            end if;
149
         end if;
150 24 gedra
      end if;
151 72 gedra
   end process CDAT;
152
 
153 10 gedra
end rtl;

powered by: WebSVN 2.1.0

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