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 |
67 |
rehayes |
output reg [ 6:0] int_req, // Encoded interrupt request to RISC
|
45 |
72 |
rehayes |
output [MAX_CHANNEL:1] xgif, // Interrupt outputs to Host
|
46 |
2 |
rehayes |
|
47 |
72 |
rehayes |
input [MAX_CHANNEL:1] chan_req_i, // XGATE Interrupt requests from peropherials
|
48 |
|
|
input [MAX_CHANNEL:1] chan_bypass, // XGATE Interrupt bypass
|
49 |
|
|
input [MAX_CHANNEL:1] xgif_status // Interrupt outputs from RISC core
|
50 |
2 |
rehayes |
);
|
51 |
|
|
|
52 |
72 |
rehayes |
wire [MAX_CHANNEL:1] chan_ena_gate; // Ouptut of channel enable gating
|
53 |
67 |
rehayes |
|
54 |
|
|
// Pass non-bypassed interrupt inputs to XGATE RISC
|
55 |
|
|
assign chan_ena_gate = ~chan_bypass & chan_req_i;
|
56 |
|
|
|
57 |
|
|
// Set int_reg to the index of the index of the lowest chan_req_i input that is active
|
58 |
2 |
rehayes |
integer i = 0;
|
59 |
67 |
rehayes |
always @(chan_ena_gate)
|
60 |
2 |
rehayes |
begin
|
61 |
|
|
int_req = 0;
|
62 |
72 |
rehayes |
for (i = MAX_CHANNEL; i >= 1; i = i - 1)
|
63 |
67 |
rehayes |
if (chan_ena_gate[i] == 1'b1)
|
64 |
2 |
rehayes |
int_req = i;
|
65 |
|
|
end
|
66 |
|
|
|
67 |
67 |
rehayes |
// XGATE output interrupt mux
|
68 |
|
|
assign xgif = (chan_bypass & chan_req_i) | (~chan_bypass & xgif_status);
|
69 |
2 |
rehayes |
|
70 |
67 |
rehayes |
|
71 |
2 |
rehayes |
endmodule // xgate_irq_encode
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|