Power Modes and the Energy of a Sleep

A chip can sleep lightly or deeply. The deeper sleep uses less power, and yet it is not always the one that saves energy. The answer depends on how long the chip has nothing to do.

You Will Be Able To

  • Describe a power mode by what stays on, and by its three numbers.
  • Work out the energy of an idle gap in a mode, and the break-even gap between two modes.
  • Rule out a mode that loses a needed value, a wake source or the wake deadline.
Lesson
S5.13
Time
24 min
Runs on
Your browser
Check
6 questions

A team moves its sensor node to the deepest sleep it has. The sleep current falls to a quarter. The battery now lasts a week less, and the node wakes four times a second. What did the measurement of sleep current leave out?

Before You Start

You need Power at Chip Level: a power domain, leakage, and the always-on domain. You need Dividers and Clock Gates: a stopped clock.

You need two facts from school physics. Power is how fast energy is used. Energy is power times time.

Where the power of a chip goes is the first page of the Low Power track: Dynamic, Short-Circuit and Leakage Power. You can follow this page without it.

Five questions this page answers
Question
1Which three numbers describe the cost of a power mode?
2How do you work out the energy of an idle gap in one mode?
3What is the break-even gap between two modes?
4When is the deeper mode the wrong choice, although it uses less power?
5What is checked before any energy is added up?

The Idea: Sleep Has a Price of Admission

A chip in a small device does nothing most of the time. Between two bursts of work there is an idle gap. What the chip does in that gap decides how long the battery lasts.

A power mode is one answer to that question. It is a list: which supplies are on, which clocks run. A deeper mode switches more off. It uses less power while idle.

Nothing is free here. Going into a mode and coming out again costs energy. Supplies must be charged again, blocks reset, values put back. A deeper mode costs more to enter and leave. It also takes longer to wake, and it forgets more.

So the question is not "which mode uses least power". It is "which mode uses least energy over this gap". For a short gap the price of going down and up is never paid back. For a long gap it is. In between is one gap at which two modes cost the same: the break-even gap.

Before any sum there is a harder test. A mode that loses a value the software needs is out. So is a mode in which the wanted wake event cannot be heard, or one that wakes too late.

New Words

New words on this page
WordMeaning
Idle gapA stretch of time in which the chip has no work to do.
Power modeA named state of the chip that says which supplies are on and which clocks run.
Run modeEverything on, the clocks running.
Sleep modeThe clock of the processor is stopped. All supplies stay on, so all values are kept.
Deep sleep modeThe supplies of the processor and of the peripherals are off. Only always-on logic is powered.
Idle powerThe power that a mode uses while the chip stays in it.
Transition energyThe energy to go into a mode and to come out of it again, together.
Wake timeThe time from a wake event until the chip does useful work again.
Wake deadlineThe longest wake time that the job of the chip allows.
Break-even gapThe idle gap at which two modes use the same energy.

Units on this page: power in milliwatts (mW), time in microseconds, energy in nanojoules (nJ). 1 mW for 1 microsecond is 1 nJ.

One Picture: Four Modes

Four Modes: What Stays on in EachStep through the four power modes of our chip, from the lightest to the deepest. Each step shows what is still on.
  • Clock / reset
  • Processor
  • Peripheral
  • Power
  • Pads
