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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm2/] [verilog/] [or1200_pm.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Power Management                                   ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  PM according to OR1K architectural specification.           ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - add support for dynamic clock gating                     ////
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.8  2001/10/21 17:57:16  lampret
48
// 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.
49
//
50
// Revision 1.7  2001/10/14 13:12:10  lampret
51
// MP3 version.
52
//
53
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
54
// no message
55
//
56
// Revision 1.2  2001/08/09 13:39:33  lampret
57
// Major clean-up.
58
//
59
// Revision 1.1  2001/07/20 00:46:21  lampret
60
// Development version of RTL. Libraries are missing.
61
//
62
//
63
 
64
// synopsys translate_off
65
`include "timescale.v"
66
// synopsys translate_on
67
`include "or1200_defines.v"
68
 
69
module or1200_pm_cm2(
70
                clk_i_cml_1,
71
 
72
        // RISC Internal Interface
73
        clk, rst, pic_wakeup, spr_write, spr_addr, spr_dat_i, spr_dat_o,
74
 
75
        // Power Management Interface
76
        pm_clksd, pm_cpustall, pm_dc_gate, pm_ic_gate, pm_dmmu_gate,
77
        pm_immu_gate, pm_tt_gate, pm_cpu_gate, pm_wakeup, pm_lvolt
78
);
79
 
80
 
81
input clk_i_cml_1;
82
reg  spr_write_cml_1;
83
reg [ 31 : 0 ] spr_addr_cml_1;
84
reg [ 31 : 0 ] spr_dat_i_cml_1;
85
reg  pm_cpustall_cml_1;
86
reg [ 3 : 0 ] sdf_cml_1;
87
reg  dme_cml_1;
88
reg  sme_cml_1;
89
reg  dcge_cml_1;
90
 
91
 
92
 
93
//
94
// RISC Internal Interface
95
//
96
input           clk;            // Clock
97
input           rst;            // Reset
98
input           pic_wakeup;     // Wakeup from the PIC
99
input           spr_write;      // SPR Read/Write
100
input   [31:0]   spr_addr;       // SPR Address
101
input   [31:0]   spr_dat_i;      // SPR Write Data
102
output  [31:0]   spr_dat_o;      // SPR Read Data
103
 
104
//
105
// Power Management Interface
106
//
107
input           pm_cpustall;    // Stall the CPU
108
output  [3:0]    pm_clksd;       // Clock Slowdown factor
109
output          pm_dc_gate;     // Gate DCache clock
110
output          pm_ic_gate;     // Gate ICache clock
111
output          pm_dmmu_gate;   // Gate DMMU clock
112
output          pm_immu_gate;   // Gate IMMU clock
113
output          pm_tt_gate;     // Gate Tick Timer clock
114
output          pm_cpu_gate;    // Gate main RISC/CPU clock
115
output          pm_wakeup;      // Activate (de-gate) all clocks
116
output          pm_lvolt;       // Lower operating voltage
117
 
118
`ifdef OR1200_PM_IMPLEMENTED
119
 
120
//
121
// Power Management Register bits
122
//
123
reg     [3:0]    sdf;    // Slow-down factor
124
reg             dme;    // Doze Mode Enable
125
reg             sme;    // Sleep Mode Enable
126
reg             dcge;   // Dynamic Clock Gating Enable
127
 
128
//
129
// Internal wires
130
//
131
wire            pmr_sel; // PMR select
132
 
133
//
134
// PMR address decoder (partial decoder)
135
//
136
`ifdef OR1200_PM_PARTIAL_DECODING
137
 
138
// SynEDA CoreMultiplier
139
// assignment(s): pmr_sel
140
// replace(s): spr_addr
141
assign pmr_sel = (spr_addr_cml_1[`OR1200_SPR_GROUP_BITS] == `OR1200_SPRGRP_PM) ? 1'b1 : 1'b0;
142
`else
143
assign pmr_sel = ((spr_addr[`OR1200_SPR_GROUP_BITS] == `OR1200_SPRGRP_PM) &&
144
                  (spr_addr[`OR1200_SPR_OFS_BITS] == `OR1200_PM_OFS_PMR)) ? 1'b1 : 1'b0;
145
`endif
146
 
147
//
148
// Write to PMR and also PMR[DME]/PMR[SME] reset when
149
// pic_wakeup is asserted
150
//
151
 
152
// SynEDA CoreMultiplier
153
// assignment(s): sdf, dme, sme, dcge
154
// replace(s): spr_write, spr_dat_i, sdf, dme, sme, dcge
155
always @(posedge clk or posedge rst)
156
        if (rst)
157
                {dcge, sme, dme, sdf} <= 7'b0;
158
        else begin  dcge <= dcge_cml_1; sme <= sme_cml_1; dme <= dme_cml_1; sdf <= sdf_cml_1; if (pmr_sel && spr_write_cml_1) begin
