Algorithmadvanced
Clustered voltage scaling
Also called CVS, Usami-Horowitz voltage scaling.
Usami and Horowitz's method that moves gates with slack to a low supply, growing clusters back from the outputs so that level converters are needed only at the registers.
- Time
- O(n (n + m)) worst
- Space
- O(n + m) extra
- Where
- m = the number of gate input pins; n = the number of gates
- Model
- Word RAM
- Properties
- deterministicnot exactgreedyiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Kimiyoshi Usami, Mark Horowitz, 1995
Clustered voltage scaling (CVS) is a method to lower the dynamic power of a synchronous circuit with two supply voltages, a high one and a low one . Since , a gate moved to spends of its old switching power, but it is slower. CVS moves gates that have timing slack to . It keeps the rule that a low gate never drives a high gate, because a high gate driven by a low signal can draw static current. So the low gates form clusters at the ends of the paths, next to the registers, and only the registers need level converters. The method visits the gates from the outputs back to the inputs, tries each gate whose fanouts are all low, and keeps it low when the circuit still meets the clock period. Usami and Horowitz gave it in 1995. Under a simple additive delay model this page proves that the greedy result is the largest legal set that meets the clock period and so is optimal. With real delay models it is a heuristic.
In plain words
A chip can have two supply rails, one at a high voltage and one at a low voltage. Gates on the low rail use much less energy per switch, but they are slower. Many gates are not on the slowest paths, so they can afford to be slower.
There is a catch. When a low-voltage gate drives a high-voltage gate, the high gate does not switch off fully and wastes current. So the low gates must sit at the ends of the paths, where they feed the registers, and the registers convert the level back.
CVS starts at the registers at the end of the logic and walks back. It tries to move each gate to the low rail when all the gates it drives are already low. If the circuit is still fast enough, the gate stays low.
The problem
Circuit. The logic between registers is a DAG of gates with gate input pins. The primary inputs come from registers clocked at time 0 at . A set of gates drive registers. Each gate has a switched capacitance , an activity , a delay at and a delay at . A register driven by a low gate is a level-converting register and adds a delay .
Delay model. This page uses an additive model in which the delay of a gate depends only on its own supply. For a set of low gates, the arrival time is over the fanins of , with at the primary inputs and if and otherwise. The circuit meets the clock period when for every . This is the timing of static timing analysis with fixed gate delays, a longest path in the DAG.
Legality. A set is legal when no gate of drives a gate outside .
Goal. Find a legal set that meets and has the largest saving .
Physical numbers. How much slower a low gate is follows the alpha-power law of Sakurai and Newton (1990): the delay of a gate is about proportional to . The threshold and the exponent are fitted to the transistors of a process. The exponent is near 2 for long channels and between 1 and 1.5 for short channels. The capacitances come from extraction, and the activities from switching activity estimation. The level converter delay is a characterized cell value.
The algorithm
CVS(circuit, T, ℓc)- 1
L ← ∅; if the circuit misses T with every gate high then fail - 2
for each gate g in reverse topological order do - 3
if every gate driven by g is in L then - 4
L ← L ∪ {g} - 5
if some output o has a(o) + ℓc [o ∈ L] > T then - 6
L ← L − {g} - 7
return L
Line L2 visits each gate after all the gates that it drives. Line L3 keeps the set legal. Line L5 is a full timing check, or an incremental one that updates the arrival times in the fanout cone of .
Example
Take V, V, V and . The alpha-power law gives a delay ratio of . For the ratio would be 1.17, and for it would be 2.04, which shows how much the fitted exponent matters. The power ratio is , so each low gate saves 56% of its switching power.
For a check by hand, the circuit below uses whole numbers for the delays. The inputs and come from registers. The gate is driven by , by , by , by and , and by . The outputs are and . The level converter adds , and .
| gate | |||
|---|---|---|---|
| 2 | 3 | 2 | |
| 2 | 3 | 2 | |
| 1 | 2 | 3 | |
| 2 | 3 | 2 | |
| 1 | 2 | 1 |
With every gate high, the longest path takes 6, so line L1 passes. The reverse topological order is .
| gate | line L3 | worst output time with low | result |
|---|---|---|---|
| an output, no gate fanout | low | ||
| an output, no gate fanout | low | ||
| and are low | low | ||
| is low | back to high | ||
| is high | not tried | high |
The result is with switched capacitance 6 of 10. If all gates have the same activity, the switching power falls from 10 units to , a saving of 33%, before the cost of the converters. A search over all 32 subsets confirms that no legal set that meets saves more.
Correctness
Two invariants hold after each pass of lines L2 to L6: is legal, since line L4 adds a gate only when all of its gate fanouts are in already, and meets , since line L6 undoes any addition that breaks it. So the result is legal and meets . It is also maximal: a gate that line L6 removed would still miss if added to the final set, because adding low gates never makes a path faster.
Under the additive model more is true, and the proof file gives the details. In a legal set, the low gates on any path form a suffix of it, so the delay of a path under equals its delay under or under . Hence the legal sets that meet are closed under union, and there is a largest one. The greedy returns exactly this largest set, so it is optimal for every choice of the nonnegative weights , and the order among gates with no path between them does not matter.
Why the rule. A static CMOS gate on whose input is driven high by a gate on sees the gate voltage at its PMOS transistor, whose source is at . The PMOS then has , and it conducts when , while the NMOS also conducts. The current flows from to ground as long as the input stays high. In the example V is more than a threshold of 0.4 V. A level-converting register restores the full swing with a cross-coupled pair of PMOS transistors.
Proof: Clustered voltage scaling returns a legal timed set, and under additive delays the largest onefull
Setting. The circuit is a DAG of gates with primary inputs at time 0, a set of output gates that drive registers, delays and a converter delay . For a set of low gates, applies to the gates of and to the others. The delay of a path from a gate driven by a primary input to an output gate is
The worst output time equals over all such paths, by the usual longest path recursion. meets when , and is legal when every gate fanout of every gate of is in . Call feasible when it is legal and meets .
Lemma 1 (monotone delay). If then .
Proof. For each path, is a sum of terms and possibly . Take the maximum over paths.
Lemma 2 (invariants). After each pass of lines L2 to L6, is feasible.
Proof. At line L1, is legal, and it meets by the check of line L1. Line L4 adds only when every gate driven by is in , so is legal: the gates of keep their fanouts in , and has its fanouts in . If misses , line L6 returns to .
Lemma 3 (suffix). If is legal and is a path of gates, then is a set of the form , possibly empty.
Proof. If and , then is a gate driven by , so by legality.
Lemma 4 (union). If and are feasible, so is .
Proof. Legality: each gate of lies in or in , and its gate fanouts lie in the same set. Timing: fix a path . By Lemma 3 its low gates under are a suffix starting at , and under a suffix starting at (with for an empty suffix). Its low gates under are the union of the two suffixes, which is the longer one. Say . Then has the same low gates under as under . The delay depends only on which gates of are in , since each gate's delay depends only on its own supply and the converter term only on . So . The case is the same with . Taking the maximum over paths gives .
So if any feasible set exists, the union of all feasible sets is feasible, and it is the largest feasible set .
Theorem. If the circuit meets with every gate high, line L7 returns .
Proof. Let be the returned set. By Lemma 2, is feasible, so . Suppose that . Let be the first gate of in the order of line L2, and let be the value of when line L2 reaches .
Every gate driven by is in by legality of . The order of line L2 is reverse topological, so comes before . Since is the first gate of that is missing from , the gate is in . A gate is added to only at line L4 and is removed only at line L6 in the same pass, so a gate of that comes before is in . So every gate driven by is in , the test of line L3 holds, and line L4 tries . Since , line L5 found .
But is feasible by Lemma 2 and is feasible, so is feasible by Lemma 4. Since , we have , and Lemma 1 gives . This contradicts the result of line L5. So , and .
Corollary. For any nonnegative weights , such as , the result has the largest total weight among all feasible sets, and every reverse topological order gives the same result.
Proof. Every feasible set is a subset of , and the weights are nonnegative. The set does not depend on the order.
Where the proof stops. Lemma 4 uses that the delay of a gate depends only on its own supply. If the delay of also depends on the supply of its driver, through the input slope, or on the supplies of the gates it drives, through their input capacitance, the delay of a path is no longer fixed by its set of low gates alone, Lemma 4 can fail, and the greedy is then only a heuristic. The tests check the theorem on random circuits of up to 9 gates against all subsets.
Why the rule is needed (physics, not a theorem of this page). In static CMOS, a gate on whose input is high at has a PMOS transistor with its source at and its gate at , so . The PMOS conducts when , while the NMOS of the same input also conducts, so a static current flows from to ground. A low input to a low gate, or a high gate driving a low gate, has no such problem, since a high level at turns the PMOS of a low gate fully off.
Complexity
Line L5 runs once per gate. A full timing pass costs , so the total is time, with space for the arrival times and the fanout lists. Incremental timing updates only the fanout cone of the new gate, which is often small, but the worst case stays the same.
Properties
- Legal and timed, proved. The result never has a low gate driving a high gate, and it meets .
- Optimal under the additive model, proved here. The result contains every legal set that meets , so it is the most power saving one for any nonnegative weights. This proof is not in the paper of Usami and Horowitz.
- A heuristic under real delay models. With delays that depend on the load and on the input slope, a low driver slows the gates it drives, and the union property can fail. Then the result depends on the order and can be worse than the best legal set.
- Measured savings. The power savings reported by Usami and Horowitz (1995) and by Usami and coworkers (1998) are measured on their circuits, not proved. They also depend on how much slack the circuit has, which is a property of the design.
- Converters only at registers. Since a low cluster ends at the registers, the only level converters are in the registers, which keeps the cost of the converters small.
Variants and improvements
- Level converters inside the logic. Later work allows a converter on any edge from a low gate to a high gate, at a cost in delay, area and power. Then more gates can go low, but the choice becomes a harder search, and the legal sets are no longer closed under union.
- Gate sizing at the same time. A gate that misses timing at can be made faster by a larger size, as in gate sizing and TILOS. Joint methods trade the two moves against each other.
- Threshold voltage as a third choice. The same structure of a choice per gate under a timing bound appears in multiple threshold voltage assignment, which lowers leakage instead of switching power. Flows often run both.
- Voltage per block and per time. Coarser schemes give a whole block one supply, which needs fewer converters and simpler rails. Speed scaling changes the supply and the clock over time instead of over gates.
When to use it
Use it on synchronous logic with much slack off the critical paths, when the process and the library offer two supplies and level-converting registers. The gain is large when many gates feed the registers through short paths, as in datapaths with a few long paths. It gives little on a circuit in which most paths are near critical, and it needs a placement that can reach both supply rails.
Pitfalls
- Breaking the rule at a fanout stem. A gate that drives both a low gate and a high gate cannot go low. Line L3 checks all gate fanouts, not only the one on the critical path.
- Forgetting the converter delay. A low output adds at the register. Without it, the timing check passes and the chip fails.
- Trusting the fixed-delay model. In a real library, a slower low driver also slows its fanout gates through the input slope. Rerun full timing with the real model on the result.
- Hold time. Low gates are slower, which helps hold time, but the converter registers have their own setup and hold times. Check setup and hold on every converter register.
- Counting the saving in the wrong units. The saving per gate is with the rising transitions per cycle, as on the dynamic power page. Leakage changes too, since it falls with the supply, but it is a separate term.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/clustered-voltage-scaling/. The authors are listed in prov/STT7KY.jsonl.
"""Clustered voltage scaling (Usami and Horowitz 1995).
The logic between registers is a DAG of gates. Each gate has a delay at the
high supply and a larger delay at the low supply, and a switched capacitance.
The primary inputs come from registers at time 0. The outputs go to
level-converting registers, which add the delay lc when their driver is low.
The clock period is T.
Legal: no low gate drives a high gate. The pass visits the gates in reverse
topological order. A gate whose gate fanouts are all low already is tried at
the low supply, and stays low when every output still meets T.
"""
from __future__ import annotations
import random
from typing import Dict, Iterable, List, Sequence, Set, Tuple
class Net:
"""inputs: names; gates: (name, fanins, d_high, d_low, cap) in topological order; outputs: gate names."""
def __init__(self, inputs: Sequence[str], gates: Sequence[Tuple[str, Sequence[str], float, float, float]], outputs: Sequence[str]):
self.inputs = list(inputs)
self.gates = [g[0] for g in gates]
self.fanin = {g[0]: list(g[1]) for g in gates}
self.d_high = {g[0]: g[2] for g in gates}
self.d_low = {g[0]: g[3] for g in gates}
self.cap = {g[0]: g[4] for g in gates}
self.outputs = list(outputs)
self.fanout: Dict[str, List[str]] = {g: [] for g in self.gates}
for g in self.gates:
for f in self.fanin[g]:
if f in self.fanout:
self.fanout[f].append(g)
def arrival(net: Net, low: Set[str]) -> Dict[str, float]:
a: Dict[str, float] = {x: 0 for x in net.inputs}
for g in net.gates:
d = net.d_low[g] if g in low else net.d_high[g]
a[g] = max((a[f] for f in net.fanin[g]), default=0) + d
return a
def worst_output_time(net: Net, low: Set[str], lc: float) -> float:
a = arrival(net, low)
return max(a[o] + (lc if o in low else 0) for o in net.outputs)
def meets_timing(net: Net, low: Set[str], period: float, lc: float) -> bool:
return worst_output_time(net, low, lc) <= period
def is_legal(net: Net, low: Set[str]) -> bool:
"""No low gate drives a high gate."""
return all(f in low for g in low for f in net.fanout[g])
def saving(net: Net, low: Iterable[str]) -> float:
"""Switched capacitance moved to the low supply (the power saving is this times alpha f (VH^2 - VL^2))."""
return sum(net.cap[g] for g in low)
def cvs(net: Net, period: float, lc: float) -> Set[str]:
"""The set of low gates chosen by clustered voltage scaling."""
low: Set[str] = set() # @line L1
if not meets_timing(net, low, period, lc):
raise ValueError("the circuit misses the period with every gate high")
for g in reversed(net.gates): # @line L2: reverse topological order
if all(f in low for f in net.fanout[g]): # @line L3
low.add(g) # @line L4
if not meets_timing(net, low, period, lc): # @line L5
low.discard(g) # @line L6
return low # @line L7
def random_net(rng: random.Random, n_in: int, n_gates: int) -> Net:
inputs = [f"i{k}" for k in range(n_in)]
names = list(inputs)
gates = []
for k in range(n_gates):
fanins = rng.sample(names, min(len(names), rng.randint(1, 2)))
dh = rng.randint(1, 3)
gates.append((f"g{k}", fanins, dh, dh + rng.randint(1, 2), rng.randint(1, 5)))
names.append(f"g{k}")
used = {f for g in gates for f in g[1]}
outputs = [g[0] for g in gates if g[0] not in used]
outputs += [g[0] for g in gates if g[0] in used and rng.random() < 0.2]
return Net(inputs, gates, outputs)
test_clustered_voltage_scaling.py 90 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/clustered-voltage-scaling/. The authors are listed in prov/STT7KY.jsonl.
import itertools
import random
import pytest
from clustered_voltage_scaling import Net, cvs, is_legal, meets_timing, random_net, saving, worst_output_time
def page_net():
# a -> g1 -> g2 -> g4 (output); b -> g3 -> g4; g3 -> g5 (output). Delays (high, low), cap.
return Net(
["a", "b"],
[
("g1", ["a"], 2, 3, 2),
("g2", ["g1"], 2, 3, 2),
("g3", ["b"], 1, 2, 3),
("g4", ["g2", "g3"], 2, 3, 2),
("g5", ["g3"], 1, 2, 1),
],
["g4", "g5"],
)
def all_feasible(net, period, lc):
for r in range(len(net.gates) + 1):
for s in itertools.combinations(net.gates, r):
s = set(s)
if is_legal(net, s) and meets_timing(net, s, period, lc):
yield s
def test_page_example():
net = page_net()
assert worst_output_time(net, set(), 1) == 6
low = cvs(net, 8, 1)
assert low == {"g4", "g5", "g3"}
assert worst_output_time(net, low, 1) == 8
best = max(all_feasible(net, 8, 1), key=lambda s: saving(net, s))
assert saving(net, best) == saving(net, low) == 6
def test_legal_timed_and_maximal_against_brute_force():
rng = random.Random(31)
for _ in range(150):
net = random_net(rng, rng.randint(1, 3), rng.randint(2, 8))
lc = rng.randint(0, 1)
period = worst_output_time(net, set(), lc) + rng.randint(0, 4)
low = cvs(net, period, lc)
assert is_legal(net, low)
assert meets_timing(net, low, period, lc)
# maximal: no single high gate can join and keep both properties
for g in net.gates:
if g not in low:
s = low | {g}
assert not (is_legal(net, s) and meets_timing(net, s, period, lc))
best = max(saving(net, s) for s in all_feasible(net, period, lc))
assert saving(net, low) <= best
def test_result_contains_every_legal_timed_set():
# Under the additive delay model the legal timed sets are closed under union,
# and the pass returns the largest one, so it is optimal for any weights.
rng = random.Random(32)
for _ in range(200):
net = random_net(rng, rng.randint(1, 3), rng.randint(2, 9))
lc = rng.randint(0, 2)
period = worst_output_time(net, set(), lc) + rng.randint(0, 5)
low = cvs(net, period, lc)
feasible = list(all_feasible(net, period, lc))
for s in feasible:
assert s <= low
for s, t in itertools.combinations(feasible[:40], 2):
u = s | t
assert is_legal(net, u) and meets_timing(net, u, period, lc)
def test_fanout_stem_goes_low_only_after_all_its_fanouts():
# g1 drives g2 and g3. With period 3 only the two outputs fit at the low
# supply; with period 4 the stem g1 joins them.
net = Net(["a"], [("g1", ["a"], 1, 2, 5), ("g2", ["g1"], 1, 2, 1), ("g3", ["g1"], 1, 2, 1)], ["g2", "g3"])
assert cvs(net, 3, 0) == {"g2", "g3"}
assert cvs(net, 4, 0) == {"g1", "g2", "g3"}
def test_infeasible_period_raises():
with pytest.raises(ValueError):
cvs(page_net(), 5, 1)
History
Chandrakasan, Sheng and Brodersen (1992) showed that the supply voltage is the strongest lever on CMOS power, because power falls with its square while delay grows more slowly. Usami and Horowitz (1995) applied this inside one circuit, with a second supply for the gates that have slack, and with the rule that clusters of low gates end at registers. Usami and coworkers at Toshiba (1998) built an automated flow around it for a media processor, and later work allowed converters inside the logic and combined the supply choice with sizing and with the threshold voltage.
References
- Kimiyoshi Usami and Mark Horowitz, Clustered voltage scaling technique for low-power design, Proceedings of the International Symposium on Low Power Design, 3 to 8, 1995, the two supplies, the rule that a low gate drives only low gates, the backward search from the outputs, and the level-converting flip-flops
- Kimiyoshi Usami, Mototsugu Igarashi, Fujio Minami, Takashi Ishikawa, Masahiro Kanazawa, Makoto Ichida and Kazutaka Nogami, Automated low-power technique exploiting multiple supply voltages applied to a media processor, IEEE Journal of Solid-State Circuits 33(3), March 1998, the automated flow with two supplies on a media processor, with the level-converting flip-flop and the layout of the two supply rails
- Takayasu Sakurai and A. Richard Newton, Alpha-power law MOSFET model and its applications to CMOS inverter delay and other formulas, IEEE Journal of Solid-State Circuits 25(2), 584 to 594, April 1990, the drain current model with the fitted exponent alpha and the inverter delay that follows from it
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag STT7KY Edit this page History Report an error Markdown