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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_pm.v] - Blame information for rev 35

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

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

powered by: WebSVN 2.1.0

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