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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [rtl/] [verilog/] [RTF65002PIC.v] - Blame information for rev 11

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

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

powered by: WebSVN 2.1.0

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