BeginnerQuestion 45 of 50

What is Gray code addressing, and why does it reduce switching power compared to binary counting?

From PDVerse Low-Power Physical Design Mentor Guide, part of the pdVerse Mentor Guide

Short Answer

In Gray code, consecutive values differ in exactly one bit, while a binary increment can flip many bits at once. For counters and address buses that step sequentially, that keeps toggles to one per step and cuts switching power, as long as the value really does move by one each time.

Technical Reference DiagramWhat is Gray code addressing, and why does it reduce switching power compared to binary counting?

Technical Explanation

  • Binary counting flips several bits at carry boundaries: 0111 to 1000 flips all four.
  • On average a binary counter flips about two bits per increment; Gray code flips exactly one.
  • Each address wire has real capacitance, so fewer toggles means less dynamic power.
  • Conversion is cheap: gray = bin XOR (bin >> 1).
  • Decoding back to binary is slower: each binary bit is the XOR of its own Gray bit and all higher ones, a chain rather than one gate.
  • Gray code also helps safe clock-domain crossing of FIFO pointers, since only one bit changes at a time.
  • The benefit only holds for sequential access; random addresses gain nothing.

Common Mistake

The Trap: Using Gray code on a bus whose values jump around, such as a random-access cache address.

  • Non-sequential steps flip as many bits as binary, so you pay the conversion logic for no saving.
  • The same happens when a sequential pointer jumps, for example on a flush or a reload, because that jump flips several bits at once.

Follow-up Question & Model Response

"Why not use Gray code for every counter?"

Candidate Model Response: Anything that does arithmetic on the value, such as adding an offset, needs it back in binary first. That conversion costs logic and delay. For a counter that only increments and is compared or decoded, Gray is a cheap win. For values used in math, the conversion can eat the saving. Asynchronous FIFO pointers are the classic case where both benefits, low power and safe crossing, land at once.

Practical Example

Design Scenario: (illustrative) A 3-bit address walks 0 to 7 and wraps. Binary toggles per step: 1, 2, 1, 3, 1, 2, 1, then 3 on the wrap, 14 in total. Gray code (000, 001, 011, 010, 110, 111, 101, 100) toggles once per step, 8 in total, about 43% fewer toggles. The 3-bit encoder costs just two XOR gates. For a 10-bit address walking a 1024-entry buffer, binary averages close to 2 toggles per step against exactly 1 for Gray, so address-bus switching roughly halves. Wider values show the carry problem most: 01111111 to 10000000 flips all 8 binary bits but still only one Gray bit.

Low-Power & UPF Handbook

Read the complete low-power guide library covering power domains, level shifters, isolation clamps, state retention, and UPF signoff verification.

Offline PDF Bundle

Want all 1109 questions offline?

Get the complete 4-book PDF bundle (PnR, STA, MMMC, Low Power) with a clickable table of contents - no ads, no internet needed.

See what's inside the bundle
Low-Power VLSI & UPF Handbook โ€” nine chaptersLow-Power & UPFDomains, isolation, retention, and multivoltage UPF.