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