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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm3/] [verilog/] [or1200_pic.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
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
// Revision 1.3  2002/03/29 15:16:56  lampret
48
// Some of the warnings fixed.
49
//
50
// Revision 1.2  2002/01/18 07:56:00  lampret
51
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
52
//
53
// Revision 1.1  2002/01/03 08:16:15  lampret
54
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
55
//
56
// Revision 1.8  2001/10/21 17:57:16  lampret
57
// 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.
58
//
59
// Revision 1.7  2001/10/14 13:12:10  lampret
60
// MP3 version.
61
//
62
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
63
// no message
64
//
65
// Revision 1.2  2001/08/09 13:39:33  lampret
66
// Major clean-up.
67
//
68
// Revision 1.1  2001/07/20 00:46:21  lampret
69
// Development version of RTL. Libraries are missing.
70
//
71
//
72
 
73
// synopsys translate_off
74
`include "timescale.v"
75
// synopsys translate_on
76
`include "or1200_defines.v"
77
 
78
module or1200_pic_cm3(
79
                clk_i_cml_1,
80
                clk_i_cml_2,
81
 
82
        // RISC Internal Interface
83
        clk, rst, spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
84
        pic_wakeup, intr,
85
 
86
        // PIC Interface
87
        pic_int
88
);
89
 
90
 
91
input clk_i_cml_1;
92
input clk_i_cml_2;
93
reg  spr_write_cml_2;
94
reg [ 31 : 0 ] spr_addr_cml_2;
95
reg [ 31 : 0 ] spr_addr_cml_1;
96
reg [ 31 : 0 ] spr_dat_i_cml_2;
97
reg [ 31 : 0 ] spr_dat_i_cml_1;
98
reg [ 20 - 1 : 0 ] pic_int_cml_1;
99
reg [ 20 - 1 : 2 ] picmr_cml_2;
100
reg [ 20 - 1 : 2 ] picmr_cml_1;
101
reg [ 20 - 1 : 0 ] picsr_cml_2;
102
reg [ 20 - 1 : 0 ] picsr_cml_1;
103
reg [ 20 - 1 : 0 ] um_ints_cml_2;
104
 
105
 
106
 
107
//
108
// RISC Internal Interface
109
//
110
input           clk;            // Clock
111
input           rst;            // Reset
112
input           spr_cs;         // SPR CS
113
input           spr_write;      // SPR Write
114
input   [31:0]   spr_addr;       // SPR Address
115
input   [31:0]   spr_dat_i;      // SPR Write Data
116
output  [31:0]   spr_dat_o;      // SPR Read Data
117
output          pic_wakeup;     // Wakeup to the PM
118
output          intr;           // interrupt
119
                                // exception request
120
 
121
//
122
// PIC Interface
123
//
124
input   [`OR1200_PIC_INTS-1:0]   pic_int;// Interrupt inputs
125
 
126
`ifdef OR1200_PIC_IMPLEMENTED
127
 
128
//
129
// PIC Mask Register bits (or no register)
130
//
131
`ifdef OR1200_PIC_PICMR
132
reg     [`OR1200_PIC_INTS-1:2]  picmr;  // PICMR bits
133
`else
134
wire    [`OR1200_PIC_INTS-1:2]  picmr;  // No PICMR register
135
`endif
136
 
137
//
138
// PIC Status Register bits (or no register)
139
//
140
`ifdef OR1200_PIC_PICSR
141
reg     [`OR1200_PIC_INTS-1:0]   picsr;  // PICSR bits
142
`else
143
wire    [`OR1200_PIC_INTS-1:0]   picsr;  // No PICSR register
144
`endif
145
 
146
//
147
// Internal wires & regs
148
//
149
wire            picmr_sel;      // PICMR select
150
wire            picsr_sel;      // PICSR select
151
wire    [`OR1200_PIC_INTS-1:0] um_ints;// Unmasked interrupts
152
reg     [31:0]   spr_dat_o;      // SPR data out
153
 
154
//
155
// PIC registers address decoder
156
//
157
 
158
// SynEDA CoreMultiplier
159
// assignment(s): picmr_sel
160
// replace(s): spr_addr
161
assign picmr_sel = (spr_cs && (spr_addr_cml_2[`OR1200_PICOFS_BITS] == `OR1200_PIC_OFS_PICMR)) ? 1'b1 : 1'b0;
162
 
163
// SynEDA CoreMultiplier
164
// assignment(s): picsr_sel
165
// replace(s): spr_addr
166
assign picsr_sel = (spr_cs && (spr_addr_cml_2[`OR1200_PICOFS_BITS] == `OR1200_PIC_OFS_PICSR)) ? 1'b1 : 1'b0;
167
 
168
//
169
// Write to PICMR
170
//
171
`ifdef OR1200_PIC_PICMR
172
 
173
// SynEDA CoreMultiplier
174
// assignment(s): picmr
175
// replace(s): spr_write, spr_dat_i, picmr
176
always @(posedge clk or posedge rst)
177
        if (rst)
178
                picmr <= {1'b1, {`OR1200_PIC_INTS-3{1'b0}}};
