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 161

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

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

powered by: WebSVN 2.1.0

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