performance test of FastCRC lib, compare hardware CRC with Arduino software CRC (crc16.h) and table driven implementation

Dependencies:   FastCRC mbed

performance test of FastCRC lib, ref https://github.com/FrankBoesing/FastCRC

                 Teensy 3.2 @120MHz                                mbed K64F @120MHz
      hardware CRC	                                         hardware CRC
    Maxim (iButton) FastCRC: Value:0xF6, Time: 275 us.	       Maxim (iButton) FastCRC: Value:0xf6, Time: 275 us
    Maxim (iButton) builtin: Value:0xF6, Time: 9994 us.	       Maxim (iButton) builtin: Value:0xf6, Time: 7100 us
    MODBUS FastCRC: Value:0x7029, Time: 275 us.	               MODBUS FastCRC: Value:0x7029, Time: 275 us
    MODBUS builtin: Value:0x7029, Time: 9584 us.	       MODBUS builtin: Value:0x7029, Time: 7100 us
    XMODEM FastCRC: Value:0x98D9, Time: 275 us.	               XMODEM FastCRC: Value:0x98d9, Time: 275 us
    XMODEM builtin: Value:0x98D9, Time: 10542 us.	       XMODEM builtin: Value:0x98d9, Time: 8193 us
    MCRF4XX FastCRC: Value:0x4A29, Time: 275 us.	       MCRF4XX FastCRC: Value:0x4a29, Time: 275 us
    MCRF4XX builtin: Value:0x4A29, Time: 1783 us.	       MCRF4XX builtin: Value:0x4a29, Time: 1639 us
    KERMIT FastCRC: Value:0xB259, Time: 279 us.	               KERMIT FastCRC: Value:0xb259, Time: 275 us
    Ethernet FastCRC: Value:0x1271457F, Time: 275 us.	       Ethernet FastCRC: Value:0x1271457f, Time: 275 us
	
      table-driven CRC	                                         table-driven CRC
    Maxim (iButton) FastCRC: Value:0xF6, Time: 1329 us.	       Maxim (iButton) FastCRC: Value:0xf6, Time: 997 us
    Maxim (iButton) builtin: Value:0xF6, Time: 9994 us.	       Maxim (iButton) builtin: Value:0xf6, Time: 7101 us
    MODBUS FastCRC: Value:0x7029, Time: 2226 us.	       MODBUS FastCRC: Value:0x7029, Time: 1623 us
    MODBUS builtin: Value:0x7029, Time: 9584 us.	       MODBUS builtin: Value:0x7029, Time: 7101 us
    XMODEM FastCRC: Value:0x98D9, Time: 2102 us.	       XMODEM FastCRC: Value:0x98d9, Time: 1608 us
    XMODEM builtin: Value:0x98D9, Time: 10542 us.	       XMODEM builtin: Value:0x98d9, Time: 8193 us
    MCRF4XX FastCRC: Value:0x4A29, Time: 2185 us.	       MCRF4XX FastCRC: Value:0x4a29, Time: 1664 us
    MCRF4XX builtin: Value:0x4A29, Time: 1782 us.	       MCRF4XX builtin: Value:0x4a29, Time: 1639 us
    KERMIT FastCRC: Value:0xB259, Time: 2190 us.	       KERMIT FastCRC: Value:0xb259, Time: 1650 us
    Ethernet FastCRC: Value:0x38D32145, Time: 2090 us.	       Ethernet FastCRC: Value:0x38d32145, Time: 1702 us
	

Files at this revision

API Documentation at this revision

Comitter:
manitou
Date:
Sat Apr 23 14:22:56 2016 +0000
Parent:
0:d4f8f8fee9db
Commit message:
add validation

Changed in this revision

FastCRC.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d4f8f8fee9db -r 66996d5c4b7c FastCRC.lib
--- a/FastCRC.lib	Fri Apr 22 09:55:23 2016 +0000
+++ b/FastCRC.lib	Sat Apr 23 14:22:56 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/manitou/code/FastCRC/#7343f324d853
+https://developer.mbed.org/users/manitou/code/FastCRC/#1ce0f4ee7357
diff -r d4f8f8fee9db -r 66996d5c4b7c main.cpp
--- a/main.cpp	Fri Apr 22 09:55:23 2016 +0000
+++ b/main.cpp	Sat Apr 23 14:22:56 2016 +0000
@@ -20,6 +20,54 @@
 
 uint8_t buf[BUFSIZE] __attribute__((aligned(4)));
 
+// validation
+void printva(char * name, uint32_t check, uint32_t val){
+    printf("%s",name);
+    if (check == val)
+        printf(" is ok");
+    else
+        printf(" is NOT ok");
+    printf("\n");
+}
+
+void validate() {
+    uint32_t crc;
+    uint8_t buf[9] = {'1','2','3','4','5','6','7','8','9'};
+
+
+  printf("CRC Validation\n");
+
+  crc = CRC8.smbus(buf, sizeof(buf));
+  printva("SMBUS", 0xf4, crc);
+
+  crc = CRC8.maxim(buf, sizeof(buf));
+  printva("Maxim", 0xa1, crc);
+
+  crc = CRC16.ccitt(buf, sizeof(buf));
+  printva("CCITT", 0x29b1, crc);
+
+  crc = CRC16.mcrf4xx(buf, sizeof(buf));
+  printva("MCRF4XX", 0x6f91, crc);
+
+  crc = CRC16.modbus(buf, sizeof(buf));
+  printva("MODBUS", 0x4b37, crc);
+
+  crc = CRC16.kermit(buf, sizeof(buf));
+  printva("KERMIT", 0x2189, crc);
+
+  crc = CRC16.xmodem(buf, sizeof(buf));
+  printva("XMODEM", 0x31c3, crc);
+
+  crc = CRC16.x25(buf, sizeof(buf));
+  printva("X.25", 0x906e, crc);
+
+  crc = CRC32.crc32(buf, sizeof(buf));
+  printva("CRC32", 0xcbf43926, crc);
+
+  crc = CRC32.cksum(buf, sizeof(buf));
+  printva("CKSUM", 0x765e7680, crc);
+}
+
 
 // Supporting functions for Software CRC
 
@@ -62,7 +110,8 @@
 
   tmr.start();
   printf("\nSystemCoreClock %d %s %s\n",SystemCoreClock,__TIME__,__DATE__);
-  printf("CRC Benchmark %d bytes\n",sizeof(buf));
+  validate();
+  printf("\nCRC Benchmark %d bytes\n",sizeof(buf));
 
   //Fill array with data
   for (int i=0; i<BUFSIZE; i++) {