-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code generation use different algorithm for reflected #8
Comments
Hi Craig, thanks for the feed-back! The bit-by-bit implementation is certainly not optimal and should be improved in future. But I'm not sure the table-driven algorithm ever reflects the input bytes. (The finalize function does, but that happens once). Can you give me an example set of parameters where the implementation can be improved? |
Sorry, I think my comments about the table-driven algorithm are wrong. I was getting a few things confused:
Now I see the table-driven algorithm is already using a "reflected" version of the algorithm as needed. So that's fine. Still, a few observations... I'm testing generation of the CRC-8/ROHC algorithm, with parameters as follows:
I now realised I should also be looking at the generated header file:
There is a "reflected" version of the bit-by-bit algorithm that reflects the algorithm itself, and therefore doesn't need any final output byte reflection. Here is code for CRC-8/ROHC that I wrote by hand (just for a single data byte):
This algorithm pattern could also be extended to 16 or 32 bits with some tweaking. |
Craig, this is really useful, thanks! Most of your suggestions will make it into the next release 0.9. I might defer the change to the reflected bit-by-bit algorithm to v0.9.1, as I'd like to release v0.9 with the slice-by variant of the table-driven algorithm as soon as it is working reliably for some corner cases. |
When generating code for a "reflected" CRC, a function is used to reflect each input byte. This is inefficient—it would be preferable to use an alternative core CRC algorithm that is a "reflected" algorithm. See Chapter 11 "Reflected" Table-Driven Implementations of A Painless Guide to CRC Error Detection Algorithms by Ross Williams. That describes a reflected table-driven algorithm; there would similarly be a reflected bit-by-bit algorithm.
The text was updated successfully, but these errors were encountered: