[Pycrc-users] PyCrc 0.8.1 - bad code for CRC-5, CRC-7 and table index width 4?
CRC C source generator
Brought to you by:
tpircher
From: Radosław G. <ra...@he...> - 2013-12-12 17:37:35
|
Hi, I'm trying to generate table based code for CRC-5 and pycrc-0.8.1 generates code that produces different CRC for most data when I'm using --alogrithm-tbl --table-idx-width=4. I am getting similar results for CRC-4, CRC-6 and CRC-7. Am I doing something wrong or I have found bug in pycrc? Thanks in advance for your help. My code is: ================================== main.c ============================ #include <stdio.h> #include "crcbbf.h" #include "crcidx4.h" #include "crcidx8.h" int main(int argc,char * argv) { crc5_bbf_t bbf; crc5_idx4_t idx4; crc5_idx8_t idx8; #define data_len 1 unsigned char data[data_len] = { 0x01 } ;//, 0x02 , 0x03 , 0x44}; int i; for (i=0;i<256;i++) { data[0]=i; bbf= crc5_bbf_init(); bbf= crc5_bbf_update(bbf, data, data_len); bbf= crc5_bbf_finalize(bbf); idx4= crc5_idx4_init(); idx4= crc5_idx4_update(idx4, data, data_len); idx4= crc5_idx4_finalize(idx4); idx8= crc5_idx8_init(); idx8= crc5_idx8_update(idx8, data, data_len); idx8= crc5_idx8_finalize(idx8); if ( (bbf != idx4 ) || (bbf != idx8) ) { printf("data[]={0x%02x} bbf=0x%02x, idx4=0x%02x," "idx8=0x%02x\n", data[0],bbf, idx4, idx8); } } return 0; } =============== Script that generates and compiles code ============== #!/bin/bash model="--poly=5 --width=4 --xor-in=0 --xor-out=0" model="$model --reflect-in=0 --reflect-out=0" ../pycrc.py --algorithm=tbl --table-idx-width=4 $model\ --std=C99 --symbol-prefix=crc5_idx4_ --generate=c \ --o crcidx4.c ../pycrc.py --algorithm=tbl --table-idx-width=4 $model\ --std=C99 --symbol-prefix=crc5_idx4_ --generate=h \ --o crcidx4.h ../pycrc.py --algorithm=tbl --table-idx-width=8 $model\ --std=C99 --symbol-prefix=crc5_idx8_ --generate=c \ --o crcidx8.c ../pycrc.py --algorithm=tbl --table-idx-width=8 $model\ --std=C99 --symbol-prefix=crc5_idx8_ --generate=h \ --o crcidx8.h ../pycrc.py --algorithm=bbf $model\ --std=C99 --symbol-prefix=crc5_bbf_ --generate=c \ --o crcbbf.c ../pycrc.py --algorithm=bbf $model\ --std=C99 --symbol-prefix=crc5_bbf_ --generate=h \ --o crcbbf.h gcc -c crcidx4.c gcc -c crcidx8.c gcc -c crcbbf.c gcc -c main.c gcc -o main main.o crcbbf.o crcidx8.o crcidx4.o ./main | head ================================== Output ============================ data[]={0x10} bbf=0x1a, idx4=0x00, idx8=0x1a data[]={0x11} bbf=0x1f, idx4=0x05, idx8=0x1f data[]={0x12} bbf=0x10, idx4=0x0a, idx8=0x10 data[]={0x13} bbf=0x15, idx4=0x0f, idx8=0x15 data[]={0x14} bbf=0x0e, idx4=0x14, idx8=0x0e data[]={0x15} bbf=0x0b, idx4=0x11, idx8=0x0b data[]={0x16} bbf=0x04, idx4=0x1e, idx8=0x04 data[]={0x17} bbf=0x01, idx4=0x1b, idx8=0x01 data[]={0x18} bbf=0x17, idx4=0x0d, idx8=0x17 data[]={0x19} bbf=0x12, idx4=0x08, idx8=0x12 ======================================================================= My system is Debian 7.2 (gcc4.7): radekg@debian64:~/pycrc-0.8.1/crctest$ uname -a Linux debian64 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux radekg@debian64:~/pycrc-0.8.1/crctest$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-5) Best Regards -- Radosław Gancarz r a d e k g @ h e l l . p l |