1 |
2 |
steckol |
library ieee;
|
2 |
|
|
use ieee.std_logic_1164.all;
|
3 |
|
|
use ieee.std_logic_arith.all;
|
4 |
|
|
|
5 |
|
|
entity vliwProc_irqCntl is
|
6 |
|
|
port (
|
7 |
|
|
state : in std_logic_vector(3 downto 0);
|
8 |
|
|
stalled_n : in std_logic;
|
9 |
|
|
|
10 |
|
|
irqLineIn : in std_logic_vector(5 downto 0);
|
11 |
|
|
irqLineOut : out std_logic_vector(5 downto 0);
|
12 |
|
|
irqAck : out std_logic;
|
13 |
|
|
|
14 |
|
|
irqAddr : out std_logic_vector(1 downto 0);
|
15 |
|
|
|
16 |
|
|
ioDataIn : in std_logic_vector(7 downto 0);
|
17 |
|
|
ioDataOut : out std_logic_vector(7 downto 0);
|
18 |
|
|
ioInEn_n : in std_logic;
|
19 |
|
|
ioInWr_n : in std_logic;
|
20 |
|
|
|
21 |
|
|
enable : in std_logic;
|
22 |
|
|
|
23 |
|
|
-- reset input
|
24 |
|
|
rst_n : in std_logic
|
25 |
|
|
);
|
26 |
|
|
end vliwProc_irqCntl;
|
27 |
|
|
|
28 |
|
|
architecture behavior of vliwProc_irqCntl is
|
29 |
|
|
|
30 |
|
|
signal irq_s : std_logic;
|
31 |
|
|
signal irqAck_s : std_logic;
|
32 |
|
|
signal irqAddr_s : std_logic_vector(1 downto 0);
|
33 |
|
|
|
34 |
|
|
signal irqLineOut_s : std_logic_vector(3 downto 0);
|
35 |
|
|
signal irqLineIn_s : std_logic_vector(3 downto 0);
|
36 |
|
|
|
37 |
|
|
signal irqLine_s : std_logic;
|
38 |
|
|
signal irqUpd_s : std_logic;
|
39 |
|
|
|
40 |
|
|
signal irqCtrl_r : std_logic_vector(7 downto 0);
|
41 |
|
|
|
42 |
|
|
begin
|
43 |
|
|
|
44 |
|
|
------------------------------------------------------------------------------------------
|
45 |
|
|
--
|
46 |
|
|
-- IRQ line multiplexer
|
47 |
|
|
--
|
48 |
|
|
------------------------------------------------------------------------------------------
|
49 |
|
|
|
50 |
|
|
irqLineIn_s(0) <= '1' when rst_n = '1' and ((irqCtrl_r(1 downto 0) = "01" and irqLineIn(0) = '1') or
|
51 |
|
|
(irqCtrl_r(1 downto 0) = "10" and irqLineIn(2) = '1') or
|
52 |
|
|
(irqCtrl_r(1 downto 0) = "11" and irqLineIn(5) = '1')) else
|
53 |
|
|
'0';
|
54 |
|
|
irqLineIn_s(1) <= '1' when rst_n = '1' and ((irqCtrl_r(3 downto 2) = "01" and irqLineIn(4) = '1') or
|
55 |
|
|
(irqCtrl_r(3 downto 2) = "10" and irqLineIn(0) = '1') or
|
56 |
|
|
(irqCtrl_r(3 downto 2) = "11" and irqLineIn(3) = '1')) else
|
57 |
|
|
'0';
|
58 |
|
|
irqLineIn_s(2) <= '1' when rst_n = '1' and ((irqCtrl_r(5 downto 4) = "01" and irqLineIn(1) = '1') or
|
59 |
|
|
(irqCtrl_r(5 downto 4) = "10" and irqLineIn(4) = '1') or
|
60 |
|
|
(irqCtrl_r(5 downto 4) = "11" and irqLineIn(5) = '1')) else
|
61 |
|
|
'0';
|
62 |
|
|
irqLineIn_s(3) <= '1' when rst_n = '1' and ((irqCtrl_r(7 downto 6) = "01" and irqLineIn(1) = '1') or
|
63 |
|
|
(irqCtrl_r(7 downto 6) = "10" and irqLineIn(2) = '1') or
|
64 |
|
|
(irqCtrl_r(7 downto 6) = "11" and irqLineIn(3) = '1')) else
|
65 |
|
|
'0';
|
66 |
|
|
|
67 |
|
|
irqLineOut(0) <= '1' when rst_n = '1' and enable = '1' and irq_s = '1' and
|
68 |
|
|
((irqCtrl_r(1 downto 0) = "01" and irqLineOut_s(0) = '1') or
|
69 |
|
|
(irqCtrl_r(3 downto 2) = "10" and irqLineOut_s(1) = '1')) else
|
70 |
|
|
'0';
|
71 |
|
|
irqLineOut(1) <= '1' when rst_n = '1' and enable = '1' and irq_s = '1' and
|
72 |
|
|
((irqCtrl_r(5 downto 4) = "01" and irqLineOut_s(2) = '1') or
|
73 |
|
|
(irqCtrl_r(7 downto 6) = "01" and irqLineOut_s(3) = '1')) else
|
74 |
|
|
'0';
|
75 |
|
|
irqLineOut(2) <= '1' when rst_n = '1' and enable = '1' and irq_s = '1' and
|
76 |
|
|
((irqCtrl_r(1 downto 0) = "10" and irqLineOut_s(0) = '1') or
|
77 |
|
|
(irqCtrl_r(7 downto 6) = "10" and irqLineOut_s(3) = '1')) else
|
78 |
|
|
'0';
|
79 |
|
|
irqLineOut(3) <= '1' when rst_n = '1' and enable = '1' and irq_s = '1' and
|
80 |
|
|
((irqCtrl_r(3 downto 2) = "11" and irqLineOut_s(1) = '1') or
|
81 |
|
|
(irqCtrl_r(7 downto 6) = "11" and irqLineOut_s(3) = '1')) else
|
82 |
|
|
'0';
|
83 |
|
|
irqLineOut(4) <= '1' when rst_n = '1' and enable = '1' and irq_s = '1' and
|
84 |
|
|
((irqCtrl_r(3 downto 2) = "01" and irqLineOut_s(1) = '1') or
|
85 |
|
|
(irqCtrl_r(5 downto 4) = "10" and irqLineOut_s(2) = '1')) else
|
86 |
|
|
'0';
|
87 |
|
|
irqLineOut(5) <= '1' when rst_n = '1' and enable = '1' and irq_s = '1' and
|
88 |
|
|
((irqCtrl_r(1 downto 0) = "11" and irqLineOut_s(0) = '1') or
|
89 |
|
|
(irqCtrl_r(5 downto 4) = "11" and irqLineOut_s(2) = '1')) else
|
90 |
|
|
'0';
|
91 |
|
|
|
92 |
|
|
------------------------------------------------------------------------------------------
|
93 |
|
|
--
|
94 |
|
|
-- Control register
|
95 |
|
|
--
|
96 |
|
|
------------------------------------------------------------------------------------------
|
97 |
|
|
|
98 |
|
|
ioDataOut <= irqCtrl_r when rst_n = '1' and ioInEn_n = '0' else
|
99 |
|
|
(others => '0');
|
100 |
|
|
|
101 |
|
|
update_irqCtrlReg: process(rst_n, ioInWr_n)
|
102 |
|
|
begin
|
103 |
|
|
if (rst_n = '0') then
|
104 |
|
|
irqCtrl_r <= (others => '0');
|
105 |
|
|
else
|
106 |
|
|
if (ioInWr_n'event and ioInWr_n = '0') then
|
107 |
|
|
if (ioInEn_n = '0') then
|
108 |
|
|
irqCtrl_r <= ioDataIn;
|
109 |
|
|
end if;
|
110 |
|
|
end if;
|
111 |
|
|
end if;
|
112 |
|
|
end process;
|
113 |
|
|
|
114 |
|
|
------------------------------------------------------------------------------------------
|
115 |
|
|
--
|
116 |
|
|
-- IRQ address generation
|
117 |
|
|
--
|
118 |
|
|
------------------------------------------------------------------------------------------
|
119 |
|
|
|
120 |
|
|
irqAddr <= irqAddr_s;
|
121 |
|
|
|
122 |
|
|
irq_proc : process(rst_n, irqUpd_s)
|
123 |
|
|
begin
|
124 |
|
|
if (rst_n = '0') then
|
125 |
|
|
irq_s <= '0';
|
126 |
|
|
|
127 |
|
|
irqAddr_s <= (others => '0');
|
128 |
|
|
irqLineOut_s <= (others => '0');
|
129 |
|
|
else
|
130 |
|
|
if (irqUpd_s'event and irqUpd_s = '1') then
|
131 |
|
|
if (irqLine_s = '1') then
|
132 |
|
|
irq_s <= '1';
|
133 |
|
|
|
134 |
|
|
if (irqLineIn_s(3) = '1') then
|
135 |
|
|
irqAddr_s <= "11";
|
136 |
|
|
irqLineOut_s <= "1000";
|
137 |
|
|
elsif (irqLineIn_s(2) = '1') then
|
138 |
|
|
irqAddr_s <= "10";
|
139 |
|
|
irqLineOut_s <= "0100";
|
140 |
|
|
elsif (irqLineIn_s(1) = '1') then
|
141 |
|
|
irqAddr_s <= "01";
|
142 |
|
|
irqLineOut_s <= "0010";
|
143 |
|
|
else
|
144 |
|
|
irqAddr_s <= "00";
|
145 |
|
|
irqLineOut_s <= "0001";
|
146 |
|
|
end if;
|
147 |
|
|
else
|
148 |
|
|
irq_s <= '0';
|
149 |
|
|
irqLineOut_s <= (others => '0');
|
150 |
|
|
end if;
|
151 |
|
|
end if;
|
152 |
|
|
end if;
|
153 |
|
|
end process;
|
154 |
|
|
|
155 |
|
|
irqLine_s <= irqLineIn_s(0) or irqLineIn_s(1) or irqLineIn_s(2) or irqLineIn_s(3);
|
156 |
|
|
|
157 |
|
|
irqUpd_s <= state(2) when enable = '1' and stalled_n = '1' else
|
158 |
|
|
'1' when enable = '1' and irqLine_s = '1' else
|
159 |
|
|
'0';
|
160 |
|
|
|
161 |
|
|
irqAck <= irq_s;
|
162 |
|
|
|
163 |
|
|
end behavior;
|