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.
| Question | |
|---|---|
| 1 | Which three numbers describe the cost of a power mode? |
| 2 | How do you work out the energy of an idle gap in one mode? |
| 3 | What is the break-even gap between two modes? |
| 4 | When is the deeper mode the wrong choice, although it uses less power? |
| 5 | What 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
| Word | Meaning |
|---|---|
| Idle gap | A stretch of time in which the chip has no work to do. |
| Power mode | A named state of the chip that says which supplies are on and which clocks run. |
| Run mode | Everything on, the clocks running. |
| Sleep mode | The clock of the processor is stopped. All supplies stay on, so all values are kept. |
| Deep sleep mode | The supplies of the processor and of the peripherals are off. Only always-on logic is powered. |
| Idle power | The power that a mode uses while the chip stays in it. |
| Transition energy | The energy to go into a mode and to come out of it again, together. |
| Wake time | The time from a wake event until the chip does useful work again. |
| Wake deadline | The longest wake time that the job of the chip allows. |
| Break-even gap | The 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
- Clock / reset
- Processor
- Peripheral
- Power
- Pads
- 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.
- 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.
- 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.
- 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.
- 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.
| Mode | What stays on | What is lost | What can wake it |
|---|---|---|---|
| Run | Everything | Nothing | It is awake |
| Sleep | Every supply. The core clock is stopped. | Nothing | Any enabled interrupt request |
| Deep sleep | The always-on logic only | Every value in the processor and the peripherals | A wake pin or the RTC alarm |
| Off | Nothing on the chip | Everything | The 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.
| Mode | Transition energy | Idle power | Wake time |
|---|---|---|---|
| Run | 0 nJ | 10 mW | 0 |
| Sleep | 2 nJ | 4 mW | 1 microsecond |
| Deep sleep | 20 nJ | 1 mW | 5 microseconds |
The energy of a mode over a gap is its transition energy, plus its idle power times the gap.
| Gap | Run | Sleep | Deep sleep | Cheaper sleep mode |
|---|---|---|---|---|
| 3 microseconds | 10 x 3 = 30 nJ | 2 + 4 x 3 = 14 nJ | 20 + 1 x 3 = 23 nJ | sleep |
| 6 microseconds | 10 x 6 = 60 nJ | 2 + 4 x 6 = 26 nJ | 20 + 1 x 6 = 26 nJ | a tie |
| 9 microseconds | 10 x 9 = 90 nJ | 2 + 4 x 9 = 38 nJ | 20 + 1 x 9 = 29 nJ | deep 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
Rule 1: A power mode is described by what stays on and by three numbers.
Idle power, transition energy and wake time.
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.
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.
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.
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.
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.
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=0Rule 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 choice | The alternative | What the choice buys, and costs |
|---|---|---|
| Several modes | One sleep mode | A 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 gap | Choose the lowest idle power | The cost of going down and up is counted. The gap must be estimated in advance. |
| Rule out before adding up | Add up first | No 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 sleep | Switch it off too | The 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 section looks ahead. One table of three modes becomes a power plan with many domains. Software picks a mode many times a second.
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.
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.
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.
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
| Name | Meaning |
|---|---|
| gap | The idle gap, in microseconds. The lab writes us for microseconds. |
| run, sleep, deep | The energy of that gap in run mode, in sleep and in deep sleep, in nJ. |
| cheaper | The sleep mode that uses less energy over that gap. |
| extra cost | How much more deep sleep costs to enter and leave than sleep. |
| saved per us | How much less energy deep sleep uses in each microsecond of the gap. |
| wake | The wake time of each mode, and the wake deadline. |
| in time | 1 if the mode wakes within the deadline, 0 if not. |
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=0Check Yourself
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.