179
        else begin  picmr <= picmr_cml_2; if (picmr_sel && spr_write_cml_2) begin
180
                picmr <= #1 spr_dat_i_cml_2[`OR1200_PIC_INTS-1:2];
181
        end end
182
`else
183
assign picmr = (`OR1200_PIC_INTS)'b1;
184
`endif
185
 
186
//
187
// Write to PICSR, both CPU and external ints
188
//
189
`ifdef OR1200_PIC_PICSR
190
 
191
// SynEDA CoreMultiplier
192
// assignment(s): picsr
193
// replace(s): spr_write, spr_dat_i, picsr, um_ints
194
always @(posedge clk or posedge rst)
195
        if (rst)
196
                picsr <= {`OR1200_PIC_INTS{1'b0}};
197
        else begin  picsr <= picsr_cml_2; if (picsr_sel && spr_write_cml_2) begin
198
                picsr <= #1 spr_dat_i_cml_2[`OR1200_PIC_INTS-1:0] | um_ints_cml_2;
199
        end else begin
200
                picsr <= #1 picsr_cml_2 | um_ints_cml_2;
201
        end end
202
`else
203
assign picsr = pic_int;
204
`endif
205
 
206
//
207
// Read PIC registers
208
//
209
 
210
// SynEDA CoreMultiplier
211
// assignment(s): spr_dat_o
212
// replace(s): spr_addr, picmr, picsr
213
always @(spr_addr_cml_1 or picmr_cml_1 or picsr_cml_1)
214
        case (spr_addr_cml_1[`OR1200_PICOFS_BITS])      // synopsys parallel_case
215
`ifdef OR1200_PIC_READREGS
216
                `OR1200_PIC_OFS_PICMR: begin
217
                                        spr_dat_o[`OR1200_PIC_INTS-1:0] = {picmr_cml_1, 2'b0};
218
`ifdef OR1200_PIC_UNUSED_ZERO
219
                                        spr_dat_o[31:`OR1200_PIC_INTS] = {32-`OR1200_PIC_INTS{1'b0}};
220
`endif
221
                                end
222
`endif
223
                default: begin
224
                                spr_dat_o[`OR1200_PIC_INTS-1:0] = picsr_cml_1;
225
`ifdef OR1200_PIC_UNUSED_ZERO
226
                                spr_dat_o[31:`OR1200_PIC_INTS] = {32-`OR1200_PIC_INTS{1'b0}};
227
`endif
228
                        end
229
        endcase
230
 
231
//
232
// Unmasked interrupts
233
//
234
 
235
// SynEDA CoreMultiplier
236
// assignment(s): um_ints
237
// replace(s): pic_int, picmr
238
assign um_ints = pic_int_cml_1 & {picmr_cml_1, 2'b11};
239
 
240
//
241
// Generate intr
242
//
243
assign intr = |um_ints;
244
 
245
//
246
// Assert pic_wakeup when intr is asserted
247
//
248
assign pic_wakeup = intr;
249
 
250
`else
251
 
252
//
253
// When PIC is not implemented, drive all outputs as would when PIC is disabled
254
//
255
assign intr = pic_int[1] | pic_int[0];
256
assign pic_wakeup= intr;
257
 
258
//
259
// Read PIC registers
260
//
261
`ifdef OR1200_PIC_READREGS
262
assign spr_dat_o[`OR1200_PIC_INTS-1:0] = `OR1200_PIC_INTS'b0;
263
`ifdef OR1200_PIC_UNUSED_ZERO
264
assign spr_dat_o[31:`OR1200_PIC_INTS] = 32-`OR1200_PIC_INTS'b0;
265
`endif
266
`endif
267
 
268
`endif
269
 
270
 
271
always @ (posedge clk_i_cml_1) begin
272
spr_addr_cml_1 <= spr_addr;
273
spr_dat_i_cml_1 <= spr_dat_i;
274
pic_int_cml_1 <= pic_int;
275
picmr_cml_1 <= picmr;
276
picsr_cml_1 <= picsr;
277
end
278
always @ (posedge clk_i_cml_2) begin
279
spr_write_cml_2 <= spr_write;
280
spr_addr_cml_2 <= spr_addr_cml_1;
281
spr_dat_i_cml_2 <= spr_dat_i_cml_1;
282
picmr_cml_2 <= picmr_cml_1;
283
picsr_cml_2 <= picsr_cml_1;
284
um_ints_cml_2 <= um_ints;
285
end
286
endmodule
287
 

powered by: WebSVN 2.1.0

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