Four Modes: What Stays On in EachStep through the four power modes of our chip, from the lightest to the deepest. Each step shows what is still on. component Core clock the clock of theprocessor component Processor andbus on the core supply component Peripherals on the peripheralsupply component Always-on logic power controller, RTCand wake pins component Board the battery and apower button clockbussupply switchsupply switchsupply
  1. component Core clockthe clock of the processor
    • clock → Processor and bus
  2. component Processor and buson the core supply
    • bus → Peripherals
  3. component Peripheralson the peripheral supply
  4. component Always-on logicpower controller, RTC and wake pins
    • supply switch → Processor and bus
    • supply switch → Peripherals
  5. component Boardthe battery and a power button
    • supply → Always-on logic
  1. Run

    Everything is on and the core clock runs. The chip can work at once. It also uses the most power, even while it only waits.

  2. Sleep

    The core clock is stopped. Every supply stays on, so every flip-flop keeps its value. Switching power is gone. Leakage is not. Waking is quick: the clock is started again.

  3. Deep sleep

    The core supply and the peripheral supply are switched off. Their values are lost. Only the always-on logic is left. Waking means: switch on, reset, start again.

  4. Off

    The board cuts the supply of the chip. Nothing on the chip can wake it. A person presses the power button, and the chip boots from cold.

  5. Deeper is cheaper to stay in

    Each step down uses less power while idle. Each step down also loses more, takes longer to leave and costs more energy to go in and out.

Read the diagram as text
  • Core clock: the clock of the processor
  • Processor and bus: on the core supply
  • Peripherals: on the peripheral supply
  • Always-on logic: power controller, RTC and wake pins
  • Board: the battery and a power button
  • Core clock → Processor and bus: clock
  • Processor and bus → Peripherals: bus
  • Always-on logic → Processor and bus: supply switch
  • Always-on logic → Peripherals: supply switch
  • Board → Always-on logic: supply

The four power modes of ap_soc. The names and the split are choices of our chip. Another chip may give the same name to a different set of supplies.

The four modes of ap_soc
ModeWhat stays onWhat is lostWhat can wake it
RunEverythingNothingIt is awake
SleepEvery supply. The core clock is stopped.NothingAny enabled interrupt request
Deep sleepThe always-on logic onlyEvery value in the processor and the peripheralsA wake pin or the RTC alarm
OffNothing on the chipEverythingThe power button on the board

The Smallest Example, Worked by Hand

Compare three modes over one idle gap. The numbers below are exercise values, chosen to be easy to add. They are not measurements of a chip.

Three modes and their three numbers
ModeTransition energyIdle powerWake time
Run0 nJ10 mW0
Sleep2 nJ4 mW1 microsecond
Deep sleep20 nJ1 mW5 microseconds

The energy of a mode over a gap is its transition energy, plus its idle power times the gap.

The energy of three idle gaps, by hand
GapRunSleepDeep sleepCheaper sleep mode
3 microseconds10 x 3 = 30 nJ2 + 4 x 3 = 14 nJ20 + 1 x 3 = 23 nJsleep
6 microseconds10 x 6 = 60 nJ2 + 4 x 6 = 26 nJ20 + 1 x 6 = 26 nJa tie
9 microseconds10 x 9 = 90 nJ2 + 4 x 9 = 38 nJ20 + 1 x 9 = 29 nJdeep sleep

Deep sleep costs 18 nJ more to enter and leave than sleep: 20 minus 2. It uses 3 mW less while idle: 4 minus 1. So it pays back 3 nJ in each microsecond. After 18 / 3 = 6 microseconds the two are level. That is the break-even gap.

Now add a wake deadline of 3 microseconds. Sleep wakes in 1 and is in time. Deep sleep needs 5 and is too late. For this job deep sleep is out, at every gap. The table of energies no longer matters for it.

The Rules

  1. Rule 1: A power mode is described by what stays on and by three numbers.

    Idle power, transition energy and wake time.

  2. Rule 2: Rule out first.

    A mode is out if it loses a needed value, cannot hear the wanted wake event, or misses the wake deadline.

  3. Rule 3: The energy of a gap is transition energy plus idle power times the gap.

    Measure the whole gap, from the last useful work to the next.

  4. Rule 4: The break-even gap is the extra transition energy divided by the idle power saved.

    Both differences are taken between the same two modes.

  5. Rule 5: Below the break-even gap the lighter mode wins. Above it the deeper mode wins.

    So the choice needs an estimate of the gap.

  6. Rule 6: Wake time ends at the first useful work.

    A supply that is back up is only one stop on the way.

Sources for These Rules

