blob: 1713d3901c94aa4793a0600e3d81eee1bbbad06e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity ent is
generic (NUM_CHANNELS : natural := 4);
port (
iar : in unsigned(15 downto 0);
ipend : in unsigned(NUM_CHANNELS-1 downto 0);
irq : out unsigned(3 downto 0);
clk : in std_logic
);
end;
architecture a of ent is
type irq_t is
array (integer range 0 to 4-1) of unsigned(NUM_CHANNELS-1 downto 0);
signal imap : irq_t;
function or_reduce (v: in unsigned) return std_logic is
variable rv : std_logic := '0';
begin
for i in v'range loop
rv := rv or v(i);
end loop;
return rv;
end function;
begin
gen_irqmap:
for i in 0 to 4-1 generate
irq(i) <= or_reduce(imap(i));
end generate;
irq_map:
process (clk)
variable itmp : irq_t := (others => (others => '0'));
begin
-- IRQ channel assignment:
if rising_edge(clk) then
for i in 0 to NUM_CHANNELS-1 loop
itmp(to_integer(iar(i*2+1 downto i*2)))(i) := ipend(i);
end loop;
imap <= itmp;
end if;
end process;
end;
|