This algorithm is also very simple. All bits of 32 bit number are summed together and checked if accumulated sum is '1' or not. This algorithm is implemented as series of 1-bit full adders in hardware. Following is the code snippet for this algorithm.
|Adding All 1s in Number|
If implemented in ANSI-C, loop will run 32 times. All bits are added together and result is checked if it is one or not. Number of cycles taken arek*32 (Where k is arbitrary constant). HW performance is
- Code Size – 21 (Less the better)
- Complexity – 9/10 on simplicity scale. (More the better – Little Subjective)
- Basic Gate Count & Timing – Area is 1813 micron2 (Less the better), Critical Path Delay 4.32ns(Less the better)
- Optimizable – Area is 3885 micron2(Less the better), Critical Path Delay 2.62ns (Less the better)
Next: Design Implementation 3 – Nifty & Cute