1 |
2 |
rehayes |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Computer Operating Properly - XGATE interrupt encoder
|
4 |
|
|
//
|
5 |
|
|
// Author: Bob Hayes
|
6 |
|
|
// rehayes@opencores.org
|
7 |
|
|
//
|
8 |
|
|
// Downloaded from: http://www.opencores.org/projects/xgate.....
|
9 |
|
|
//
|
10 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
11 |
|
|
// Copyright (c) 2009, Robert Hayes
|
12 |
|
|
//
|
13 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
14 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
15 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
16 |
|
|
// (at your option) any later version.
|
17 |
|
|
//
|
18 |
|
|
// Supplemental terms.
|
19 |
|
|
// * Redistributions of source code must retain the above copyright
|
20 |
|
|
// notice, this list of conditions and the following disclaimer.
|
21 |
|
|
// * Neither the name of the <organization> nor the
|
22 |
|
|
// names of its contributors may be used to endorse or promote products
|
23 |
|
|
// derived from this software without specific prior written permission.
|
24 |
|
|
//
|
25 |
|
|
// THIS SOFTWARE IS PROVIDED BY Robert Hayes ''AS IS'' AND ANY
|
26 |
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
27 |
|
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
28 |
|
|
// DISCLAIMED. IN NO EVENT SHALL Robert Hayes BE LIABLE FOR ANY
|
29 |
|
|
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
30 |
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
31 |
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
32 |
|
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
33 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
34 |
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 |
|
|
//
|
36 |
|
|
// You should have received a copy of the GNU General Public License
|
37 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
38 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
module xgate_irq_encode #(parameter MAX_CHANNEL = 127) // Max XGATE Interrupt Channel Number
|
43 |
|
|
(
|
44 |
|
|
output reg [ 6:0] int_req, // Encoded interrupt request
|
45 |
|
|
|
46 |
|
|
input [MAX_CHANNEL:0] chan_req_i // XGATE Interrupt request
|
47 |
|
|
);
|
48 |
|
|
|
49 |
28 |
rehayes |
// Set int_reg to the index of the index of the highest chen_req_i input that is active
|
50 |
2 |
rehayes |
integer i = 0;
|
51 |
|
|
always @(chan_req_i)
|
52 |
|
|
begin
|
53 |
|
|
int_req = 0;
|
54 |
|
|
for (i = 0; i <= MAX_CHANNEL; i = i + 1)
|
55 |
|
|
if (chan_req_i[i] == 1'b1)
|
56 |
|
|
int_req = i;
|
57 |
|
|
end
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
endmodule // xgate_irq_encode
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|