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

Subversion Repositories pss

[/] [pss/] [trunk/] [pss/] [hdl/] [pss/] [zpu_uc/] [motherblock/] [pss_int_controller.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 AlexAntono
/*
2
 PSS
3
 
4
 Copyright (c) 2016 Alexander Antonov <153287@niuitmo.ru>
5
 All rights reserved.
6
 
7
 Version 0.99
8
 
9
 The FreeBSD license
10
 
11
 Redistribution and use in source and binary forms, with or without
12
 modification, are permitted provided that the following conditions
13
 are met:
14
 
15
 1. Redistributions of source code must retain the above copyright
16
    notice, this list of conditions and the following disclaimer.
17
 2. Redistributions in binary form must reproduce the above
18
    copyright notice, this list of conditions and the following
19
    disclaimer in the documentation and/or other materials
20
    provided with the distribution.
21
 
22
 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
23
 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25
 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
 PSS PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
 
36
 
37
module pss_int_controller
38
(
39
        input clk_i, rst_i,
40
 
41
        input [7:0] interrupt_bi,
42
 
43
        // control interface
44
        output ie_o,
45
        input ie_we_i,
46
        input ie_data_i,
47
        input [7:0] mask_bi,
48
        output [7:0] pending_bo,
49
        input clr_cmd_i,
50
        input [7:0] clr_code_bi,
51
 
52
        // cpu interface
53
        output reg cpu_req_o,
54
        input cpu_ack_i
55
);
56
 
57
reg [7:0] int_req, int_req_next;
58
reg IE;
59
 
60
wire [7:0] interrupt_masked;
61
assign interrupt_masked = interrupt_bi & mask_bi;
62
assign pending_bo = int_req;
63
assign ie_o = IE;
64
 
65
 
66
always @*
67
        begin
68
        // default
69
        int_req_next = int_req;
70
        // deasserting from cpu
71
        if (clr_cmd_i == 1'b1) int_req_next = int_req_next & ~clr_code_bi;
72
        // asserting from external interrupts
73
        int_req_next = int_req_next | interrupt_masked;
74
        end
75
 
76
always @(posedge clk_i)
77
        begin
78
        if (rst_i)
79
                int_req <= 8'h0;
80
        else
81
                int_req <= int_req_next;
82
        end
83
 
84
 
85
always @(posedge clk_i)
86
        begin
87
        if (rst_i)
88
                begin
89
                IE <= 1'b0;
90
                cpu_req_o <= 1'b0;
91
                end
92
        else
93
                begin
94
 
95
                if (ie_we_i == 1'b1)
96
                        IE <= ie_data_i;
97
 
98
                if ((IE == 1'b1) && (int_req != 8'h0))
99
                        begin
100
                        cpu_req_o <= 1'b1;
101
                        IE <= 1'b0;
102
                        end
103
                else if (cpu_ack_i == 1'b1)
104
                        cpu_req_o <= 1'b0;
105
 
106
                end
107
        end
108
 
109
endmodule

powered by: WebSVN 2.1.0

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