Going into and out of a switched-off state takes time and energy. So switching off pays only for a long enough gap: Weste and Harris, CMOS VLSI Design, fourth edition, section 5.3.2.

Rules 3 and 4 are arithmetic on the definition of energy. Rule 4 follows from setting the two sums of rule 3 equal.

The four modes and their names are choices of ap_soc. Every number in the tables is an exercise value.

Now Run It

The lab at the end of this page is a calculator. It holds the table of three modes as constants and adds up three gaps. It simulates no circuit. Its use is that you can change a number and see the answer move.

Printed by the lab on Icarus. The lab writes us for microseconds. All values are exercise values.
gap=3us run=30nJ sleep=14nJ deep=23nJ cheaper=sleep
gap=6us run=60nJ sleep=26nJ deep=26nJ cheaper=tie
gap=9us run=90nJ sleep=38nJ deep=29nJ cheaper=deep
extra cost=18nJ saved per us=3nJ
break-even gap=6us
wake: sleep=1us deep=5us deadline=3us
in time: sleep=1 deep=0

Rule 3 at work, in the first three rows. They are the three rows of the hand table: 14 against 23, then 26 against 26, then 38 against 29.

Rule 4 at work, in the next two rows. An extra cost of 18 nJ, paid back at 3 nJ in each microsecond, gives a break-even gap of 6.

Rule 5 at work, in the word after "cheaper": sleep at 3, a tie at 6, deep sleep at 9.

Rule 2 at work, in the last row. Against a deadline of 3 microseconds sleep is in time and deep sleep is not.

This lab leaves nearly everything out, and says so. A real transition energy is measured on the supply of a chip, not typed in. Real gaps are milliseconds to hours, and real modes differ by a factor of a thousand and more. The method is the same.

Why It Is Built This Way

Design choiceThe alternativeWhat the choice buys, and costs
Several modesOne sleep modeA good answer for a short gap and for a long one. Software must choose, and each mode must be tested.
Choose by energy over the gapChoose the lowest idle powerThe cost of going down and up is counted. The gap must be estimated in advance.
Rule out before adding upAdd up firstNo time is spent on a mode that cannot do the job. The needs of the job must be written down.
Keep the RTC on in deep sleepSwitch it off tooThe chip can wake itself at a set time. The RTC adds to the idle power of the mode.

The Trap: The Lowest Sleep Current

Back to the sensor node. Its team measured one number: the current while asleep. Deep sleep cut it to a quarter, so they shipped deep sleep.

The node wakes four times a second. Each time it pays to charge its supplies again, to reset and to start up. The gaps are far shorter than the break-even gap. The node now spends most of its energy going to sleep and waking.

A second trap is hidden in rule 6. A team times the wake of deep sleep to the moment the supply is back. That takes 2 microseconds, inside the deadline. The first useful instruction runs 3 microseconds later, after the reset and the start-up code. The deadline was missed all along.

A third trap is rule 2 read too late. A mode is chosen for its energy. In the field the device sleeps through its alarm. The block that raises the alarm was in a domain that the mode switches off.

At Scale

This page3 modes, 1 gap
A phone chipdozens of domains, each with modes

This section looks ahead. One table of three modes becomes a power plan with many domains. Software picks a mode many times a second.

  1. Software guesses the gap

    An operating system looks at its next timer and at recent gaps. From them it picks a mode for each idle period.

  2. Each domain has its own modes

    A camera block can be off while the processor only sleeps. The legal combinations are written down as a table of power states.

  3. Finish fast, then sleep

    Sometimes running faster and sleeping longer uses less energy than running slowly. Architecture Trade-offs in the Low Power track works an example.

  4. What a sleep looks like in logic

    The lightest mode, a stopped clock, has a page of its own: Sleep and Wake.

Try It

Run the lab. It is a calculator: it adds up the numbers of one table for three idle gaps, in three modes.

Halve the cost of deep sleep: change DEEP_COST from 20 to 11. Where is the break-even gap now?

Raise the deadline from 3 to 5 microseconds. Which mode is in time now?

