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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [pm.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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