Sunday, March 9, 2014

Microcontroller Showdown, Conclusion

The last chip in the comparison is the Z16F2810. When I started the tests I got a Loop overhead time of only 0.64, which made me think the chip might be very fast. When I moved on to the multiplication and division tests, though, some of them completed in only 0.89 seconds. After looking at the assembly generated during compilation I noticed that the arguments of division were only being copied to the register that holds the answer. It seems that even though all the variables were declared as volatile, the compiler decided to optimize the division out anyway. This made me think the compiler was simply ignoring the volatile keyword but the assembly generated when accessing volatiles is slightly different. Loops involving them take about 25% longer to run, so it does have an effect. The only way I could prevent it from optimizing out multiplies and divides while keeping optimizations was to declare the involved variables globally. The User Manual for the chip helped a lot when looking at this problem and I think it is really well done.

For arithmetic operations, the chip did very well. It was always faster than the MSP430 and almost as fast as the LPC1114 for most things. One place it did very well was division where it outperformed all the other chips by a large margin because it has a hardware divider. General GPIO is also pretty fast, although it does not have any special mechanism for speeding it up like the masks on the LPC1114 or the constant generator on the MSP430. BCD Add was about the same as the MSP430. BCD Multiply was faster than on the MSP430 but still much slower than on the LPC1114.

After running all the chips, here are my conclusions:
  • MSP430 Easy to use and reasonably fast. Good choice for small jobs and low-power projects. Held back by low clock speed (16MHz), small memory, and lack of hardware multiplier.
  • LPC1114 The fastest chip by far for everything but division and 8 bit math. Lots of RAM and Flash. Straightforward to use, although there is no real community. Very fast GPIO with masks. Top choice for calculations.
  • DS89C450 Fast for 8 bit math, although slow at shifting. Very fast GPIO since each GPIO pin is mapped to its own byte in memory. Extremely slow at BCD calculations. The only real advantage is the external memory bus.
  • AT89LP6440 Similar to the DS89C450 but lower clock speed and performance. 
  • Z16F2810 Good performance but inferior to the LPC1114 in everything but dividing. Debugger is very useful but the IDE itself is sometimes clunky. Enough RAM and very big Flash (128kB). PLCC package is inconvenient.
In the future I plan to do a few more projects that will need the extra horsepower for the LPC1114. For other smaller jobs I will stick with the MSP430.

Results are after the break.
These tests are not a comprehensive benchmark. Many factors have to be taken into account to choose the right chip for a job. These tests only focus on a very narrow range of those factors.
Loop overhead time -O31.720.843.333.331.79
Add unsigned 8 bit -O39.8268.1064.643.86.292.961.796.262.937.15.31
Add unsigned 16 bit -O310.0328.3124.964.1218.0414.718.9218.0714.746.714.92
Add unsigned 32 bit -O329.59227.8724.233.3931.4928.1617.0731.4728.149.297.5
Add signed 8 bit -O39.848.124.633.796.292.961.796.252.927.095.3
Add signed 16 bit -O310.028.34.633.7918.0514.728.9218.0914.766.74.91
Add signed 32 bit -O329.53627.8164.23.3631.4928.1617.0731.4528.129.297.5
Multiply unsigned 8 bit -O319.6517.931.280.445.311.981.24.431.14.152.36
Multiply unsigned 16 bit -O321.1419.421.280.4412.929.595.8110.36.973.641.85
Multiply unsigned 32 bit -O340.3638.641.330.4931.3728.0416.992319.673.761.97
Multiply signed 8 bit -O319.9818.261.390.555.311.981.24.431.15.023.23
Multiply signed 16 bit -O320.6518.931.390.5512.919.585.8110.286.954.512.72
Multiply signed 32 bit -O370.2468.521.230.3931.3828.051722.9419.614.632.84
Divide unsigned 8 bit -O317.3415.628.097.255.442.111.284.681.355.143.35
Divide unsigned 16 bit -O329.4427.721110.1675.4372.143.773.3570.024.632.84
Divide unsigned 32 bit -O390.1288.414.5613.72231.16227.83138.08226.32222.996.64.81
Divide signed 8 bit -O333.2731.559.358.518.264.932.997.243.915.263.47
Divide signed 16 bit -O333.723212.0511.2179.3476.0146.0777.2973.964.752.96
Divide signed 32 bit -O396.9495.2215.514.66231.86228.53138.5227.3223.976.855.06
Shift right unsigned 8 bit -O314.8613.141.830.9917.814.478.7716.0212.695.013.22
Shift right unsigned 16 bit -O329.7928.071.830.9962.8659.5336.0858.9455.614.752.96
Shift right unsigned 32 bit -O369.6267.91.720.88200.46197.13119.47192.1188.775.243.45
Shift right signed 8 bit -O314.8513.132.161.3220.7417.4110.5518.7215.395.013.22
Shift right signed 16 bit -O325.1523.432.161.3267.7664.4339.0563.5960.264.752.96
Shift right signed 32 bit -O359.6957.971.720.88209.38206.05124.88200.68197.355.243.45
Shift left unsigned 8 bit -O314.8613.141.830.9917.8114.488.7816.0312.75.013.22
Shift left unsigned 16 bit -O325.1623.441.830.9962.8659.5336.0858.9655.634.752.96
Shift left unsigned 32 bit -O359.6757.981.720.88200.53197.2119.52192.16188.835.243.45
Shift left signed 8 bit -O314.8613.142.161.3217.814.478.7716.0312.75.013.22
Shift left signed 16 bit -O325.1723.452.161.3262.8859.5536.0958.9755.644.752.96
Shift left signed 32 bit -O359.6857.961.720.88200.55197.22119.53192.21188.885.243.45
GPIO -O318.08816.3687.036.1915.612.277.4415.5512.2211.59.71
GPIO Constant Generator -O314.75213.032
GPIO Masked -O33.222.38
GPIO Bit Operation -O38.264.932.998.244.91
BCD Add 120+325 -O347.9346.2117.9316.2142.4740.68
BCD Add 120+325
Stored in xdata
BCD Add 120+325
Stored in idata
BCD Multiply 24 * 13
Without multiplies
BCD Multiply 24 * 13
Without multiplies, xdata
BCD Multiply 24 * 13
Without multiplies, idata
BCD Multiply 24 * 13
With multiplies
BCD Multiply 24 * 13
With multiplies, xdata
BCD Multiply 24 * 13
With multiplies, idata
-Os 1818.91815.571100.351867.41864.07

No comments:

Post a Comment