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

Subversion Repositories tinyvliw8

[/] [tinyvliw8/] [trunk/] [src/] [vhdl/] [proc/] [irqCntl.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 9 steckol
 
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 2 steckol
 
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 9 steckol
        signal irqAddr_s    : std_logic_vector(1 downto 0);
33 2 steckol
 
34 9 steckol
        signal irqLineOut_s : std_logic_vector(3 downto 0);
35 2 steckol
        signal irqLineIn_s  : std_logic_vector(3 downto 0);
36 9 steckol
 
37 2 steckol
        signal irqLine_s    : std_logic;
38
        signal irqUpd_s     : std_logic;
39
 
40 9 steckol
        signal irqCtrl_r    : std_logic_vector(7 downto 0);
41
 
42 2 steckol
begin
43
 
44 9 steckol
        ------------------------------------------------------------------------------------------
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 2 steckol
        update_irqCtrlReg: process(rst_n, ioInWr_n)
102
        begin
103 9 steckol
                if (rst_n = '0') then
104 2 steckol
                        irqCtrl_r <= (others => '0');
105 9 steckol
                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 2 steckol
        end process;
113
 
114 9 steckol
        ------------------------------------------------------------------------------------------
115
        --
116
        --   IRQ address generation
117
        --
118
        ------------------------------------------------------------------------------------------
119
 
120 2 steckol
        irqAddr <= irqAddr_s;
121 9 steckol
 
122 2 steckol
        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 9 steckol
                        if (irqUpd_s'event and irqUpd_s = '0') then
131 2 steckol
                                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 9 steckol
        irqUpd_s <= state(3) when enable = '1' and stalled_n = '1' else
158
                    '0'      when enable = '1' and irqLine_s = '1' else
159
                    '1';
160 2 steckol
 
161
        irqAck <= irq_s;
162
 
163
end behavior;

powered by: WebSVN 2.1.0

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