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

Subversion Repositories spdif_interface

[/] [spdif_interface/] [trunk/] [rtl/] [vhdl/] [gen_event_reg.vhd] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 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
---- Generic event 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.3  2004/06/06 15:42:20  gedra
49
-- Cleaned up lint warnings.
50
--
51 13 gedra
-- Revision 1.2  2004/06/04 15:55:07  gedra
52
-- Cleaned up lint warnings.
53
--
54 8 gedra
-- Revision 1.1  2004/06/03 17:49:26  gedra
55
-- Generic event register. Used in both receiver and transmitter.
56 6 gedra
--
57 8 gedra
--
58 6 gedra
 
59
library IEEE;
60
use IEEE.std_logic_1164.all;
61
 
62
entity gen_event_reg is
63 8 gedra
  generic (DATA_WIDTH: integer:=32);
64 6 gedra
  port (
65
    clk: in std_logic;   -- clock  
66
    rst: in std_logic; -- reset
67
    evt_wr: in std_logic; -- event register write       
68
    evt_rd: in std_logic; -- event register read
69 8 gedra
    evt_din: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- write data
70
    event: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- event vector
71
    evt_mask: in std_logic_vector(DATA_WIDTH - 1 downto 0); -- irq mask
72 6 gedra
    evt_en: in std_logic;               -- irq enable
73 8 gedra
    evt_dout: out std_logic_vector(DATA_WIDTH - 1 downto 0); -- read data
74 6 gedra
    evt_irq: out std_logic); -- interrupt  request
75
end gen_event_reg;
76
 
77
architecture rtl of gen_event_reg is
78
 
79 8 gedra
  signal evt_internal, zero: std_logic_vector(DATA_WIDTH - 1 downto 0);
80 39 gedra
  signal zevent: std_logic_vector(DATA_WIDTH - 1 downto 0);
81 6 gedra
 
82
begin
83 13 gedra
 
84 6 gedra
  evt_dout <= evt_internal when evt_rd = '1' else (others => '0');
85
  zero <= (others => '0');
86
 
87
-- IRQ generation:
88 8 gedra
-- IRQ signal will pulse low when writing to the event register. This will
89
-- capture situations when not all active events are cleared or an event happens
90
-- at the same time as it is cleared.
91 6 gedra
  IR: process (clk)
92
  begin
93
    if rising_edge(clk) then
94 13 gedra
      if ((evt_internal and evt_mask) /= zero) and evt_wr = '0'
95
        and evt_en = '1' then
96 6 gedra
        evt_irq <= '1';
97
      else
98
        evt_irq <= '0';
99
      end if;
100
    end if;
101
  end process IR;
102
 
103
-- event register generation   
104
  EVTREG: for k in evt_din'range generate
105
    EBIT: process (clk, rst)
106
    begin
107
      if rst = '1' then
108
        evt_internal(k) <= '0';
109 39 gedra
        zevent(k) <= event(k);
110 6 gedra
      else
111
        if rising_edge(clk) then
112 39 gedra
          zevent(k) <= event(k);
113
          if event(k) /= zevent(k) then    -- set event
114 6 gedra
            evt_internal(k) <= '1';
115
          elsif evt_wr = '1' and evt_din(k) = '1' then -- clear event
116
            evt_internal(k) <= '0';
117
          end if;
118
        end if;
119
      end if;
120
    end process EBIT;
121 8 gedra
  end generate EVTREG;
122 6 gedra
 
123
end rtl;

powered by: WebSVN 2.1.0

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