Names Printed by the Lab
NameMeaning
gapThe idle gap, in microseconds. The lab writes us for microseconds.
run, sleep, deepThe energy of that gap in run mode, in sleep and in deep sleep, in nJ.
cheaperThe sleep mode that uses less energy over that gap.
extra costHow much more deep sleep costs to enter and leave than sleep.
saved per usHow much less energy deep sleep uses in each microsecond of the gap.
wakeThe wake time of each mode, and the wake deadline.
in time1 if the mode wakes within the deadline, 0 if not.
RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: gap=3us run=30nJ sleep=14nJ deep=23nJ cheaper=sleep gap=6us run=60nJ sleep=26nJ deep=26nJ cheaper=tie gap=9us run=90nJ sleep=38nJ deep=29nJ cheaper=deep extra cost=18nJ saved per us=3nJ break-even gap=6us wake: sleep=1us deep=5us deadline=3us in time: sleep=1 deep=0

Check Yourself

Predict the outputIn this run the idle gap is 12 microseconds. Run mode uses 10 mW. Sleep costs 2 nJ and uses 4 mW. Deep sleep costs 20 nJ and uses 1 mW. What is the first row the lab prints?
module tb;
  // Exercise values. Power in mW. Energy in nJ. Time in us. 1 mW for 1 us is 1 nJ.
  localparam int RUN_POWER = 10;                // awake and waiting
  localparam int SLEEP_COST = 2, SLEEP_POWER = 4, SLEEP_WAKE = 1;   // going in and out, idle power, time to wake
  localparam int DEEP_COST = 20, DEEP_POWER = 1, DEEP_WAKE = 5;

  function automatic string cheaper(input int a, input int b);
    return a < b ? "sleep" : a > b ? "deep" : "tie";
  endfunction
  task automatic gap(input int us);
    int stay = RUN_POWER * us, light = SLEEP_COST + SLEEP_POWER * us, heavy = DEEP_COST + DEEP_POWER * us;
    $display("gap=%0dus run=%0dnJ sleep=%0dnJ deep=%0dnJ cheaper=%s", us, stay, light, heavy, cheaper(light, heavy));
  endtask
  initial begin
    gap(12);
    // Deep sleep pays back when its extra cost equals what its lower power has saved.
    $display("extra cost=%0dnJ saved per us=%0dnJ", DEEP_COST - SLEEP_COST, SLEEP_POWER - DEEP_POWER);
    $display("break-even gap=%0dus", (DEEP_COST - SLEEP_COST) / (SLEEP_POWER - DEEP_POWER));
    $display("wake: sleep=%0dus deep=%0dus deadline=%0dus", SLEEP_WAKE, DEEP_WAKE, 3);
    $display("in time: sleep=%0d deep=%0d", SLEEP_WAKE <= 3, DEEP_WAKE <= 3);
    $finish;
  end
endmodule
ConceptWhich three numbers describe the cost of a power mode?
ConceptHow do you work out the energy of an idle gap in one mode?
ConceptWhat is the break-even gap between two modes?
ConceptWhen is the deeper mode the wrong choice, although it uses less idle power?
ConceptWhat is checked before any energy is added up?

Common Mistakes

Wrong Pick the mode with the lowest idle power.

For a short gap its transition energy is never paid back.

Fix Add up the energy of the whole gap in each mode.

Wrong Add up energies first, and check the needs of the job later.

The cheapest mode may lose a value, a wake source or the deadline.

Fix Rule such modes out before any sum.

Wrong Stop the wake timer when the supply is back.

Reset and start-up code still have to run.

Fix Time the wake to the first useful work.

Remember

  • A power mode is a list of what stays on, with three numbers: idle power, transition energy and wake time.
  • Energy of a gap = transition energy + idle power x gap.
  • Break-even gap = extra transition energy / idle power saved. Below it the lighter mode wins.
  • First rule out every mode that loses a needed value, a wake source or the wake deadline.

Practice

Report a problem with this page