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.
MSP430G2553LPC1114DS89C450AT89LP6440Z16F2810
Loop overhead time -O31.720.843.333.331.79
-Os1.720.913.33(20MHz)(33MHz)3.331.79
Add unsigned 8 bit -O39.8268.1064.643.86.292.961.796.262.937.15.31
-Os9.8898.1694.843.936.242.911.766.252.927.15.31
Add unsigned 16 bit -O310.0328.3124.964.1218.0414.718.9218.0714.746.714.92
-Os10.0718.3515.154.2417.9214.598.8418.0514.726.714.92
Add unsigned 32 bit -O329.59227.8724.233.3931.4928.1617.0731.4728.149.297.5
-Os29.81628.0964.383.4731.327.9716.9531.4228.099.297.5
Add signed 8 bit -O39.848.124.633.796.292.961.796.252.927.095.3
-Os9.9098.1894.823.916.242.911.766.252.927.15.31
Add signed 16 bit -O310.028.34.633.7918.0514.728.9218.0914.766.74.91
-Os10.0548.3345.154.2417.9214.598.8418.0514.726.714.92
Add signed 32 bit -O329.53627.8164.23.3631.4928.1617.0731.4528.129.297.5
-Os29.63727.9174.383.4731.3127.9816.9631.4428.119.297.5
Multiply unsigned 8 bit -O319.6517.931.280.445.311.981.24.431.14.152.36
-Os19.5817.861.410.55.281.951.184.421.094.152.36
Multiply unsigned 16 bit -O321.1419.421.280.4412.929.595.8110.36.973.641.85
-Os21.0719.351.410.512.829.495.7510.276.943.641.85
Multiply unsigned 32 bit -O340.3638.641.330.4931.3728.0416.992319.673.761.97
-Os40.2338.511.420.5131.2827.9516.9422.919.573.761.97
Multiply signed 8 bit -O319.9818.261.390.555.311.981.24.431.15.023.23
-Os19.9118.191.530.625.281.951.184.431.15.023.23
Multiply signed 16 bit -O320.6518.931.390.5512.919.585.8110.286.954.512.72
-Os20.5818.861.530.6212.829.495.7510.266.934.512.72
Multiply signed 32 bit -O370.2468.521.230.3931.3828.051722.9419.614.632.84
-Os69.9768.251.410.531.1827.8516.8822.919.574.632.84
Divide unsigned 8 bit -O317.3415.628.097.255.442.111.284.681.355.143.35
-Os17.2715.558.337.425.42.071.254.671.345.143.35
Divide unsigned 16 bit -O329.4427.721110.1675.4372.143.773.3570.024.632.84
-Os29.3227.611.1410.2374.9872.6543.4273.2169.884.632.84
Divide unsigned 32 bit -O390.1288.414.5613.72231.16227.83138.08226.32222.996.64.81
-Os89.7588.0314.6513.74229.63226.3137.15225.89222.566.64.81
Divide signed 8 bit -O333.2731.559.358.518.264.932.997.243.915.263.47
-Os33.1331.419.388.478.24.872.957.223.895.263.47
Divide signed 16 bit -O333.723212.0511.2179.3476.0146.0777.2973.964.752.96
-Os33.4731.7512.2911.3878.8975.5645.7977.1373.84.752.96
Divide signed 32 bit -O396.9495.2215.514.66231.86228.53138.5227.3223.976.855.06
-Os96.5494.8215.5814.67230.46227.13137.65226.68223.356.845.05
Shift right unsigned 8 bit -O314.8613.141.830.9917.814.478.7716.0212.695.013.22
-Os14.7913.071.961.0517.6714.348.6915.9812.655.013.22
Shift right unsigned 16 bit -O329.7928.071.830.9962.8659.5336.0858.9455.614.752.96
-Os29.6627.941.971.0662.4659.1335.8458.7955.464.752.96
Shift right unsigned 32 bit -O369.6267.91.720.88200.46197.13119.47192.1188.775.243.45
-Os69.3167.591.80.89199.32195.99118.78191.57188.245.243.45
Shift right signed 8 bit -O314.8513.132.161.3220.7417.4110.5518.7215.395.013.22
-Os14.813.082.291.3820.6217.2910.4818.6615.335.013.22
Shift right signed 16 bit -O325.1523.432.161.3267.7664.4339.0563.5960.264.752.96
-Os25.0523.332.291.3867.3564.0238.863.4460.114.752.96
Shift right signed 32 bit -O359.6957.971.720.88209.38206.05124.88200.68197.355.243.45
-Os59.4257.71.80.89208.16204.83124.14200.12196.795.243.45
Shift left unsigned 8 bit -O314.8613.141.830.9917.8114.488.7816.0312.75.013.22
-Os14.813.081.961.0517.7114.388.7215.9812.655.013.22
Shift left unsigned 16 bit -O325.1623.441.830.9962.8659.5336.0858.9655.634.752.96
-Os25.0423.321.971.0662.5159.1835.8758.2154.884.752.96
Shift left unsigned 32 bit -O359.6757.981.720.88200.53197.2119.52192.16188.835.243.45
-Os59.4157.961.80.89199.42196.09118.84189.73186.45.243.45
Shift left signed 8 bit -O314.8613.142.161.3217.814.478.7716.0312.75.013.22
-Os14.813.082.291.3817.714.378.7115.8212.495.013.22
Shift left signed 16 bit -O325.1723.452.161.3262.8859.5536.0958.9755.644.752.96
-Os25.0423.322.291.3862.5159.1835.8758.2154.884.752.96
Shift left signed 32 bit -O359.6857.961.720.88200.55197.22119.53192.21188.885.243.45
-Os59.4157.691.80.89199.44196.11118.85189.73186.45.243.45
GPIO -O318.08816.3687.036.1915.612.277.4415.5512.2211.59.71
-Os18.05616.3367.266.3515.5212.197.3915.3512.0211.519.72
GPIO Constant Generator -O314.75213.032
-Os14.75813.038
GPIO Masked -O33.222.38
-Os3.522.61
GPIO Bit Operation -O38.264.932.998.244.91
-Os8.224.892.968.124.79
BCD Add 120+325 -O347.9346.2117.9316.2142.4740.68
-Os50.0548.3320.8319.1142.540.71
BCD Add 120+325
Stored in xdata
-O3214.03210.7127.7218.71215.38
-Os212.13208.8126.55215.79212.46
BCD Add 120+325
Stored in idata
-O3249.96246.63149.47254.55251.22
-Os247.78244.45148.15251.02247.69
BCD Multiply 24 * 13
Without multiplies
-O3393.4391.68131.49129.77292.5290.71
-Os375.21373.49149.84148.12292.65290.86
BCD Multiply 24 * 13
Without multiplies, xdata
-O31441.81438.47871.81471.11467.77
-Os14371433.67868.891480.31476.97
BCD Multiply 24 * 13
Without multiplies, idata
-O31658.31654.971003.011683.41680.07
-Os1651.81648.47999.0716851681.67
BCD Multiply 24 * 13
With multiplies
-O3405.64403.92131.88130.16290.85289.06
-Os508.52506.8140.53138.81290.87289.08
BCD Multiply 24 * 13
With multiplies, xdata
-O31565.11561.77946.531593.81590.47
-Os15571553.67941.621604.91601.57
BCD Multiply 24 * 13
With multiplies, idata
-O31829.51826.171106.7718531849.67
-Os 1818.91815.571100.351867.41864.07

No comments:

Post a Comment