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

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [mp3/] [rtl/] [verilog/] [or1200.xcv/] [pm.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 266 lampret
//////////////////////////////////////////////////////////////////////
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.1.1.1  2001/10/06 10:18:35  igorm
48
// no message
49
//
50
// Revision 1.2  2001/08/09 13:39:33  lampret
51
// Major clean-up.
52
//
53
// Revision 1.1  2001/07/20 00:46:21  lampret
54
// Development version of RTL. Libraries are missing.
55
//
56
//
57
 
58
// synopsys translate_off
59
`include "timescale.v"
60
// synopsys translate_on
61
`include "defines.v"
62
 
63
module pm(
64
        // RISC Internal Interface
65
        clk, rst, pic_wakeup, spr_write, spr_addr, spr_dat_i, spr_dat_o,
66
 
67
        // Power Management Interface
68
        pm_clksd, pm_cpustall, pm_dc_gate, pm_ic_gate, pm_dmmu_gate,
69
        pm_immu_gate, pm_tt_gate, pm_cpu_gate, pm_wakeup, pm_lvolt
70
);
71
 
72
//
73
// RISC Internal Interface
74
//
75
input           clk;            // Clock
76
input           rst;            // Reset
77
input           pic_wakeup;     // Wakeup from the PIC
78
input           spr_write;      // SPR Read/Write
79
input   [31:0]   spr_addr;       // SPR Address
80
input   [31:0]   spr_dat_i;      // SPR Write Data
81
output  [31:0]   spr_dat_o;      // SPR Read Data
82
 
83
//
84
// Power Management Interface
85
//
86
input           pm_cpustall;    // Stall the CPU
87
output  [3:0]    pm_clksd;       // Clock Slowdown factor
88
output          pm_dc_gate;     // Gate DCache clock
89
output          pm_ic_gate;     // Gate ICache clock
90
output          pm_dmmu_gate;   // Gate DMMU clock
91
output          pm_immu_gate;   // Gate IMMU clock
92
output          pm_tt_gate;     // Gate Tick Timer clock
93
output          pm_cpu_gate;    // Gate main RISC/CPU clock
94
output          pm_wakeup;      // Activate (de-gate) all clocks
95
output          pm_lvolt;       // Lower operating voltage
96
 
97
`ifdef PM_IMPLEMENTED
98
 
99
//
100
// Power Management Register bits
101
//
102
reg     [3:0]    sdf;    // Slow-down factor
103
reg             dme;    // Doze Mode Enable
104
reg             sme;    // Sleep Mode Enable
105
reg             dcge;   // Dynamic Clock Gating Enable
106
 
107
//
108
// Internal wires
109
//
110
wire            pmr_sel; // PMR select
111
 
112
//
113
// PMR address decoder (partial decoder)
114
//
115
`ifdef PM_PARTIAL_DECODING
116
assign pmr_sel = (spr_addr[`SPRGRP_BITS] == `SPRGRP_PM) ? 1'b1 : 1'b0;
117
`else
118
assign pmr_sel = ((spr_addr[`SPRGRP_BITS] == `SPRGRP_PM) &&
119
                  (spr_addr[`SPROFS_BITS] == `PM_OFS_PMR)) ? 1'b1 : 1'b0;
120
`endif
121
 
122
//
123
// Write to PMR and also PMR[DME]/PMR[SME] reset when
124
// pic_wakeup is asserted
125
//
126
always @(posedge clk or posedge rst)
127
        if (rst)
128
                {dcge, sme, dme, sdf} <= 7'b0;
129
        else if (pmr_sel && spr_write) begin
130
                sdf <= #1 spr_dat_i[`PM_PMR_SDF];
131
                dme <= #1 spr_dat_i[`PM_PMR_DME];
132
                sme <= #1 spr_dat_i[`PM_PMR_SME];
133
                dcge <= #1 spr_dat_i[`PM_PMR_DCGE];
134
        end
135
        else if (pic_wakeup) begin
136
                dme <= #1 1'b0;
137
                sme <= #1 1'b0;
138
        end
139
 
140
//
141
// Read PMR
142
//
143
`ifdef PM_READREGS
144
assign spr_dat_o[`PM_PMR_SDF] = sdf;
145
assign spr_dat_o[`PM_PMR_DME] = dme;
146
assign spr_dat_o[`PM_PMR_SME] = sme;
147
assign spr_dat_o[`PM_PMR_DCGE] = dcge;
148
`ifdef PM_UNUSED_ZERO
149
assign spr_dat_o[`PM_PMR_UNUSED] = 25'b0;
150
`endif
151
`endif
152
 
153
//
154
// Generate pm_clksd
155
//
156
assign pm_clksd = sdf;
157
 
158
//
159
// Statically generate all clock gate outputs
160
// TODO: add dynamic clock gating feature
161
//
162
assign pm_cpu_gate = (dme | sme) & ~pic_wakeup;
163
assign pm_dc_gate = pm_cpu_gate;
164
assign pm_ic_gate = pm_cpu_gate;
165
assign pm_dmmu_gate = pm_cpu_gate;
166
assign pm_immu_gate = pm_cpu_gate;
167
assign pm_tt_gate = sme & ~pic_wakeup;
168
 
169
//
170
// Assert pm_wakeup when pic_wakeup is asserted
171
//
172
assign pm_wakeup = pic_wakeup;
173
 
174
//
175
// Assert pm_lvolt when pm_cpu_gate or pm_cpustall are asserted
176
//
177
assign pm_lvolt = pm_cpu_gate | pm_cpustall;
178
 
179
`else
180
 
181
//
182
// When PM is not implemented, drive all outputs as would when PM is disabled
183
//
184
assign pm_clksd = 4'b0;
185
assign pm_cpu_gate = 1'b0;
186
assign pm_dc_gate = 1'b0;
187
assign pm_ic_gate = 1'b0;
188
assign pm_dmmu_gate = 1'b0;
189
assign pm_immu_gate = 1'b0;
190
assign pm_tt_gate = 1'b0;
191
assign pm_wakeup = 1'b1;
192
assign pm_lvolt = 1'b0;
193
 
194
//
195
// Read PMR
196
//
197
`ifdef PM_READREGS
198
assign spr_dat_o[`PM_PMR_SDF] = 4'b0;
199
assign spr_dat_o[`PM_PMR_DME] = 1'b0;
200
assign spr_dat_o[`PM_PMR_SME] = 1'b0;
201
assign spr_dat_o[`PM_PMR_DCGE] = 1'b0;
202
`ifdef PM_UNUSED_ZERO
203
assign spr_dat_o[`PM_PMR_UNUSED] = 25'b0;
204
`endif
205
`endif
206
 
207
`endif
208
 
209
endmodule

powered by: WebSVN 2.1.0

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