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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_clk_detect.vhd] - Diff between revs 173 and 191

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

Rev 173 Rev 191
Line 24... Line 24...
-- VHDL Units :  o8_clk_detect
-- VHDL Units :  o8_clk_detect
-- Description:  Provides up/down status and interrupt for monitoring a clock
-- Description:  Provides up/down status and interrupt for monitoring a clock
--
--
-- Register Map:
-- Register Map:
-- Offset  Bitfield Description                          Read/Write
-- Offset  Bitfield Description                          Read/Write
--   0x00   BB-----A VSD Engine PLL Reset                (RO/RW)
--   0x00   BA------ VSD Engine PLL Reset                (RO/RW)
--                    A = Interrupt Enable (1 = enabled, 0 = masked) (RW)
--                    A = Clock Line State (follows input) (RO)
--                    B = Clock Line State (follows input, only valid if B = 1) (RO)
--                    B = Clock Detect (1 = transition detected) (RO)
--                    C = Clock Detect (1 = transition detected) (RO)
 
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
Line 51... Line 50...
  Reset                 : in  std_logic;
  Reset                 : in  std_logic;
  --
  --
  Ref_Clk_In            : in  std_logic;
  Ref_Clk_In            : in  std_logic;
  --
  --
  Bus_Address           : in  ADDRESS_TYPE;
  Bus_Address           : in  ADDRESS_TYPE;
  Wr_Enable             : in  std_logic;
 
  Wr_Data               : in  DATA_TYPE;
 
  Rd_Enable             : in  std_logic;
  Rd_Enable             : in  std_logic;
  Rd_Data               : out DATA_TYPE;
  Rd_Data               : out DATA_TYPE;
  Interrupt             : out std_logic
  Interrupt             : out std_logic
);
);
end entity;
end entity;
 
 
architecture behave of o8_clk_detect is
architecture behave of o8_clk_detect is
 
 
  constant User_Addr    : std_logic_vector(15 downto 0) := Address;
  constant User_Addr    : std_logic_vector(15 downto 0) := Address;
  alias  Comp_Addr      is Bus_Address(15 downto 0);
  alias  Comp_Addr      is Bus_Address(15 downto 0);
  signal Addr_Match     : std_logic;
  signal Addr_Match          : std_logic := '0';
 
 
  signal Wr_Data_Q      : DATA_TYPE;
  signal Rd_En               : std_logic := '0';
  signal Wr_En          : std_logic;
 
  signal Rd_En          : std_logic;
 
 
 
  signal Int_En         : std_logic;
 
 
 
  function ceil_log2 (x : in natural) return natural is
 
    variable retval          : natural;
 
  begin
 
    retval                   := 1;
 
    while ((2**retval) - 1) < x loop
 
      retval                 := retval + 1;
 
    end loop;
 
    return retval;
 
  end function;
 
 
 
  constant Threshold_bits    : integer := ceil_log2(Threshold_Count);
  constant Threshold_bits    : integer := ceil_log2(Threshold_Count);
  constant THRESHOLD         : std_logic_vector(Threshold_bits - 1 downto 0) :=
  constant THRESHOLD         : std_logic_vector(Threshold_bits - 1 downto 0) :=
                        conv_std_logic_vector(Threshold_Count,Threshold_bits);
                        conv_std_logic_vector(Threshold_Count,Threshold_bits);
 
 
  signal RE_Threshold_Ctr    : std_logic_vector(Threshold_Bits - 1 downto 0);
  signal RE_Threshold_Ctr    : std_logic_vector(Threshold_Bits - 1 downto 0) :=
  signal FE_Threshold_Ctr    : std_logic_vector(Threshold_Bits - 1 downto 0);
                                (others => '0');
 
  signal FE_Threshold_Ctr    : std_logic_vector(Threshold_Bits - 1 downto 0) :=
 
                                (others => '0');
 
 
  signal Ref_In_SR           : std_logic_vector(3 downto 0);
  signal Ref_In_SR           : std_logic_vector(3 downto 0) := (others => '0');
  alias  Ref_In_q1           is Ref_In_SR(2);
  alias  Ref_In_q1           is Ref_In_SR(2);
  alias  Ref_In_q2           is Ref_In_SR(3);
  alias  Ref_In_q2           is Ref_In_SR(3);
  signal Ref_In_RE           : std_logic;
  signal Ref_In_RE           : std_logic := '0';
  signal Ref_In_FE           : std_logic;
  signal Ref_In_FE           : std_logic := '0';
 
 
  signal Ref_Detect          : std_logic;
  signal Ref_Detect          : std_logic := '0';
  signal Ref_Detect_q1       : std_logic;
  signal Ref_Detect_q1       : std_logic := '0';
  signal Ref_Detect_CoS      : std_logic;
  signal Ref_Detect_CoS      : std_logic := '0';
 
 
begin
begin
 
 
  Addr_Match            <= '1' when Comp_Addr = User_Addr else '0';
  Addr_Match            <= Rd_Enable when Comp_Addr = User_Addr else '0';
 
 
  io_reg: process( Clock, Reset )
  io_reg: process( Clock, Reset )
  begin
  begin
    if( Reset = Reset_Level )then
    if( Reset = Reset_Level )then
      Wr_Data_Q         <= x"00";
 
      Wr_En             <= '0';
 
      Rd_En             <= '0';
      Rd_En             <= '0';
      Rd_Data           <= x"00";
      Rd_Data           <= OPEN8_NULLBUS;
      Int_En            <= '0';
 
    elsif( rising_edge( Clock ) )then
    elsif( rising_edge( Clock ) )then
      Wr_Data_Q         <= Wr_Data;
      Rd_En             <= Addr_Match;
      Wr_En             <= Wr_Enable and Addr_Match;
 
      Rd_En             <= Rd_Enable and Addr_Match;
 
 
 
    if( Wr_En = '1' )then
 
      Int_En          <= Wr_Data_Q(0);
 
    end if;
 
 
 
      Rd_Data           <= (others => '0');
      Rd_Data           <= OPEN8_NULLBUS;
      if( Rd_En = '1' )then
      if( Rd_En = '1' )then
        Rd_Data(0)      <= Int_En;
 
        Rd_Data(6)      <= Ref_In_q2;
        Rd_Data(6)      <= Ref_In_q2;
        Rd_Data(7)      <= Ref_Detect;
        Rd_Data(7)      <= Ref_Detect;
      end if;
      end if;
 
 
    end if;
    end if;
Line 164... Line 139...
      Ref_Detect             <= or_reduce(RE_Threshold_Ctr) and
      Ref_Detect             <= or_reduce(RE_Threshold_Ctr) and
                                or_reduce(FE_Threshold_Ctr);
                                or_reduce(FE_Threshold_Ctr);
      Ref_Detect_q1          <= Ref_Detect;
      Ref_Detect_q1          <= Ref_Detect;
      Ref_Detect_CoS         <= Ref_Detect xor Ref_Detect_q1;
      Ref_Detect_CoS         <= Ref_Detect xor Ref_Detect_q1;
 
 
      Interrupt              <= Ref_Detect_CoS and Int_En;
      Interrupt              <= Ref_Detect_CoS;
    end if;
    end if;
  end process;
  end process;
 
 
end architecture;
end architecture;
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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