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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [or1200/] [rtl/] [verilog/] [or1200_pm.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
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: or1200_pm.v,v $
47
// 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
// 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:35  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_pm(
73
        // RISC Internal Interface
74
        clk, rst, pic_wakeup, spr_write, spr_addr, spr_dat_i, spr_dat_o,
75
 
76
        // Power Management Interface
77
        pm_clksd, pm_cpustall, pm_dc_gate, pm_ic_gate, pm_dmmu_gate,
78
        pm_immu_gate, pm_tt_gate, pm_cpu_gate, pm_wakeup, pm_lvolt
79
);
80
 
81
//
82
// RISC Internal Interface
83
//
84
input           clk;            // Clock
85
input           rst;            // Reset
86
input           pic_wakeup;     // Wakeup from the PIC
87
input           spr_write;      // SPR Read/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
 
92
//
93
// Power Management Interface
94
//
95
input           pm_cpustall;    // Stall the CPU
96
output  [3:0]    pm_clksd;       // Clock Slowdown factor
97
output          pm_dc_gate;     // Gate DCache clock
98
output          pm_ic_gate;     // Gate ICache clock
99
output          pm_dmmu_gate;   // Gate DMMU clock
100
output          pm_immu_gate;   // Gate IMMU clock
101
output          pm_tt_gate;     // Gate Tick Timer clock
102
output          pm_cpu_gate;    // Gate main RISC/CPU clock
103
output          pm_wakeup;      // Activate (de-gate) all clocks
104
output          pm_lvolt;       // Lower operating voltage
105
 
106
`ifdef OR1200_PM_IMPLEMENTED
107
 
108
//
109
// Power Management Register bits
110
//
111
reg     [3:0]    sdf;    // Slow-down factor
112
reg             dme;    // Doze Mode Enable
113
reg             sme;    // Sleep Mode Enable
114
reg             dcge;   // Dynamic Clock Gating Enable
115
 
116
//
117
// Internal wires
118
//
119
wire            pmr_sel; // PMR select
120
 
121
//
122
// PMR address decoder (partial decoder)
123
//
124
`ifdef OR1200_PM_PARTIAL_DECODING
125
assign pmr_sel = (spr_addr[`OR1200_SPR_GROUP_BITS] == `OR1200_SPRGRP_PM) ? 1'b1 : 1'b0;
126
`else
127
assign pmr_sel = ((spr_addr[`OR1200_SPR_GROUP_BITS] == `OR1200_SPRGRP_PM) &&
128
                  (spr_addr[`OR1200_SPR_OFS_BITS] == `OR1200_PM_OFS_PMR)) ? 1'b1 : 1'b0;
129
`endif
130
 
131
//
132
// Write to PMR and also PMR[DME]/PMR[SME] reset when
133
// pic_wakeup is asserted
134
//
135
always @(posedge clk or posedge rst)
136
        if (rst)
137
                {dcge, sme, dme, sdf} <= 7'b0;
138
        else if (pmr_sel && spr_write) begin
139
                sdf <= #1 spr_dat_i[`OR1200_PM_PMR_SDF];
140
                dme <= #1 spr_dat_i[`OR1200_PM_PMR_DME];
141
                sme <= #1 spr_dat_i[`OR1200_PM_PMR_SME];
142
                dcge <= #1 spr_dat_i[`OR1200_PM_PMR_DCGE];
143
        end
144
        else if (pic_wakeup) begin
145
                dme <= #1 1'b0;
146
                sme <= #1 1'b0;
147
        end
148
 
149
//
150
// Read PMR
151
//
152
`ifdef OR1200_PM_READREGS
153
assign spr_dat_o[`OR1200_PM_PMR_SDF] = sdf;
154
assign spr_dat_o[`OR1200_PM_PMR_DME] = dme;
155
assign spr_dat_o[`OR1200_PM_PMR_SME] = sme;
156
assign spr_dat_o[`OR1200_PM_PMR_DCGE] = dcge;
157
`ifdef OR1200_PM_UNUSED_ZERO
158
assign spr_dat_o[`OR1200_PM_PMR_UNUSED] = 25'b0;
159
`endif
160
`endif
161
 
162
//
163
// Generate pm_clksd
164
//
165
assign pm_clksd = sdf;
166
 
167
//
168
// Statically generate all clock gate outputs
169
// TODO: add dynamic clock gating feature
170
//
171
assign pm_cpu_gate = (dme | sme) & ~pic_wakeup;
172
assign pm_dc_gate = pm_cpu_gate;
173
assign pm_ic_gate = pm_cpu_gate;
174
assign pm_dmmu_gate = pm_cpu_gate;
175
assign pm_immu_gate = pm_cpu_gate;
176
assign pm_tt_gate = sme & ~pic_wakeup;
177
 
178
//
179
// Assert pm_wakeup when pic_wakeup is asserted
180
//
181
assign pm_wakeup = pic_wakeup;
182
 
183
//
184
// Assert pm_lvolt when pm_cpu_gate or pm_cpustall are asserted
185
//
186
assign pm_lvolt = pm_cpu_gate | pm_cpustall;
187
 
188
`else
189
 
190
//
191
// When PM is not implemented, drive all outputs as would when PM is disabled
192
//
193
assign pm_clksd = 4'b0;
194
assign pm_cpu_gate = 1'b0;
195
assign pm_dc_gate = 1'b0;
196
assign pm_ic_gate = 1'b0;
197
assign pm_dmmu_gate = 1'b0;
198
assign pm_immu_gate = 1'b0;
199
assign pm_tt_gate = 1'b0;
200
assign pm_wakeup = 1'b1;
201
assign pm_lvolt = 1'b0;
202
 
203
//
204
// Read PMR
205
//
206
`ifdef OR1200_PM_READREGS
207
assign spr_dat_o[`OR1200_PM_PMR_SDF] = 4'b0;
208
assign spr_dat_o[`OR1200_PM_PMR_DME] = 1'b0;
209
assign spr_dat_o[`OR1200_PM_PMR_SME] = 1'b0;
210
assign spr_dat_o[`OR1200_PM_PMR_DCGE] = 1'b0;
211
`ifdef OR1200_PM_UNUSED_ZERO
212
assign spr_dat_o[`OR1200_PM_PMR_UNUSED] = 25'b0;
213
`endif
214
`endif
215
 
216
`endif
217
 
218
endmodule

powered by: WebSVN 2.1.0

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