
This weekend I completed the major changes needed for the CRC site to support 64-bit CRC generation. The reason this could not happen right away has to do with how Javascript handles numbers. In Javascript, all numbers are 64-bit (double-precision) floating-point. You can do bit manipulation, but it is done on floating-point values. An IEEE double-precision float has 1 sign bit, 11-bits of exponent and 52-bits of mantissa. In theory one could store 52-bits in a double without loss of precision. That means Javascript cannot directly hold a 64-bit CRC in a single word, and that makes implementation more difficult.
We cannot use a single word to hold results, but we can use multiple words. So the first step in generating larger CRCs inside Javascript is to create an arbitrary length word. Although we technically can use 52-bits/word, it is easier to work with 32-bit words. I created a unit that can do bit manipulation on words of arbitrary length. In reality I only need 64-bit words, but it was about as easy to use make this size arbitrary. The unit needed to support basic bit operations: AND, OR, XOR, shifts, bit reversal, etc., and converting to/from strings.
After a large word unit was implemented I needed to make the CRC class use it. The large words are significantly slower than small, so I kept the original class and simply duplicated the functionality with a large class.
It took a few passes but I worked out all the bugs and now have a functional CRC class that can generate 64-bit CRCs. The system can do the 82-bit CRC, but the C implementation system only supports up to 64-bit word sizes.
My CRC website creates C source code using Javascript and I needed a method to verify the generated code. As an engineer I am pretty lazy and I didn’t want anything manual so I went in search of a tool that could help. I found system called PhantomJS which seems to be designed to test Javascript rich websites, and it seems to be exactly what I was looking for. I was able to use it to run a test script that generated C code for every possible CRC output combination, along with test C code. The code is then saved to disk where it can be compiled and verified. The results: all good. CRC code for each combination generates the correct CRC for the test vector.
Temp were above 40°F/4°C this afternoon and made for a very pleasant ride home. Temperatures are forecast to stay warm through the weekend and I have a feeling the snowman I'm standing with will not be around on my next ride.