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

Subversion Repositories spdif_interface

[/] [spdif_interface/] [trunk/] [rtl/] [vhdl/] [rx_phase_det.vhd] - Diff between revs 11 and 20

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 11 Rev 20
Line 44... Line 44...
----------------------------------------------------------------------
----------------------------------------------------------------------
--
--
-- CVS Revision History
-- CVS Revision History
--
--
-- $Log: not supported by cvs2svn $
-- $Log: not supported by cvs2svn $
 
-- Revision 1.1  2004/06/06 15:43:02  gedra
 
-- Early version of the bi-phase mark decoder.
 
--
--
--
 
 
LIBRARY ieee;
library ieee;
USE ieee.std_logic_1164.ALL;
use ieee.std_logic_1164.all;
 
 
entity rx_phase_det is
entity rx_phase_det is
  generic (WISH_BONE_FREQ: natural := 33);   -- WishBone frequency in MHz
  generic (WISHBONE_FREQ: natural := 33);   -- WishBone frequency in MHz
  port (
  port (
    wb_clk_i: in std_logic;
    wb_clk_i: in std_logic;             -- wishbone clock
    rxen: in std_logic;
    rxen: in std_logic;                 -- phase detector enable
    spdif: in std_logic;
    spdif: in std_logic;                -- SPDIF input signal
    lock: out std_logic;
    lock: out std_logic;                -- true if locked to spdif input
    rx_data: out std_logic;
    rx_data: out std_logic;             -- recevied data
    rx_data_en: out std_logic;
    rx_data_en: out std_logic;          -- received data enable
    rx_block_start: out std_logic;
    rx_block_start: out std_logic;      -- start-of-block pulse
    rx_frame_start: out std_logic;
    rx_frame_start: out std_logic;      -- start-of-frame pulse
    rx_channel_a: out std_logic;
    rx_channel_a: out std_logic;        -- 1 if channel A frame is recevied
    rx_error: out std_logic;
    rx_error: out std_logic;            -- signal error was detected
    ud_a_en: out std_logic;              -- user data ch. A enable
    ud_a_en: out std_logic;              -- user data ch. A enable
    ud_b_en: out std_logic;              -- user data ch. B enable
    ud_b_en: out std_logic;              -- user data ch. B enable
    cs_a_en: out std_logic;              -- channel status ch. A enable
    cs_a_en: out std_logic;              -- channel status ch. A enable
    cs_b_en: out std_logic);             -- channel status ch. B enable);            
    cs_b_en: out std_logic);             -- channel status ch. B enable);            
end rx_phase_det;
end rx_phase_det;
 
 
architecture rtl of rx_phase_det is
architecture rtl of rx_phase_det is
 
 
  constant TRANSITIONS : integer := 40;
  constant TRANSITIONS : integer := 40;
  constant FRAMES_FOR_LOCK : integer := 3;
  constant FRAMES_FOR_LOCK : integer := 3;
  signal maxpulse, maxp, mp_cnt: integer range 0 to 16 * WISH_BONE_FREQ;
  signal maxpulse, maxp, mp_cnt: integer range 0 to 16 * WISHBONE_FREQ;
  signal last_cnt, max_thres : integer range 0 to 16 * WISH_BONE_FREQ;
  signal last_cnt, max_thres : integer range 0 to 16 * WISHBONE_FREQ;
  signal minpulse, minp, min_thres: integer range 0 to 8 * WISH_BONE_FREQ;
  signal minpulse, minp, min_thres: integer range 0 to 8 * WISHBONE_FREQ;
  signal zspdif, spdif_in, zspdif_in, trans, ztrans : std_logic;
  signal zspdif, spdif_in, zspdif_in, trans, ztrans : std_logic;
  signal trans_cnt : integer range 0 to TRANSITIONS;
  signal trans_cnt : integer range 0 to TRANSITIONS;
  signal valid, p_long, p_short: std_logic;
  signal valid, p_long, p_short: std_logic;
  type pulse_type is (ZERO, SHORT, MED, LONG);
  type pulse_type is (ZERO, SHORT, MED, LONG);
  type pulse_array is array (0 to 3) of pulse_type;
  type pulse_array is array (0 to 3) of pulse_type;
Line 130... Line 133...
          if mp_cnt < minp then
          if mp_cnt < minp then
            minp <= mp_cnt;
            minp <= mp_cnt;
          end if;
          end if;
        else
        else
          trans <= '0';
          trans <= '0';
          if mp_cnt < 16 * WISH_BONE_FREQ then
          if mp_cnt < 16 * WISHBONE_FREQ then
            mp_cnt <= mp_cnt + 1;
            mp_cnt <= mp_cnt + 1;
          end if;
          end if;
        end if;
        end if;
        -- transition counting
        -- transition counting
        if trans = '1' then
        if trans = '1' then
Line 144... Line 147...
            -- the max/min pulse length is updated after given # of transitions
            -- the max/min pulse length is updated after given # of transitions
            trans_cnt <= 0;
            trans_cnt <= 0;
            maxpulse <= maxp;
            maxpulse <= maxp;
            maxp <= 0;
            maxp <= 0;
            minpulse <= minp;
            minpulse <= minp;
            minp <= 8 * WISH_BONE_FREQ;
            minp <= 8 * WISHBONE_FREQ;
            min_thres <= maxp / 2;
            min_thres <= maxp / 2;
            if maxp < 11 then
            if maxp < 11 then
              max_thres <= maxp - 1;
              max_thres <= maxp - 1;
            else
            else
              max_thres <= maxp - 3;
              max_thres <= maxp - 3;

powered by: WebSVN 2.1.0

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