Code optimization vs hardware lifespan
W9GFO
Posts: 4,010
I've been wondering how important it is to make nice clean code. Not in terms of readability or ease for others to understand but in terms of being nice to the hardware. After all there are only a finite number of times that you can flip a bit, only so many electrons that can pass through a semiconductor before it fails right?
Suppose two cases. One chip running a couple lines of code to toggle an LED, the other running an absolute mess of code that invokes all eight cogs in a Rube Goldberg fashion using every last bit of processing power and memory space available - yet accomplishes the same simple goal of toggling an LED.
Does it make any difference? Would we have one happy chip with the other chip begrudged at all the extra work?
Reasonably, I would think that the chip running the clean code would outlast the other just because there are so many things happening over and over again that the likelihood of a failure would have to increase.
Rich H
Suppose two cases. One chip running a couple lines of code to toggle an LED, the other running an absolute mess of code that invokes all eight cogs in a Rube Goldberg fashion using every last bit of processing power and memory space available - yet accomplishes the same simple goal of toggling an LED.
Does it make any difference? Would we have one happy chip with the other chip begrudged at all the extra work?
Reasonably, I would think that the chip running the clean code would outlast the other just because there are so many things happening over and over again that the likelihood of a failure would have to increase.
Rich H
Comments
EEPROMs and similar devices have lifetimes in terms of numbers of write / erase cycles, but that's because you're trying to trap electrons within an insulating oxide layer and there's a finite possibility that they'll get stuck there. If the memory goes through too many write cycles, there's a high probability that too many will get stuck over time to be able to properly erase that bit.
Logic chips break down from too high a voltage which destroys the thin gate oxide at some weak point on the chip or the current carried by a conductor is too high and the electron flow itself carries along metal atoms a short distance and eventually conductors break (wear away). It's kind of like a fast creek washing the pebbles lining the creak downstream a little way exposing the underlying dirt or rock.
-Phil
What happens when you have 1 million transistors working together in a chip, how does that affect the MTBF?
Rich H
I will bear that in mind for my next project, a CPU made with relays[noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Ultimately, the reason to tighten your code is that one day you'll need to change it, and you absolutely will not remember just why you did that clever thing you did unless you leave a note to yourself. I constantly get calls along the lines of "You remember that console you built for us in 1996? Well, we need to add X to it." I've done thousands of little applications like that over the years, and the answer to the first question is usualy "Um, no." That is the situation which teaches you that comments and clean layout are your friend.
The greatest enemy of electronics is heat and excessive voltage/voltage spikes.
But it only really applies when there are very large and very rapid current surges
eg a modern X86 can go from standby power to full on in less than a clock cycle which causes
a very rapid 40-50A surge into the chip and under the appropriate conditions this can cause
wiskers to form on the metal powerlines and, should they touch, let the holy smoke out.
Appropriate design practices reduce or eliminate this effect.
For more details, see http://en.wikipedia.org/wiki/Metal_migration
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
Jo
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230