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

Subversion Repositories spi_slave

[/] [spi_slave/] [trunk/] [pcore/] [opb_spi_slave_v1_00_a/] [hdl/] [vhdl/] [irq_ctl.vhd] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dkoethe
-------------------------------------------------------------------------------
2
--* 
3
--* @short Control Unit for IRQ detection, enable and clear
4
--* 
5
--* @generic C_ACTIVE_EDGE  Select active edge for IRQ-Source 0: H->L;1: L->H
6
--*
7
--*    @author: Daniel Köthe
8
--*   @version: 1.0
9
--* @date:      2007-11-11
10
--/
11 18 dkoethe
-- Version 1.1
12
-- Bugfix
13
-- added syncronisation registers opb_fifo_flg_int_r[0,1] to prevent
14
-- metastability
15 2 dkoethe
-------------------------------------------------------------------------------
16
library ieee;
17
use ieee.std_logic_1164.all;
18
 
19
entity irq_ctl is
20
  generic (
21
    C_ACTIVE_EDGE : std_logic := '0');
22
  port (
23
    rst          : in  std_logic;
24
    clk          : in  std_logic;
25
    opb_fifo_flg : in  std_logic;
26
    opb_ier      : in  std_logic;
27
    opb_isr      : out std_logic;
28
    opb_isr_clr  : in  std_logic);
29
 
30
end irq_ctl;
31
 
32
architecture behavior of irq_ctl is
33
 
34
  signal opb_fifo_flg_int : std_logic;
35 18 dkoethe
  -- Sync to clock domain register
36
  signal opb_fifo_flg_int_r0 : std_logic;
37
  signal opb_fifo_flg_int_r1 : std_logic;
38
 
39
 
40 2 dkoethe
  signal opb_fifo_flg_reg : std_logic;
41
begin  -- behavior
42
 
43 18 dkoethe
  opb_fifo_flg_int_r0 <= opb_fifo_flg when (C_ACTIVE_EDGE = '1') else
44
                         not opb_fifo_flg;
45 2 dkoethe
 
46 18 dkoethe
  irq_ctl_proc : process(rst, clk)
47 2 dkoethe
  begin
48
    if (rst = '1') then
49
      opb_isr <= '0';
50
    elsif rising_edge(clk) then
51 18 dkoethe
      -- sync to clock domain
52
      opb_fifo_flg_int_r1 <= opb_fifo_flg_int_r0;
53
      opb_fifo_flg_int    <= opb_fifo_flg_int_r1;
54
 
55 2 dkoethe
      opb_fifo_flg_reg <= opb_fifo_flg_int;
56 18 dkoethe
      if (opb_ier = '1' and opb_fifo_flg_int = '1' and opb_fifo_flg_reg = '0') then
57 2 dkoethe
        opb_isr <= '1';
58
      elsif (opb_isr_clr = '1') then
59
        opb_isr <= '0';
60
      end if;
61
    end if;
62
  end process irq_ctl_proc;
63
 
64
 
65
end behavior;

powered by: WebSVN 2.1.0

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