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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm2/] [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_cm2(
79
                clk_i_cml_1,
80
 
81
        // RISC Internal Interface
82
        clk, rst, spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
83
        pic_wakeup, intr,
84
 
85
        // PIC Interface
86
        pic_int
87
);
88
 
89
 
90
input clk_i_cml_1;
91
reg  spr_write_cml_1;
92
reg [ 31 : 0 ] spr_addr_cml_1;
93
reg [ 31 : 0 ] spr_dat_i_cml_1;
94
reg  intr_cml_1;
95
reg [ 20 - 1 : 2 ] picmr_cml_1;
96
reg [ 20 - 1 : 0 ] picsr_cml_1;
97
reg [ 20 - 1 : 0 ] um_ints_cml_1;
98
 
99
 
100
 
101
//
102
// RISC Internal Interface
103
//
104
input           clk;            // Clock
105
input           rst;            // Reset
106
input           spr_cs;         // SPR CS
107
input           spr_write;      // SPR Write
108
input   [31:0]   spr_addr;       // SPR Address
109
input   [31:0]   spr_dat_i;      // SPR Write Data
110
output  [31:0]   spr_dat_o;      // SPR Read Data
111
output          pic_wakeup;     // Wakeup to the PM
112
output          intr;           // interrupt
113
                                // exception request
114
 
115
//
116
// PIC Interface
117
//
118
input   [`OR1200_PIC_INTS-1:0]   pic_int;// Interrupt inputs
119
 
120
`ifdef OR1200_PIC_IMPLEMENTED
121
 
122
//
123
// PIC Mask Register bits (or no register)
124
//
125
`ifdef OR1200_PIC_PICMR
126
reg     [`OR1200_PIC_INTS-1:2]  picmr;  // PICMR bits
127
`else
128
wire    [`OR1200_PIC_INTS-1:2]  picmr;  // No PICMR register
129
`endif
130
 
131
//
132
// PIC Status Register bits (or no register)
133
//
134
`ifdef OR1200_PIC_PICSR
135
reg     [`OR1200_PIC_INTS-1:0]   picsr;  // PICSR bits
136
`else
137
wire    [`OR1200_PIC_INTS-1:0]   picsr;  // No PICSR register
138
`endif
139
 
140
//
141
// Internal wires & regs
142
//
143
wire            picmr_sel;      // PICMR select
144
wire            picsr_sel;      // PICSR select
145
wire    [`OR1200_PIC_INTS-1:0] um_ints;// Unmasked interrupts
146
reg     [31:0]   spr_dat_o;      // SPR data out
147
 
148
//
149
// PIC registers address decoder
150
//
151
 
152
// SynEDA CoreMultiplier
153
// assignment(s): picmr_sel
154
// replace(s): spr_addr
155
assign picmr_sel = (spr_cs && (spr_addr_cml_1[`OR1200_PICOFS_BITS] == `OR1200_PIC_OFS_PICMR)) ? 1'b1 : 1'b0;
156
 
157
// SynEDA CoreMultiplier
158
// assignment(s): picsr_sel
159
// replace(s): spr_addr
160
assign picsr_sel = (spr_cs && (spr_addr_cml_1[`OR1200_PICOFS_BITS] == `OR1200_PIC_OFS_PICSR)) ? 1'b1 : 1'b0;
161
 
162
//
163
// Write to PICMR
164
//
165
`ifdef OR1200_PIC_PICMR
166
 
167
// SynEDA CoreMultiplier
168
// assignment(s): picmr
169
// replace(s): spr_write, spr_dat_i, picmr
170
always @(posedge clk or posedge rst)
171
        if (rst)
172
                picmr <= {1'b1, {`OR1200_PIC_INTS-3{1'b0}}};
173
        else begin  picmr <= picmr_cml_1; if (picmr_sel && spr_write_cml_1) begin
174
                picmr <= #1 spr_dat_i_cml_1[`OR1200_PIC_INTS-1:2];
