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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_pic.v] - Blame information for rev 589

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Programmable Interrupt Controller                  ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  PIC according to OR1K architectural specification.          ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   None                                                       ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 589 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
48
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
49
//
50 504 lampret
// Revision 1.8  2001/10/21 17:57:16  lampret
51
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
52
//
53
// Revision 1.7  2001/10/14 13:12:10  lampret
54
// MP3 version.
55
//
56
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
57
// no message
58
//
59
// Revision 1.2  2001/08/09 13:39:33  lampret
60
// Major clean-up.
61
//
62
// Revision 1.1  2001/07/20 00:46:21  lampret
63
// Development version of RTL. Libraries are missing.
64
//
65
//
66
 
67
// synopsys translate_off
68
`include "timescale.v"
69
// synopsys translate_on
70
`include "or1200_defines.v"
71
 
72
module or1200_pic(
73
        // RISC Internal Interface
74
        clk, rst, spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
75 589 lampret
        pic_wakeup, int,
76 504 lampret
 
77
        // PIC Interface
78
        pic_int
79
);
80
 
81
//
82
// RISC Internal Interface
83
//
84
input           clk;            // Clock
85
input           rst;            // Reset
86
input           spr_cs;         // SPR CS
87
input           spr_write;      // SPR Write
88
input   [31:0]   spr_addr;       // SPR Address
89
input   [31:0]   spr_dat_i;      // SPR Write Data
90
output  [31:0]   spr_dat_o;      // SPR Read Data
91
output          pic_wakeup;     // Wakeup to the PM
92 589 lampret
output          int;            // interrupt
93 504 lampret
                                // exception request
94
 
95
//
96
// PIC Interface
97
//
98
input   [`OR1200_PIC_INTS-1:0]   pic_int;// Interrupt inputs
99
 
100
`ifdef OR1200_PIC_IMPLEMENTED
101
 
102
//
103
// PIC Mask Register bits (or no register)
104
//
105
`ifdef OR1200_PIC_PICMR
106
reg     [`OR1200_PIC_INTS-1:2]  picmr;  // PICMR bits
107
`else
108
wire    [`OR1200_PIC_INTS-1:2]  picmr;  // No PICMR register
109
`endif
110
 
111
//
112
// PIC Status Register bits (or no register)
113
//
114
`ifdef OR1200_PIC_PICSR
115
reg     [`OR1200_PIC_INTS-1:0]   picsr;  // PICSR bits
116
`else
117
wire    [`OR1200_PIC_INTS-1:0]   picsr;  // No PICSR register
118
`endif
119
 
120
//
121
// Internal wires & regs
122
//
123
wire            picmr_sel;      // PICMR select
124
wire            picsr_sel;      // PICSR select
125
wire    [`OR1200_PIC_INTS-1:0] um_ints;// Unmasked interrupts
126
reg     [31:0]   spr_dat_o;      // SPR data out
127
 
128
//
129
// PIC registers address decoder
130
//
131
assign picmr_sel = (spr_cs && (spr_addr[`OR1200_PICOFS_BITS] == `OR1200_PIC_OFS_PICMR)) ? 1'b1 : 1'b0;
132
assign picsr_sel = (spr_cs && (spr_addr[`OR1200_PICOFS_BITS] == `OR1200_PIC_OFS_PICSR)) ? 1'b1 : 1'b0;
133
 
134
//
135
// Write to PICMR
136
//
137
`ifdef OR1200_PIC_PICMR
138
always @(posedge clk or posedge rst)
139
        if (rst)
140
                picmr <= {1'b1, {`OR1200_PIC_INTS-3{1'b0}}};
141
        else if (picmr_sel && spr_write) begin
142
                picmr <= #1 spr_dat_i[`OR1200_PIC_INTS-1:2];
143
        end
144
`else
145 589 lampret
assign picmr = (`OR1200_PIC_INTS)'b1;
146 504 lampret
`endif
147
 
148
//
149
// Write to PICSR, both CPU and external ints
150
//
151
`ifdef OR1200_PIC_PICSR
152
always @(posedge clk or posedge rst)
153
        if (rst)
154
                picsr <= {`OR1200_PIC_INTS-2{1'b0}};
155
        else if (picsr_sel && spr_write) begin
156
                picsr <= #1 spr_dat_i[`OR1200_PIC_INTS-1:0] | um_ints;
157
        end else
158
                picsr <= #1 picsr | um_ints;
159
`else
160
assign picsr = pic_int;
161
`endif
162
 
163
//
164
// Read PIC registers
165
//
166 589 lampret
always @(spr_addr or picmr or picsr)
167 504 lampret
        case (spr_addr[`OR1200_PICOFS_BITS])    // synopsys full_case parallel_case
168
`ifdef OR1200_PIC_READREGS
169
                `OR1200_PIC_OFS_PICMR: begin
170
                                        spr_dat_o[`OR1200_PIC_INTS-1:0] = {picmr, 2'b0};
171
`ifdef OR1200_PIC_UNUSED_ZERO
172
                                        spr_dat_o[31:`OR1200_PIC_INTS] = {32-`OR1200_PIC_INTS{1'b0}};
173
`endif
174
                                end
175
`endif
176
                default: begin
177
                                spr_dat_o[`OR1200_PIC_INTS-1:0] = picsr;
178
`ifdef OR1200_PIC_UNUSED_ZERO
179
                                spr_dat_o[31:`OR1200_PIC_INTS] = {32-`OR1200_PIC_INTS{1'b0}};
180
`endif
181
                        end
182
        endcase
183
 
184
//
185
// Unmasked interrupts
186
//
187
assign um_ints = pic_int & {picmr, 2'b11};
188
 
189
//
190 589 lampret
// Generate int
191 504 lampret
//
192 589 lampret
assign int = |um_ints;
193 504 lampret
 
194
//
195 589 lampret
// Assert pic_wakeup when int is asserted
196 504 lampret
//
197 589 lampret
assign pic_wakeup = int;
198 504 lampret
 
199
`else
200
 
201
//
202
// When PIC is not implemented, drive all outputs as would when PIC is disabled
203
//
204 589 lampret
assign int = pic_int[1] | pic_int[0];
205
assign pic_wakeup= int;
206 504 lampret
 
207
//
208
// Read PIC registers
209
//
210
`ifdef OR1200_PIC_READREGS
211
assign spr_dat_o[`OR1200_PIC_INTS-1:0] = `OR1200_PIC_INTS'b0;
212
`ifdef OR1200_PIC_UNUSED_ZERO
213
assign spr_dat_o[31:`OR1200_PIC_INTS] = 32-`OR1200_PIC_INTS'b0;
214
`endif
215
`endif
216
 
217
`endif
218
 
219
endmodule

powered by: WebSVN 2.1.0

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