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

Subversion Repositories fluid_core_2

[/] [fluid_core_2/] [trunk/] [rtl/] [interrupt_unit.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 azmathmoos
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2014-2015 Azmath Moosa                         ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 3 of the License, or (at your option) any     ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
`timescale 1ns / 1ps
28
`include "Configuration.v"
29
 
30
module interrupt_unit(
31
        input Clk,
32
        input [0:`intr_msb] intr_req,
33
        input [0:log2(`intr_msb)] intr_inx,
34
        input [0:`pc_w] new_vector,
35
        input write, return_back,
36
        output intr,
37
        output [0:`pc_w] vector
38
    );
39
 
40
        reg [0:`pc_w] isr_vectors [0:`intr_msb+1];
41
        reg [0:`intr_msb] masks;
42
        reg temp_unblock;
43
        reg [0:log2(`intr_msb)-1] vctr_inx;
44
 
45
        integer i;
46
        always@(*) begin
47
        for ( i = `intr_msb; (i >= 0); i = i - 1) begin
48
                if (intr_req[i] == 1) begin
49
                vctr_inx <= i;
50
                end
51
        end
52
        end
53
        initial begin
54
                temp_unblock <= 1;
55
        end
56
        assign intr = |(masks & intr_req ) & temp_unblock; //(~(vctr_inx == 0)&&(masks[vctr_inx]));
57
        assign vector = intr ? isr_vectors[vctr_inx]:'bz;
58
 
59
        always@(posedge Clk) begin
60
                if (write) begin//write
61
                        if (intr_inx == 0) masks <= new_vector; //(aligned by MSB)
62
                        else begin
63
                        isr_vectors[intr_inx] <= new_vector;
64
                        end
65
                end
66
                if (intr) temp_unblock <= 0;
67
                else if (return_back) temp_unblock <= 1;
68
        end
69
 
70
 
71
        //--- Constant Function ----//
72
        function integer log2;
73
          input integer value;
74
          begin
75
                 value = value-1;
76
                 for (log2=0; value>0; log2=log2+1)
77
                        value = value>>1;
78
          end
79
        endfunction
80
endmodule

powered by: WebSVN 2.1.0

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