175
        end end
176
`else
177
assign picmr = (`OR1200_PIC_INTS)'b1;
178
`endif
179
 
180
//
181
// Write to PICSR, both CPU and external ints
182
//
183
`ifdef OR1200_PIC_PICSR
184
 
185
// SynEDA CoreMultiplier
186
// assignment(s): picsr
187
// replace(s): spr_write, spr_dat_i, picsr, um_ints
188
always @(posedge clk or posedge rst)
189
        if (rst)
190
                picsr <= {`OR1200_PIC_INTS{1'b0}};
191
        else begin  picsr <= picsr_cml_1; if (picsr_sel && spr_write_cml_1) begin
192
                picsr <= #1 spr_dat_i_cml_1[`OR1200_PIC_INTS-1:0] | um_ints_cml_1;
193
        end else begin
194
                picsr <= #1 picsr_cml_1 | um_ints_cml_1;
195
        end end
196
`else
197
assign picsr = pic_int;
198
`endif
199
 
200
//
201
// Read PIC registers
202
//
203
 
204
// SynEDA CoreMultiplier
205
// assignment(s): spr_dat_o
206
// replace(s): spr_addr, picmr, picsr
207
always @(spr_addr_cml_1 or picmr_cml_1 or picsr_cml_1)
208
        case (spr_addr_cml_1[`OR1200_PICOFS_BITS])      // synopsys parallel_case
209
`ifdef OR1200_PIC_READREGS
210
                `OR1200_PIC_OFS_PICMR: begin
211
                                        spr_dat_o[`OR1200_PIC_INTS-1:0] = {picmr_cml_1, 2'b0};
212
`ifdef OR1200_PIC_UNUSED_ZERO
213
                                        spr_dat_o[31:`OR1200_PIC_INTS] = {32-`OR1200_PIC_INTS{1'b0}};
214
`endif
215
                                end
216
`endif
217
                default: begin
218
                                spr_dat_o[`OR1200_PIC_INTS-1:0] = picsr_cml_1;
219
`ifdef OR1200_PIC_UNUSED_ZERO
220
                                spr_dat_o[31:`OR1200_PIC_INTS] = {32-`OR1200_PIC_INTS{1'b0}};
221
`endif
222
                        end
223
        endcase
224
 
225
//
226
// Unmasked interrupts
227
//
228
assign um_ints = pic_int & {picmr, 2'b11};
229
 
230
//
231
// Generate intr
232
//
233
assign intr = |um_ints;
234
 
235
//
236
// Assert pic_wakeup when intr is asserted
237
//
238
 
239
// SynEDA CoreMultiplier
240
// assignment(s): pic_wakeup
241
// replace(s): intr
242
assign pic_wakeup = intr_cml_1;
243
 
244
`else
245
 
246
//
247
// When PIC is not implemented, drive all outputs as would when PIC is disabled
248
//
249
assign intr = pic_int[1] | pic_int[0];
250
assign pic_wakeup= intr;
251
 
252
//
253
// Read PIC registers
254
//
255
`ifdef OR1200_PIC_READREGS
256
assign spr_dat_o[`OR1200_PIC_INTS-1:0] = `OR1200_PIC_INTS'b0;
257
`ifdef OR1200_PIC_UNUSED_ZERO
258
assign spr_dat_o[31:`OR1200_PIC_INTS] = 32-`OR1200_PIC_INTS'b0;
259
`endif
260
`endif
261
 
262
`endif
263
 
264
 
265
always @ (posedge clk_i_cml_1) begin
266
spr_write_cml_1 <= spr_write;
267
spr_addr_cml_1 <= spr_addr;
268
spr_dat_i_cml_1 <= spr_dat_i;
269
intr_cml_1 <= intr;
270
picmr_cml_1 <= picmr;
271
picsr_cml_1 <= picsr;
272
um_ints_cml_1 <= um_ints;
273
end
274
endmodule
275
 

powered by: WebSVN 2.1.0

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