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

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [rtl/] [verilog/] [RaptorPIC.v] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 robfinch
//=============================================================================
2
//      (C) 2005-2012  Robert Finch
3
//      All rights reserved.
4
//      robfinch@Opencores.org
5
//
6
//      RaptorPIC.v
7
//
8
//  
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//                                                                          
22
//
23
//              Encodes discrete interrupt request signals into four
24
//      bit code using a priority encoder.
25
//      
26
//      reg
27
//      0        - encoded request number (read only)
28
//                      This register contains the number identifying
29
//                      the current requester.
30
//                      the actual number is shifted left three times
31
//                      before being placed into this register so it may
32
//                      be used directly as an index in OS software. The
33
//                      index may be a mailbox id or index into a jump
34
//                      table as desired by the OS. If there is no
35
//                      active request, then this number will be 
36
//                      zero.
37
//      1       - request enable (read / write)
38
//                      this register contains request enable bits
39
//                      for each request line. 1 = request
40
//                      enabled, 0 = request disabled. On reset this
41
//                      register is set to zero (disable all ints).
42
//                      bit zero is specially reserved for nmi
43
//
44
//      2   - write only
45
//                      this register disables the interrupt indicated
46
//                      by the low order four bits of the input data
47
//                      
48
//      3       - write only
49
//                      this register enables the interrupt indicated
50
//                      by the low order four bits of the input data
51
//
52
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53
//      |WISHBONE Datasheet
54
//      |WISHBONE SoC Architecture Specification, Revision B.3
55
//      |
56
//      |Description:                                           Specifications:
57
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58
//      |General Description:                           simple programmable interrupt controller
59
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60
//      |Supported Cycles:                                      SLAVE,READ/WRITE
61
//      |                                                                       SLAVE,BLOCK READ/WRITE
62
//      |                                                                       SLAVE,RMW
63
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64
//      |Data port, size:                                       16 bit
65
//      |Data port, granularity:                        16 bit
66
//      |Data port, maximum operand size:       16 bit
67
//      |Data transfer ordering:                        Undefined
68
//      |Data transfer sequencing:                      Undefined
69
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70
//      |Clock frequency constraints:           none
71
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72
//      |Supported signal list and                      Signal Name             WISHBONE equiv.
73
//      |cross reference to equivalent          ack_o                           ACK_O
74
//      |WISHBONE signals                                       adr_i(2:1)                      ADR_I()
75
//      |                                                                       clk_i                           CLK_I
76
//      |                                                                       dat_i(15:0)                     DAT_I()
77
//      |                                                                       dat_o(15:0)                     DAT_O()
78
//      |                                                                       cyc_i                           CYC_I
79
//      |                                                                       stb_i                           STB_I
80
//      |                                                                       we_i                            WE_I
81
//      |
82
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
83
//      |Special requirements:
84
//      +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85
//
86
//      Spartan3-4
87
//      105 LUTs / 58 slices / 163MHz
88
//=============================================================================
89
 
90
module RaptorPIC
91
(
92
        input rst_i,            // reset
93
        input clk_i,            // system clock
94
        input cyc_i,            // cycle valid
95
        input stb_i,            // strobe
96
        output ack_o,           // transfer acknowledge
97
        input we_i,                     // write
98
        input [1:0] sel_i,       // byte select
99
        input [63:0] adr_i,      // address
100
        input [15:0] dat_i,
101
        output reg [15:0] dat_o,
102
        output vol_o,           // volatile register selected
103
        input i1, i2, i3, i4, i5, i6, i7,
104
                i8, i9, i10, i11, i12, i13, i14, i15,
105
        output irqo,    // normally connected to the processor irq
106
        input nmii,             // nmi input connected to nmi requester
107
        output nmio,    // normally connected to the nmi of cpu
108
        output reg [3:0] irqenc
109
);
110
 
111
reg [15:0] ie;           // interrupt enable register
112
reg ack1;
113
 
114
wire cs = cyc_i && stb_i && adr_i[63:4]==60'hFFFF_FFFF_FFDC_0FF;
115
assign vol_o = cs;
116
 
117
always @(posedge clk_i)
118
        ack1 <= cs & !ack_o;
119
assign ack_o = ack1 && cs;
120
 
121
// write registers      
122
always @(posedge clk_i)
123
        if (rst_i)
124
                ie <= 16'h0;
125
        else if (cs & we_i)
126
                case (adr_i[2:1])
127
                2'd0,2'd1:
128
                        begin
129
                                if (sel_i[0]) ie[ 7:0] <= dat_i[ 7:0];
130
                                if (sel_i[1]) ie[15:8] <= dat_i[15:8];
131
                        end
132
                2'd2,2'd3:
133
                        if (sel_i[0]) ie[dat_i[3:0]] <= adr_i[1];
134
                endcase
135
 
136
// read registers
137
always @(posedge clk_i)
138
        if (cs)
139
                case (adr_i[2:1])
140
                2'd0:   dat_o <= {12'b0,irqenc};
141
                default:        dat_o <= ie;
142
                endcase
143
        else
144
                dat_o <= 16'h0000;
145
 
146
assign irqo = irqenc != 4'h0;
147
assign nmio = nmii & ie[0];
148
 
149
// irq requests are latched on every clock edge to prevent
150
// misreads
151
// nmi is not encoded
152
always @(posedge clk_i)
153
        case (1'b1)
154
        i1&ie[1]:               irqenc <= 4'd1;
155
        i2&ie[2]:               irqenc <= 4'd2;
156
        i3&ie[3]:               irqenc <= 4'd3;
157
        i4&ie[4]:               irqenc <= 4'd4;
158
        i5&ie[5]:               irqenc <= 4'd5;
159
        i6&ie[6]:               irqenc <= 4'd6;
160
        i7&ie[7]:               irqenc <= 4'd7;
161
        i8&ie[8]:               irqenc <= 4'd8;
162
        i9&ie[9]:               irqenc <= 4'd9;
163
        i10&ie[10]:     irqenc <= 4'd10;
164
        i11&ie[11]:             irqenc <= 4'd11;
165
        i12&ie[12]:             irqenc <= 4'd12;
166
        i13&ie[13]:             irqenc <= 4'd13;
167
        i14&ie[14]:             irqenc <= 4'd14;
168
        i15&ie[15]:             irqenc <= 4'd15;
169
        default:        irqenc <= 4'd0;
170
        endcase
171
 
172
endmodule

powered by: WebSVN 2.1.0

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