159
                sdf <= #1 spr_dat_i_cml_1[`OR1200_PM_PMR_SDF];
160
                dme <= #1 spr_dat_i_cml_1[`OR1200_PM_PMR_DME];
161
                sme <= #1 spr_dat_i_cml_1[`OR1200_PM_PMR_SME];
162
                dcge <= #1 spr_dat_i_cml_1[`OR1200_PM_PMR_DCGE];
163
        end
164
        else if (pic_wakeup) begin
165
                dme <= #1 1'b0;
166
                sme <= #1 1'b0;
167
        end end
168
 
169
//
170
// Read PMR
171
//
172
`ifdef OR1200_PM_READREGS
173
assign spr_dat_o[`OR1200_PM_PMR_SDF] = sdf_cml_1;
174
assign spr_dat_o[`OR1200_PM_PMR_DME] = dme_cml_1;
175
assign spr_dat_o[`OR1200_PM_PMR_SME] = sme_cml_1;
176
assign spr_dat_o[`OR1200_PM_PMR_DCGE] = dcge_cml_1;
177
`ifdef OR1200_PM_UNUSED_ZERO
178
 
179
// SynEDA CoreMultiplier
180
// assignment(s): spr_dat_o
181
// replace(s): sdf, dme, sme, dcge
182
assign spr_dat_o[`OR1200_PM_PMR_UNUSED] = 25'b0;
183
`endif
184
`endif
185
 
186
//
187
// Generate pm_clksd
188
//
189
 
190
// SynEDA CoreMultiplier
191
// assignment(s): pm_clksd
192
// replace(s): sdf
193
assign pm_clksd = sdf_cml_1;
194
 
195
//
196
// Statically generate all clock gate outputs
197
// TODO: add dynamic clock gating feature
198
//
199
 
200
// SynEDA CoreMultiplier
201
// assignment(s): pm_cpu_gate
202
// replace(s): dme, sme
203
assign pm_cpu_gate = (dme_cml_1 | sme_cml_1) & ~pic_wakeup;
204
assign pm_dc_gate = pm_cpu_gate;
205
assign pm_ic_gate = pm_cpu_gate;
206
assign pm_dmmu_gate = pm_cpu_gate;
207
assign pm_immu_gate = pm_cpu_gate;
208
 
209
// SynEDA CoreMultiplier
210
// assignment(s): pm_tt_gate
211
// replace(s): sme
212
assign pm_tt_gate = sme_cml_1 & ~pic_wakeup;
213
 
214
//
215
// Assert pm_wakeup when pic_wakeup is asserted
216
//
217
assign pm_wakeup = pic_wakeup;
218
 
219
//
220
// Assert pm_lvolt when pm_cpu_gate or pm_cpustall are asserted
221
//
222
 
223
// SynEDA CoreMultiplier
224
// assignment(s): pm_lvolt
225
// replace(s): pm_cpustall
226
assign pm_lvolt = pm_cpu_gate | pm_cpustall_cml_1;
227
 
228
`else
229
 
230
//
231
// When PM is not implemented, drive all outputs as would when PM is disabled
232
//
233
assign pm_clksd = 4'b0;
234
assign pm_cpu_gate = 1'b0;
235
assign pm_dc_gate = 1'b0;
236
assign pm_ic_gate = 1'b0;
237
assign pm_dmmu_gate = 1'b0;
238
assign pm_immu_gate = 1'b0;
239
assign pm_tt_gate = 1'b0;
240
assign pm_wakeup = 1'b1;
241
assign pm_lvolt = 1'b0;
242
 
243
//
244
// Read PMR
245
//
246
`ifdef OR1200_PM_READREGS
247
assign spr_dat_o[`OR1200_PM_PMR_SDF] = 4'b0;
248
assign spr_dat_o[`OR1200_PM_PMR_DME] = 1'b0;
249
assign spr_dat_o[`OR1200_PM_PMR_SME] = 1'b0;
250
assign spr_dat_o[`OR1200_PM_PMR_DCGE] = 1'b0;
251
`ifdef OR1200_PM_UNUSED_ZERO
252
assign spr_dat_o[`OR1200_PM_PMR_UNUSED] = 25'b0;
253
`endif
254
`endif
255
 
256
`endif
257
 
258
 
259
always @ (posedge clk_i_cml_1) begin
260
spr_write_cml_1 <= spr_write;
261
spr_addr_cml_1 <= spr_addr;
262
spr_dat_i_cml_1 <= spr_dat_i;
263
pm_cpustall_cml_1 <= pm_cpustall;
264
sdf_cml_1 <= sdf;
265
dme_cml_1 <= dme;
266
sme_cml_1 <= sme;
267
dcge_cml_1 <= dcge;
268
end
269
endmodule
270
 

powered by: WebSVN 2.1.0

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