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

Subversion Repositories spdif_interface

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

powered by: WebSVN 2.1.0

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