]> git.cryptolib.org Git - arm-crypto-lib.git/commitdiff
speedup of bmw
authorbg <bg@cypex>
Thu, 13 May 2010 03:00:56 +0000 (05:00 +0200)
committerbg <bg@cypex>
Thu, 13 May 2010 03:00:56 +0000 (05:00 +0200)
17 files changed:
bmw/autogen_f1.rb [new file with mode: 0644]
bmw/autogen_f1_large.rb [new file with mode: 0644]
bmw/bmw_large_speed.c
bmw/bmw_small_speed.c
bmw/f1_autogen.c [new file with mode: 0644]
bmw/f1_autogen_large.c [new file with mode: 0644]
test_src/config.h
test_src/main-blake-test.c
test_src/main-bmw-test.c
test_src/main-cubehash-test.c
test_src/main-echo-test.c
test_src/main-groestl-test.c
test_src/main-keccak-test.c
test_src/main-sha1-test.c
test_src/main-sha256-test.c
test_src/main-shabal-test.c
test_src/main-skein-test.c

diff --git a/bmw/autogen_f1.rb b/bmw/autogen_f1.rb
new file mode 100644 (file)
index 0000000..b956083
--- /dev/null
@@ -0,0 +1,75 @@
+# autogen f1 function for BMW
+
+header = <<EOF
+/* BEGIN of automatic generated code */
+
+static inline
+void bmw_small_f1(uint32_t* q, const void* m, const void* h){ 
+EOF
+
+footer = <<EOF
+}
+
+/* END of automatic generated code */
+
+EOF
+
+=begin
+  uint32_t r;
+  /* r = 0x05555555*(j+16); */
+  r = (   ROTL32(((uint32_t*)m)[j],      ((j+0))+1  )
+         + ROTL32(((uint32_t*)m)[(j+3)],  ((j+3))+1  )
+         - ROTL32(((uint32_t*)m)[(j+10)], ((j+10))+1 )
+         + k_lut[j]
+       ) ^ ((uint32_t*)h)[(j+7)];
+  r += S32_1(q[j+ 0]) + S32_2(q[j+ 1]) + S32_3(q[j+ 2]) + S32_0(q[j+ 3]) +
+     S32_1(q[j+ 4]) + S32_2(q[j+ 5]) + S32_3(q[j+ 6]) + S32_0(q[j+ 7]) +
+     S32_1(q[j+ 8]) + S32_2(q[j+ 9]) + S32_3(q[j+10]) + S32_0(q[j+11]) +
+     S32_1(q[j+12]) + S32_2(q[j+13]) + S32_3(q[j+14]) + S32_0(q[j+15]);
+=end
+
+def expand_1(j)
+  s = sprintf("/* expand_1(%2d) */\n", j)
+  s += sprintf("\tq[%2d] = \n", j+16)
+  s += sprintf("\t\t((  ROTL32(((uint32_t*)m)[%2d], %d) \n", j%16,      (j%16)+1)
+  s += sprintf("\t\t  + ROTL32(((uint32_t*)m)[%2d], %d) \n", (j+ 3)%16, ((j+ 3)%16)+1)
+  s += sprintf("\t\t  - ROTL32(((uint32_t*)m)[%2d], %d) \n", (j+10)%16, ((j+10)%16)+1)
+  s += sprintf("\t\t  + 0x%08xUL \n", 0x0555_5555*(16+j))
+  s += sprintf("\t\t )^ ((uint32_t*)h)[%2d] \n", (j+7)%16)
+  s += sprintf("\t\t)");
+  (0..15).each do |x|
+    s += (x%4==0)?"\n\t\t":" "
+    s += sprintf("+ S32_%d(q[%2d])", (x+1)%4, x+j)
+  end
+  s += ';'
+  return s
+end
+
+
+def expand_2(j)
+  s = sprintf("/* expand_2(%2d) */\n", j)
+  s += sprintf("\tq[%2d] = \n", j+16)
+  s += sprintf("\t\t((  ROTL32(((uint32_t*)m)[%2d], %d) \n", j%16,      (j%16)+1)
+  s += sprintf("\t\t  + ROTL32(((uint32_t*)m)[%2d], %d) \n", (j+ 3)%16, ((j+ 3)%16)+1)
+  s += sprintf("\t\t  - ROTL32(((uint32_t*)m)[%2d], %d) \n", (j+10)%16, ((j+10)%16)+1)
+  s += sprintf("\t\t  + 0x%08xUL \n", 0x0555_5555*(16+j))
+  s += sprintf("\t\t )^ ((uint32_t*)h)[%2d] \n", (j+7)%16)
+  s += sprintf("\t\t)");
+  (0..13).each do |x|
+    s += (x%4==0)?"\n\t\t":" "
+    if x%2==0
+      s += sprintf("+       q[%2d] ",  x+j)
+    else
+      s += sprintf("+ R32_%d(q[%2d])", (x+1)/2, x+j)
+    end
+  end
+  s += sprintf(" + S32_4(q[%2d]) + S32_5(q[%2d])", j+14, j+15)
+  s += ';'
+  return s
+end
+
+
+puts header
+(0..1).each  {|x| puts expand_1(x)}
+(2..15).each {|x| puts expand_2(x)}
+puts footer
\ No newline at end of file
diff --git a/bmw/autogen_f1_large.rb b/bmw/autogen_f1_large.rb
new file mode 100644 (file)
index 0000000..5faca0f
--- /dev/null
@@ -0,0 +1,75 @@
+# autogen f1 function for BMW
+
+header = <<EOF
+/* BEGIN of automatic generated code */
+
+static inline
+void bmw_large_f1(uint64_t* q, const void* m, const void* h){ 
+EOF
+
+footer = <<EOF
+}
+
+/* END of automatic generated code */
+
+EOF
+
+=begin
+  uint32_t r;
+  /* r = 0x05555555*(j+16); */
+  r = (   ROTL32(((uint32_t*)m)[j],      ((j+0))+1  )
+         + ROTL32(((uint32_t*)m)[(j+3)],  ((j+3))+1  )
+         - ROTL32(((uint32_t*)m)[(j+10)], ((j+10))+1 )
+         + k_lut[j]
+       ) ^ ((uint32_t*)h)[(j+7)];
+  r += S32_1(q[j+ 0]) + S32_2(q[j+ 1]) + S32_3(q[j+ 2]) + S32_0(q[j+ 3]) +
+     S32_1(q[j+ 4]) + S32_2(q[j+ 5]) + S32_3(q[j+ 6]) + S32_0(q[j+ 7]) +
+     S32_1(q[j+ 8]) + S32_2(q[j+ 9]) + S32_3(q[j+10]) + S32_0(q[j+11]) +
+     S32_1(q[j+12]) + S32_2(q[j+13]) + S32_3(q[j+14]) + S32_0(q[j+15]);
+=end
+
+def expand_1(j)
+  s = sprintf("/* expand_1(%2d) */\n", j)
+  s += sprintf("\tq[%2d] = \n", j+16)
+  s += sprintf("\t\t((  ROTL64(((uint64_t*)m)[%2d], %d) \n", j%16,      (j%16)+1)
+  s += sprintf("\t\t  + ROTL64(((uint64_t*)m)[%2d], %d) \n", (j+ 3)%16, ((j+ 3)%16)+1)
+  s += sprintf("\t\t  - ROTL64(((uint64_t*)m)[%2d], %d) \n", (j+10)%16, ((j+10)%16)+1)
+  s += sprintf("\t\t  + 0x%016xULL \n", 0x0555_5555_5555_5555*(16+j))
+  s += sprintf("\t\t )^ ((uint64_t*)h)[%2d] \n", (j+7)%16)
+  s += sprintf("\t\t)");
+  (0..15).each do |x|
+    s += (x%4==0)?"\n\t\t":" "
+    s += sprintf("+ S64_%d(q[%2d])", (x+1)%4, x+j)
+  end
+  s += ';'
+  return s
+end
+
+
+def expand_2(j)
+  s = sprintf("/* expand_2(%2d) */\n", j)
+  s += sprintf("\tq[%2d] = \n", j+16)
+  s += sprintf("\t\t((  ROTL64(((uint64_t*)m)[%2d], %d) \n", j%16,      (j%16)+1)
+  s += sprintf("\t\t  + ROTL64(((uint64_t*)m)[%2d], %d) \n", (j+ 3)%16, ((j+ 3)%16)+1)
+  s += sprintf("\t\t  - ROTL64(((uint64_t*)m)[%2d], %d) \n", (j+10)%16, ((j+10)%16)+1)
+  s += sprintf("\t\t  + 0x%016xULL \n", 0x0555_5555_5555_5555*(16+j))
+  s += sprintf("\t\t )^ ((uint64_t*)h)[%2d] \n", (j+7)%16)
+  s += sprintf("\t\t)");
+  (0..13).each do |x|
+    s += (x%4==0)?"\n\t\t":" "
+    if x%2==0
+      s += sprintf("+       q[%2d] ",  x+j)
+    else
+      s += sprintf("+ R64_%d(q[%2d])", (x+1)/2, x+j)
+    end
+  end
+  s += sprintf(" + S64_4(q[%2d]) + S64_5(q[%2d])", j+14, j+15)
+  s += ';'
+  return s
+end
+
+
+puts header
+(0..1).each  {|x| puts expand_1(x)}
+(2..15).each {|x| puts expand_2(x)}
+puts footer
\ No newline at end of file
index a9088a2ae94c2bd05c2ebfdfc59aed9772090d30..eb8396980f1529e8893d939cb01f232054dd0b36 100644 (file)
 #define R64_6(x)    (ROTR64((x), 21))
 #define R64_7(x)    (ROTR64((x), 11))
 
-/*
-#define K    0x0555555555555555LL
-#define MASK 0xFFFFFFFFFFFFFFFFLL
-static
-uint64_t k_lut[] PROGMEM = {
-       16LL*K, 17LL*K, 18LL*K, 19LL*K,
-       20LL*K, 21LL*K, 22LL*K, 23LL*K,
-       24LL*K, 25LL*K, 26LL*K, 27LL*K,
-       28LL*K, 29LL*K, 30LL*K, 31LL*K };
-*/
-/* the same as above but precomputed to avoid compiler warnings */
-static const
-uint64_t k_lut[] = {
-       0x5555555555555550LL, 0x5aaaaaaaaaaaaaa5LL, 0x5ffffffffffffffaLL,
-       0x655555555555554fLL, 0x6aaaaaaaaaaaaaa4LL, 0x6ffffffffffffff9LL,
-       0x755555555555554eLL, 0x7aaaaaaaaaaaaaa3LL, 0x7ffffffffffffff8LL,
-       0x855555555555554dLL, 0x8aaaaaaaaaaaaaa2LL, 0x8ffffffffffffff7LL,
-       0x955555555555554cLL, 0x9aaaaaaaaaaaaaa1LL, 0x9ffffffffffffff6LL,
-       0xa55555555555554bLL };
-
-static
-uint64_t bmw_large_expand1(uint8_t j, const uint64_t* q, const void* m, const void* h){
-       uint64_t r;
-       /* r = 0x0555555555555555LL*(j+16); */
-       r  = (   ROTL64(((uint64_t*)m)[(j)&0xf],   ((j+ 0)&0xf)+1)
-              + ROTL64(((uint64_t*)m)[(j+3)&0xf], ((j+ 3)&0xf)+1)
-              + k_lut[j]
-              - ROTL64(((uint64_t*)m)[(j+10)&0xf],((j+10)&0xf)+1)
-            ) ^ ((uint64_t*)h)[(j+7)&0xf];
-       r += S64_1(q[j+ 0]) + S64_2(q[j+ 1]) + S64_3(q[j+ 2]) + S64_0(q[j+ 3]) +
-                S64_1(q[j+ 4]) + S64_2(q[j+ 5]) + S64_3(q[j+ 6]) + S64_0(q[j+ 7]) +
-                S64_1(q[j+ 8]) + S64_2(q[j+ 9]) + S64_3(q[j+10]) + S64_0(q[j+11]) +
-                S64_1(q[j+12]) + S64_2(q[j+13]) + S64_3(q[j+14]) + S64_0(q[j+15]);
-
-       return r;
-}
-
-static
-uint64_t bmw_large_expand2(uint8_t j, const uint64_t* q, const void* m, const void* h){
-       uint64_t r=0;
-       r  = (   ROTL64(((uint64_t*)m)[(j)&0xf],   ((j+ 0)&0xf)+1)
-              + ROTL64(((uint64_t*)m)[(j+3)&0xf], ((j+ 3)&0xf)+1)
-              + k_lut[j]
-              - ROTL64(((uint64_t*)m)[(j+10)&0xf],((j+10)&0xf)+1)
-            ) ^ ((uint64_t*)h)[(j+7)&0xf];
-       r += (q[j+ 0]) + R64_1(q[j+ 1]) + (q[j+ 2]) + R64_2(q[j+ 3]) +
-                (q[j+ 4]) + R64_3(q[j+ 5]) + (q[j+ 6]) + R64_4(q[j+ 7]) +
-                (q[j+ 8]) + R64_5(q[j+ 9]) + (q[j+10]) + R64_6(q[j+11]) +
-                (q[j+12]) + R64_7(q[j+13]) + S64_4(q[j+14]) + S64_5(q[j+15]);
-
-       return r;
-}
-
-static
-void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
-       uint8_t i;
-       for(i=0; i<16; ++i){
-               ((uint64_t*)h)[i] ^= ((uint64_t*)m)[i];
-       }
-//     dump_x(t, 16, 'T');
+#include "f1_autogen_large.c"
+
+static inline
+void bmw_large_f0(uint64_t* q, uint64_t* h, const uint64_t* m){
+       h[ 0] ^= m[ 0];
+       h[ 1] ^= m[ 1];
+       h[ 2] ^= m[ 2];
+       h[ 3] ^= m[ 3];
+       h[ 4] ^= m[ 4];
+       h[ 5] ^= m[ 5];
+       h[ 6] ^= m[ 6];
+       h[ 7] ^= m[ 7];
+       h[ 8] ^= m[ 8];
+       h[ 9] ^= m[ 9];
+       h[10] ^= m[10];
+       h[11] ^= m[11];
+       h[12] ^= m[12];
+       h[13] ^= m[13];
+       h[14] ^= m[14];
+       h[15] ^= m[15];
+       //      dump_x(t, 16, 'T');
        q[ 0] = (h[ 5] - h[ 7] + h[10] + h[13] + h[14]);
        q[ 1] = (h[ 6] - h[ 8] + h[11] + h[14] - h[15]);
        q[ 2] = (h[ 0] + h[ 7] + h[ 9] - h[12] + h[15]);
@@ -181,28 +142,26 @@ void bmw_large_f0(uint64_t* q, const uint64_t* h, const void* m){
        q[14] = (h[ 3] - h[ 5] + h[ 8] - h[11] - h[12]);
        q[15] = (h[12] - h[ 4] - h[ 6] - h[ 9] + h[13]);
        dump_x(q, 16, 'W');
-       q[ 0] = S64_0(q[ 0]); q[ 1] = S64_1(q[ 1]); q[ 2] = S64_2(q[ 2]); q[ 3] = S64_3(q[ 3]); q[ 4] = S64_4(q[ 4]);
-       q[ 5] = S64_0(q[ 5]); q[ 6] = S64_1(q[ 6]); q[ 7] = S64_2(q[ 7]); q[ 8] = S64_3(q[ 8]); q[ 9] = S64_4(q[ 9]);
-       q[10] = S64_0(q[10]); q[11] = S64_1(q[11]); q[12] = S64_2(q[12]); q[13] = S64_3(q[13]); q[14] = S64_4(q[14]);
-       q[15] = S64_0(q[15]);
-
-       for(i=0; i<16; ++i){
-               q[(i+15)&15] += ((uint64_t*)h)[i] ^= ((uint64_t*)m)[i];
-
-       }
-}
 
-static
-void bmw_large_f1(uint64_t* q, const void* m, const uint64_t* h){
-       uint8_t i;
-       q[16] = bmw_large_expand1(0, q, m, h);
-       q[17] = bmw_large_expand1(1, q, m, h);
-       for(i=2; i<16; ++i){
-               q[16+i] = bmw_large_expand2(i, q, m, h);
-       }
+       q[ 0] = S64_0(q[ 0]) + (h[ 1] ^= m[ 1]);
+       q[ 1] = S64_1(q[ 1]) + (h[ 2] ^= m[ 2]);
+       q[ 2] = S64_2(q[ 2]) + (h[ 3] ^= m[ 3]);
+       q[ 3] = S64_3(q[ 3]) + (h[ 4] ^= m[ 4]);
+       q[ 4] = S64_4(q[ 4]) + (h[ 5] ^= m[ 5]);
+       q[ 5] = S64_0(q[ 5]) + (h[ 6] ^= m[ 6]);
+       q[ 6] = S64_1(q[ 6]) + (h[ 7] ^= m[ 7]);
+       q[ 7] = S64_2(q[ 7]) + (h[ 8] ^= m[ 8]);
+       q[ 8] = S64_3(q[ 8]) + (h[ 9] ^= m[ 9]);
+       q[ 9] = S64_4(q[ 9]) + (h[10] ^= m[10]);
+       q[10] = S64_0(q[10]) + (h[11] ^= m[11]);
+       q[11] = S64_1(q[11]) + (h[12] ^= m[12]);
+       q[12] = S64_2(q[12]) + (h[13] ^= m[13]);
+       q[13] = S64_3(q[13]) + (h[14] ^= m[14]);
+       q[14] = S64_4(q[14]) + (h[15] ^= m[15]);
+       q[15] = S64_0(q[15]) + (h[ 0] ^= m[ 0]);
 }
 
-static
+static inline
 void bmw_large_f2(uint64_t* h, const uint64_t* q, const uint64_t* m){
 
        uint64_t xl, xh;
index 148b2f7535cd0d4704c09509ee89d9b08c21fe30..c67d6aa03985740b225e9d4bc1deb8ca7cd5f389 100644 (file)
@@ -115,7 +115,7 @@ uint32_t k_lut[] PROGMEM = {
 };
 */
 /* same as above but precomputed to avoid compiler warnings */
-
+/*
 static
 uint32_t k_lut[] = {
        0x55555550L, 0x5aaaaaa5L, 0x5ffffffaL,
@@ -124,16 +124,16 @@ uint32_t k_lut[] = {
        0x8555554dL, 0x8aaaaaa2L, 0x8ffffff7L,
        0x9555554cL, 0x9aaaaaa1L, 0x9ffffff6L,
        0xa555554bL };
-
-static
+*/
+/*
+static inline
 uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const void* h){
        uint32_t r;
-       /* r = 0x05555555*(j+16); */
-       r = (   ROTL32(((uint32_t*)m)[j&0xf],      ((j+0)&0xf)+1  )
-              + ROTL32(((uint32_t*)m)[(j+3)&0xf],  ((j+3)&0xf)+1  )
-              - ROTL32(((uint32_t*)m)[(j+10)&0xf], ((j+10)&0xf)+1 )
+       r = (   ROTL32(((uint32_t*)m)[j],      ((j+0))+1  )
+              + ROTL32(((uint32_t*)m)[(j+3)],  ((j+3))+1  )
+              - ROTL32(((uint32_t*)m)[(j+10)], ((j+10))+1 )
               + k_lut[j]
-            ) ^ ((uint32_t*)h)[(j+7)&0xf];
+            ) ^ ((uint32_t*)h)[(j+7)];
        r += S32_1(q[j+ 0]) + S32_2(q[j+ 1]) + S32_3(q[j+ 2]) + S32_0(q[j+ 3]) +
                 S32_1(q[j+ 4]) + S32_2(q[j+ 5]) + S32_3(q[j+ 6]) + S32_0(q[j+ 7]) +
                 S32_1(q[j+ 8]) + S32_2(q[j+ 9]) + S32_3(q[j+10]) + S32_0(q[j+11]) +
@@ -142,7 +142,7 @@ uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const vo
        return r;
 }
 
-static
+static inline
 uint32_t bmw_small_expand2(uint8_t j, const uint32_t* q, const void* m, const void* h){
        uint32_t r;
        r = (   ROTL32(((uint32_t*)m)[j&0xf],      ((j+0)&0xf)+1  )
@@ -156,15 +156,29 @@ uint32_t bmw_small_expand2(uint8_t j, const uint32_t* q, const void* m, const vo
                 (q[j+12]) + R32_7(q[j+13]) + S32_4(q[j+14]) + S32_5(q[j+15]);
        return r;
 }
+*/
+static inline
+void bmw_small_f1(uint32_t* q, const void* m, const void* h);
+
+static inline
+void bmw_small_f0(uint32_t* q, uint32_t* h, const uint32_t* m){
+       h[ 0] ^= m[ 0];
+       h[ 1] ^= m[ 1];
+       h[ 2] ^= m[ 2];
+       h[ 3] ^= m[ 3];
+       h[ 4] ^= m[ 4];
+       h[ 5] ^= m[ 5];
+       h[ 6] ^= m[ 6];
+       h[ 7] ^= m[ 7];
+       h[ 8] ^= m[ 8];
+       h[ 9] ^= m[ 9];
+       h[10] ^= m[10];
+       h[11] ^= m[11];
+       h[12] ^= m[12];
+       h[13] ^= m[13];
+       h[14] ^= m[14];
+       h[15] ^= m[15];
 
-
-static
-void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
-       uint8_t i;
-       i=15;
-       do{
-               ((uint32_t*)h)[i] ^= ((uint32_t*)m)[i];
-       }while(i--);
        dump_x(h, 16, 'T');
        q[ 0] = (h[ 5] - h[ 7] + h[10] + h[13] + h[14]);
        q[ 3] = (h[ 0] - h[ 1] + h[ 8] - h[10] + h[13]);
@@ -183,27 +197,47 @@ void bmw_small_f0(uint32_t* q, uint32_t* h, const void* m){
        q[10] = (h[ 8] - h[ 1] - h[ 4] - h[ 7] + h[15]);
        q[13] = (h[ 2] + h[ 4] + h[ 7] + h[10] + h[11]);
        dump_x(q, 16, 'W');
+/*
        q[ 0] = S32_0(q[ 0]); q[ 1] = S32_1(q[ 1]); q[ 2] = S32_2(q[ 2]); q[ 3] = S32_3(q[ 3]); q[ 4] = S32_4(q[ 4]);
        q[ 5] = S32_0(q[ 5]); q[ 6] = S32_1(q[ 6]); q[ 7] = S32_2(q[ 7]); q[ 8] = S32_3(q[ 8]); q[ 9] = S32_4(q[ 9]);
        q[10] = S32_0(q[10]); q[11] = S32_1(q[11]); q[12] = S32_2(q[12]); q[13] = S32_3(q[13]); q[14] = S32_4(q[14]);
        q[15] = S32_0(q[15]);
-       i=15;
-       do{
-               q[(i+15)&15] += ((uint32_t*)h)[i] ^= ((uint32_t*)m)[i];
-       }while(i--);
-}
-
-static
-void bmw_small_f1(uint32_t* q, const void* m, const void* h){
-       uint8_t i;
-       q[16] = bmw_small_expand1(0, q, m, h);
-       q[17] = bmw_small_expand1(1, q, m, h);
-       for(i=2; i<16; ++i){
-               q[16+i] = bmw_small_expand2(i, q, m, h);
-       }
+       q[ 0] += h[ 1] ^= m[ 1];
+       q[ 1] += h[ 2] ^= m[ 2];
+       q[ 2] += h[ 3] ^= m[ 3];
+       q[ 3] += h[ 4] ^= m[ 4];
+       q[ 4] += h[ 5] ^= m[ 5];
+       q[ 5] += h[ 6] ^= m[ 6];
+       q[ 6] += h[ 7] ^= m[ 7];
+       q[ 7] += h[ 8] ^= m[ 8];
+       q[ 8] += h[ 9] ^= m[ 9];
+       q[ 9] += h[10] ^= m[10];
+       q[10] += h[11] ^= m[11];
+       q[11] += h[12] ^= m[12];
+       q[12] += h[13] ^= m[13];
+       q[13] += h[14] ^= m[14];
+       q[14] += h[15] ^= m[15];
+       q[15] += h[ 0] ^= m[ 0];
+*/
+       q[ 0] = S32_0(q[ 0]) + (h[ 1] ^= m[ 1]);
+       q[ 1] = S32_1(q[ 1]) + (h[ 2] ^= m[ 2]);
+       q[ 2] = S32_2(q[ 2]) + (h[ 3] ^= m[ 3]);
+       q[ 3] = S32_3(q[ 3]) + (h[ 4] ^= m[ 4]);
+       q[ 4] = S32_4(q[ 4]) + (h[ 5] ^= m[ 5]);
+       q[ 5] = S32_0(q[ 5]) + (h[ 6] ^= m[ 6]);
+       q[ 6] = S32_1(q[ 6]) + (h[ 7] ^= m[ 7]);
+       q[ 7] = S32_2(q[ 7]) + (h[ 8] ^= m[ 8]);
+       q[ 8] = S32_3(q[ 8]) + (h[ 9] ^= m[ 9]);
+       q[ 9] = S32_4(q[ 9]) + (h[10] ^= m[10]);
+       q[10] = S32_0(q[10]) + (h[11] ^= m[11]);
+       q[11] = S32_1(q[11]) + (h[12] ^= m[12]);
+       q[12] = S32_2(q[12]) + (h[13] ^= m[13]);
+       q[13] = S32_3(q[13]) + (h[14] ^= m[14]);
+       q[14] = S32_4(q[14]) + (h[15] ^= m[15]);
+       q[15] = S32_0(q[15]) + (h[ 0] ^= m[ 0]);
 }
 
-static
+static inline
 void bmw_small_f2(uint32_t* h, uint32_t* q, const uint32_t* m){
        uint32_t xl, xh;
        xl =      q[16] ^ q[17] ^ q[18] ^ q[19] ^ q[20] ^ q[21] ^ q[22] ^ q[23];
@@ -240,7 +274,7 @@ void bmw_small_nextBlock(bmw_small_ctx_t* ctx, const void* block){
        bmw_small_f0(q, ctx->h, block);
        dump_x(q, 16, 'Q');
        bmw_small_f1(q, block, ctx->h);
-       dump_x(q, 32, 'Q');
+       dump_x(q+16, 16, 'Q');
        bmw_small_f2(ctx->h, q, block);
        ctx->counter += 1;
        ctx_dump(ctx);
@@ -348,3 +382,5 @@ void bmw256(void* dest, const void* msg, uint32_t length_b){
        bmw256_ctx2hash(dest, &ctx);
 }
 
+#include "f1_autogen.c"
+
diff --git a/bmw/f1_autogen.c b/bmw/f1_autogen.c
new file mode 100644 (file)
index 0000000..31217b7
--- /dev/null
@@ -0,0 +1,200 @@
+/* BEGIN of automatic generated code */
+
+static inline
+void bmw_small_f1(uint32_t* q, const void* m, const void* h){ 
+/* expand_1( 0) */
+       q[16] = 
+               ((  ROTL32(((uint32_t*)m)[ 0], 1) 
+                 + ROTL32(((uint32_t*)m)[ 3], 4) 
+                 - ROTL32(((uint32_t*)m)[10], 11) 
+                 + 0x55555550UL 
+                )^ ((uint32_t*)h)[ 7] 
+               )
+               + S32_1(q[ 0]) + S32_2(q[ 1]) + S32_3(q[ 2]) + S32_0(q[ 3])
+               + S32_1(q[ 4]) + S32_2(q[ 5]) + S32_3(q[ 6]) + S32_0(q[ 7])
+               + S32_1(q[ 8]) + S32_2(q[ 9]) + S32_3(q[10]) + S32_0(q[11])
+               + S32_1(q[12]) + S32_2(q[13]) + S32_3(q[14]) + S32_0(q[15]);
+/* expand_1( 1) */
+       q[17] = 
+               ((  ROTL32(((uint32_t*)m)[ 1], 2) 
+                 + ROTL32(((uint32_t*)m)[ 4], 5) 
+                 - ROTL32(((uint32_t*)m)[11], 12) 
+                 + 0x5aaaaaa5UL 
+                )^ ((uint32_t*)h)[ 8] 
+               )
+               + S32_1(q[ 1]) + S32_2(q[ 2]) + S32_3(q[ 3]) + S32_0(q[ 4])
+               + S32_1(q[ 5]) + S32_2(q[ 6]) + S32_3(q[ 7]) + S32_0(q[ 8])
+               + S32_1(q[ 9]) + S32_2(q[10]) + S32_3(q[11]) + S32_0(q[12])
+               + S32_1(q[13]) + S32_2(q[14]) + S32_3(q[15]) + S32_0(q[16]);
+/* expand_2( 2) */
+       q[18] = 
+               ((  ROTL32(((uint32_t*)m)[ 2], 3) 
+                 + ROTL32(((uint32_t*)m)[ 5], 6) 
+                 - ROTL32(((uint32_t*)m)[12], 13) 
+                 + 0x5ffffffaUL 
+                )^ ((uint32_t*)h)[ 9] 
+               )
+               +       q[ 2]  + R32_1(q[ 3]) +       q[ 4]  + R32_2(q[ 5])
+               +       q[ 6]  + R32_3(q[ 7]) +       q[ 8]  + R32_4(q[ 9])
+               +       q[10]  + R32_5(q[11]) +       q[12]  + R32_6(q[13])
+               +       q[14]  + R32_7(q[15]) + S32_4(q[16]) + S32_5(q[17]);
+/* expand_2( 3) */
+       q[19] = 
+               ((  ROTL32(((uint32_t*)m)[ 3], 4) 
+                 + ROTL32(((uint32_t*)m)[ 6], 7) 
+                 - ROTL32(((uint32_t*)m)[13], 14) 
+                 + 0x6555554fUL 
+                )^ ((uint32_t*)h)[10] 
+               )
+               +       q[ 3]  + R32_1(q[ 4]) +       q[ 5]  + R32_2(q[ 6])
+               +       q[ 7]  + R32_3(q[ 8]) +       q[ 9]  + R32_4(q[10])
+               +       q[11]  + R32_5(q[12]) +       q[13]  + R32_6(q[14])
+               +       q[15]  + R32_7(q[16]) + S32_4(q[17]) + S32_5(q[18]);
+/* expand_2( 4) */
+       q[20] = 
+               ((  ROTL32(((uint32_t*)m)[ 4], 5) 
+                 + ROTL32(((uint32_t*)m)[ 7], 8) 
+                 - ROTL32(((uint32_t*)m)[14], 15) 
+                 + 0x6aaaaaa4UL 
+                )^ ((uint32_t*)h)[11] 
+               )
+               +       q[ 4]  + R32_1(q[ 5]) +       q[ 6]  + R32_2(q[ 7])
+               +       q[ 8]  + R32_3(q[ 9]) +       q[10]  + R32_4(q[11])
+               +       q[12]  + R32_5(q[13]) +       q[14]  + R32_6(q[15])
+               +       q[16]  + R32_7(q[17]) + S32_4(q[18]) + S32_5(q[19]);
+/* expand_2( 5) */
+       q[21] = 
+               ((  ROTL32(((uint32_t*)m)[ 5], 6) 
+                 + ROTL32(((uint32_t*)m)[ 8], 9) 
+                 - ROTL32(((uint32_t*)m)[15], 16) 
+                 + 0x6ffffff9UL 
+                )^ ((uint32_t*)h)[12] 
+               )
+               +       q[ 5]  + R32_1(q[ 6]) +       q[ 7]  + R32_2(q[ 8])
+               +       q[ 9]  + R32_3(q[10]) +       q[11]  + R32_4(q[12])
+               +       q[13]  + R32_5(q[14]) +       q[15]  + R32_6(q[16])
+               +       q[17]  + R32_7(q[18]) + S32_4(q[19]) + S32_5(q[20]);
+/* expand_2( 6) */
+       q[22] = 
+               ((  ROTL32(((uint32_t*)m)[ 6], 7) 
+                 + ROTL32(((uint32_t*)m)[ 9], 10) 
+                 - ROTL32(((uint32_t*)m)[ 0], 1) 
+                 + 0x7555554eUL 
+                )^ ((uint32_t*)h)[13] 
+               )
+               +       q[ 6]  + R32_1(q[ 7]) +       q[ 8]  + R32_2(q[ 9])
+               +       q[10]  + R32_3(q[11]) +       q[12]  + R32_4(q[13])
+               +       q[14]  + R32_5(q[15]) +       q[16]  + R32_6(q[17])
+               +       q[18]  + R32_7(q[19]) + S32_4(q[20]) + S32_5(q[21]);
+/* expand_2( 7) */
+       q[23] = 
+               ((  ROTL32(((uint32_t*)m)[ 7], 8) 
+                 + ROTL32(((uint32_t*)m)[10], 11) 
+                 - ROTL32(((uint32_t*)m)[ 1], 2) 
+                 + 0x7aaaaaa3UL 
+                )^ ((uint32_t*)h)[14] 
+               )
+               +       q[ 7]  + R32_1(q[ 8]) +       q[ 9]  + R32_2(q[10])
+               +       q[11]  + R32_3(q[12]) +       q[13]  + R32_4(q[14])
+               +       q[15]  + R32_5(q[16]) +       q[17]  + R32_6(q[18])
+               +       q[19]  + R32_7(q[20]) + S32_4(q[21]) + S32_5(q[22]);
+/* expand_2( 8) */
+       q[24] = 
+               ((  ROTL32(((uint32_t*)m)[ 8], 9) 
+                 + ROTL32(((uint32_t*)m)[11], 12) 
+                 - ROTL32(((uint32_t*)m)[ 2], 3) 
+                 + 0x7ffffff8UL 
+                )^ ((uint32_t*)h)[15] 
+               )
+               +       q[ 8]  + R32_1(q[ 9]) +       q[10]  + R32_2(q[11])
+               +       q[12]  + R32_3(q[13]) +       q[14]  + R32_4(q[15])
+               +       q[16]  + R32_5(q[17]) +       q[18]  + R32_6(q[19])
+               +       q[20]  + R32_7(q[21]) + S32_4(q[22]) + S32_5(q[23]);
+/* expand_2( 9) */
+       q[25] = 
+               ((  ROTL32(((uint32_t*)m)[ 9], 10) 
+                 + ROTL32(((uint32_t*)m)[12], 13) 
+                 - ROTL32(((uint32_t*)m)[ 3], 4) 
+                 + 0x8555554dUL 
+                )^ ((uint32_t*)h)[ 0] 
+               )
+               +       q[ 9]  + R32_1(q[10]) +       q[11]  + R32_2(q[12])
+               +       q[13]  + R32_3(q[14]) +       q[15]  + R32_4(q[16])
+               +       q[17]  + R32_5(q[18]) +       q[19]  + R32_6(q[20])
+               +       q[21]  + R32_7(q[22]) + S32_4(q[23]) + S32_5(q[24]);
+/* expand_2(10) */
+       q[26] = 
+               ((  ROTL32(((uint32_t*)m)[10], 11) 
+                 + ROTL32(((uint32_t*)m)[13], 14) 
+                 - ROTL32(((uint32_t*)m)[ 4], 5) 
+                 + 0x8aaaaaa2UL 
+                )^ ((uint32_t*)h)[ 1] 
+               )
+               +       q[10]  + R32_1(q[11]) +       q[12]  + R32_2(q[13])
+               +       q[14]  + R32_3(q[15]) +       q[16]  + R32_4(q[17])
+               +       q[18]  + R32_5(q[19]) +       q[20]  + R32_6(q[21])
+               +       q[22]  + R32_7(q[23]) + S32_4(q[24]) + S32_5(q[25]);
+/* expand_2(11) */
+       q[27] = 
+               ((  ROTL32(((uint32_t*)m)[11], 12) 
+                 + ROTL32(((uint32_t*)m)[14], 15) 
+                 - ROTL32(((uint32_t*)m)[ 5], 6) 
+                 + 0x8ffffff7UL 
+                )^ ((uint32_t*)h)[ 2] 
+               )
+               +       q[11]  + R32_1(q[12]) +       q[13]  + R32_2(q[14])
+               +       q[15]  + R32_3(q[16]) +       q[17]  + R32_4(q[18])
+               +       q[19]  + R32_5(q[20]) +       q[21]  + R32_6(q[22])
+               +       q[23]  + R32_7(q[24]) + S32_4(q[25]) + S32_5(q[26]);
+/* expand_2(12) */
+       q[28] = 
+               ((  ROTL32(((uint32_t*)m)[12], 13) 
+                 + ROTL32(((uint32_t*)m)[15], 16) 
+                 - ROTL32(((uint32_t*)m)[ 6], 7) 
+                 + 0x9555554cUL 
+                )^ ((uint32_t*)h)[ 3] 
+               )
+               +       q[12]  + R32_1(q[13]) +       q[14]  + R32_2(q[15])
+               +       q[16]  + R32_3(q[17]) +       q[18]  + R32_4(q[19])
+               +       q[20]  + R32_5(q[21]) +       q[22]  + R32_6(q[23])
+               +       q[24]  + R32_7(q[25]) + S32_4(q[26]) + S32_5(q[27]);
+/* expand_2(13) */
+       q[29] = 
+               ((  ROTL32(((uint32_t*)m)[13], 14) 
+                 + ROTL32(((uint32_t*)m)[ 0], 1) 
+                 - ROTL32(((uint32_t*)m)[ 7], 8) 
+                 + 0x9aaaaaa1UL 
+                )^ ((uint32_t*)h)[ 4] 
+               )
+               +       q[13]  + R32_1(q[14]) +       q[15]  + R32_2(q[16])
+               +       q[17]  + R32_3(q[18]) +       q[19]  + R32_4(q[20])
+               +       q[21]  + R32_5(q[22]) +       q[23]  + R32_6(q[24])
+               +       q[25]  + R32_7(q[26]) + S32_4(q[27]) + S32_5(q[28]);
+/* expand_2(14) */
+       q[30] = 
+               ((  ROTL32(((uint32_t*)m)[14], 15) 
+                 + ROTL32(((uint32_t*)m)[ 1], 2) 
+                 - ROTL32(((uint32_t*)m)[ 8], 9) 
+                 + 0x9ffffff6UL 
+                )^ ((uint32_t*)h)[ 5] 
+               )
+               +       q[14]  + R32_1(q[15]) +       q[16]  + R32_2(q[17])
+               +       q[18]  + R32_3(q[19]) +       q[20]  + R32_4(q[21])
+               +       q[22]  + R32_5(q[23]) +       q[24]  + R32_6(q[25])
+               +       q[26]  + R32_7(q[27]) + S32_4(q[28]) + S32_5(q[29]);
+/* expand_2(15) */
+       q[31] = 
+               ((  ROTL32(((uint32_t*)m)[15], 16) 
+                 + ROTL32(((uint32_t*)m)[ 2], 3) 
+                 - ROTL32(((uint32_t*)m)[ 9], 10) 
+                 + 0xa555554bUL 
+                )^ ((uint32_t*)h)[ 6] 
+               )
+               +       q[15]  + R32_1(q[16]) +       q[17]  + R32_2(q[18])
+               +       q[19]  + R32_3(q[20]) +       q[21]  + R32_4(q[22])
+               +       q[23]  + R32_5(q[24]) +       q[25]  + R32_6(q[26])
+               +       q[27]  + R32_7(q[28]) + S32_4(q[29]) + S32_5(q[30]);
+}
+
+/* END of automatic generated code */
+
diff --git a/bmw/f1_autogen_large.c b/bmw/f1_autogen_large.c
new file mode 100644 (file)
index 0000000..75eff07
--- /dev/null
@@ -0,0 +1,200 @@
+/* BEGIN of automatic generated code */
+
+static inline
+void bmw_large_f1(uint64_t* q, const void* m, const void* h){ 
+/* expand_1( 0) */
+       q[16] = 
+               ((  ROTL64(((uint64_t*)m)[ 0], 1) 
+                 + ROTL64(((uint64_t*)m)[ 3], 4) 
+                 - ROTL64(((uint64_t*)m)[10], 11) 
+                 + 0x5555555555555550ULL 
+                )^ ((uint64_t*)h)[ 7] 
+               )
+               + S64_1(q[ 0]) + S64_2(q[ 1]) + S64_3(q[ 2]) + S64_0(q[ 3])
+               + S64_1(q[ 4]) + S64_2(q[ 5]) + S64_3(q[ 6]) + S64_0(q[ 7])
+               + S64_1(q[ 8]) + S64_2(q[ 9]) + S64_3(q[10]) + S64_0(q[11])
+               + S64_1(q[12]) + S64_2(q[13]) + S64_3(q[14]) + S64_0(q[15]);
+/* expand_1( 1) */
+       q[17] = 
+               ((  ROTL64(((uint64_t*)m)[ 1], 2) 
+                 + ROTL64(((uint64_t*)m)[ 4], 5) 
+                 - ROTL64(((uint64_t*)m)[11], 12) 
+                 + 0x5aaaaaaaaaaaaaa5ULL 
+                )^ ((uint64_t*)h)[ 8] 
+               )
+               + S64_1(q[ 1]) + S64_2(q[ 2]) + S64_3(q[ 3]) + S64_0(q[ 4])
+               + S64_1(q[ 5]) + S64_2(q[ 6]) + S64_3(q[ 7]) + S64_0(q[ 8])
+               + S64_1(q[ 9]) + S64_2(q[10]) + S64_3(q[11]) + S64_0(q[12])
+               + S64_1(q[13]) + S64_2(q[14]) + S64_3(q[15]) + S64_0(q[16]);
+/* expand_2( 2) */
+       q[18] = 
+               ((  ROTL64(((uint64_t*)m)[ 2], 3) 
+                 + ROTL64(((uint64_t*)m)[ 5], 6) 
+                 - ROTL64(((uint64_t*)m)[12], 13) 
+                 + 0x5ffffffffffffffaULL 
+                )^ ((uint64_t*)h)[ 9] 
+               )
+               +       q[ 2]  + R64_1(q[ 3]) +       q[ 4]  + R64_2(q[ 5])
+               +       q[ 6]  + R64_3(q[ 7]) +       q[ 8]  + R64_4(q[ 9])
+               +       q[10]  + R64_5(q[11]) +       q[12]  + R64_6(q[13])
+               +       q[14]  + R64_7(q[15]) + S64_4(q[16]) + S64_5(q[17]);
+/* expand_2( 3) */
+       q[19] = 
+               ((  ROTL64(((uint64_t*)m)[ 3], 4) 
+                 + ROTL64(((uint64_t*)m)[ 6], 7) 
+                 - ROTL64(((uint64_t*)m)[13], 14) 
+                 + 0x655555555555554fULL 
+                )^ ((uint64_t*)h)[10] 
+               )
+               +       q[ 3]  + R64_1(q[ 4]) +       q[ 5]  + R64_2(q[ 6])
+               +       q[ 7]  + R64_3(q[ 8]) +       q[ 9]  + R64_4(q[10])
+               +       q[11]  + R64_5(q[12]) +       q[13]  + R64_6(q[14])
+               +       q[15]  + R64_7(q[16]) + S64_4(q[17]) + S64_5(q[18]);
+/* expand_2( 4) */
+       q[20] = 
+               ((  ROTL64(((uint64_t*)m)[ 4], 5) 
+                 + ROTL64(((uint64_t*)m)[ 7], 8) 
+                 - ROTL64(((uint64_t*)m)[14], 15) 
+                 + 0x6aaaaaaaaaaaaaa4ULL 
+                )^ ((uint64_t*)h)[11] 
+               )
+               +       q[ 4]  + R64_1(q[ 5]) +       q[ 6]  + R64_2(q[ 7])
+               +       q[ 8]  + R64_3(q[ 9]) +       q[10]  + R64_4(q[11])
+               +       q[12]  + R64_5(q[13]) +       q[14]  + R64_6(q[15])
+               +       q[16]  + R64_7(q[17]) + S64_4(q[18]) + S64_5(q[19]);
+/* expand_2( 5) */
+       q[21] = 
+               ((  ROTL64(((uint64_t*)m)[ 5], 6) 
+                 + ROTL64(((uint64_t*)m)[ 8], 9) 
+                 - ROTL64(((uint64_t*)m)[15], 16) 
+                 + 0x6ffffffffffffff9ULL 
+                )^ ((uint64_t*)h)[12] 
+               )
+               +       q[ 5]  + R64_1(q[ 6]) +       q[ 7]  + R64_2(q[ 8])
+               +       q[ 9]  + R64_3(q[10]) +       q[11]  + R64_4(q[12])
+               +       q[13]  + R64_5(q[14]) +       q[15]  + R64_6(q[16])
+               +       q[17]  + R64_7(q[18]) + S64_4(q[19]) + S64_5(q[20]);
+/* expand_2( 6) */
+       q[22] = 
+               ((  ROTL64(((uint64_t*)m)[ 6], 7) 
+                 + ROTL64(((uint64_t*)m)[ 9], 10) 
+                 - ROTL64(((uint64_t*)m)[ 0], 1) 
+                 + 0x755555555555554eULL 
+                )^ ((uint64_t*)h)[13] 
+               )
+               +       q[ 6]  + R64_1(q[ 7]) +       q[ 8]  + R64_2(q[ 9])
+               +       q[10]  + R64_3(q[11]) +       q[12]  + R64_4(q[13])
+               +       q[14]  + R64_5(q[15]) +       q[16]  + R64_6(q[17])
+               +       q[18]  + R64_7(q[19]) + S64_4(q[20]) + S64_5(q[21]);
+/* expand_2( 7) */
+       q[23] = 
+               ((  ROTL64(((uint64_t*)m)[ 7], 8) 
+                 + ROTL64(((uint64_t*)m)[10], 11) 
+                 - ROTL64(((uint64_t*)m)[ 1], 2) 
+                 + 0x7aaaaaaaaaaaaaa3ULL 
+                )^ ((uint64_t*)h)[14] 
+               )
+               +       q[ 7]  + R64_1(q[ 8]) +       q[ 9]  + R64_2(q[10])
+               +       q[11]  + R64_3(q[12]) +       q[13]  + R64_4(q[14])
+               +       q[15]  + R64_5(q[16]) +       q[17]  + R64_6(q[18])
+               +       q[19]  + R64_7(q[20]) + S64_4(q[21]) + S64_5(q[22]);
+/* expand_2( 8) */
+       q[24] = 
+               ((  ROTL64(((uint64_t*)m)[ 8], 9) 
+                 + ROTL64(((uint64_t*)m)[11], 12) 
+                 - ROTL64(((uint64_t*)m)[ 2], 3) 
+                 + 0x7ffffffffffffff8ULL 
+                )^ ((uint64_t*)h)[15] 
+               )
+               +       q[ 8]  + R64_1(q[ 9]) +       q[10]  + R64_2(q[11])
+               +       q[12]  + R64_3(q[13]) +       q[14]  + R64_4(q[15])
+               +       q[16]  + R64_5(q[17]) +       q[18]  + R64_6(q[19])
+               +       q[20]  + R64_7(q[21]) + S64_4(q[22]) + S64_5(q[23]);
+/* expand_2( 9) */
+       q[25] = 
+               ((  ROTL64(((uint64_t*)m)[ 9], 10) 
+                 + ROTL64(((uint64_t*)m)[12], 13) 
+                 - ROTL64(((uint64_t*)m)[ 3], 4) 
+                 + 0x855555555555554dULL 
+                )^ ((uint64_t*)h)[ 0] 
+               )
+               +       q[ 9]  + R64_1(q[10]) +       q[11]  + R64_2(q[12])
+               +       q[13]  + R64_3(q[14]) +       q[15]  + R64_4(q[16])
+               +       q[17]  + R64_5(q[18]) +       q[19]  + R64_6(q[20])
+               +       q[21]  + R64_7(q[22]) + S64_4(q[23]) + S64_5(q[24]);
+/* expand_2(10) */
+       q[26] = 
+               ((  ROTL64(((uint64_t*)m)[10], 11) 
+                 + ROTL64(((uint64_t*)m)[13], 14) 
+                 - ROTL64(((uint64_t*)m)[ 4], 5) 
+                 + 0x8aaaaaaaaaaaaaa2ULL 
+                )^ ((uint64_t*)h)[ 1] 
+               )
+               +       q[10]  + R64_1(q[11]) +       q[12]  + R64_2(q[13])
+               +       q[14]  + R64_3(q[15]) +       q[16]  + R64_4(q[17])
+               +       q[18]  + R64_5(q[19]) +       q[20]  + R64_6(q[21])
+               +       q[22]  + R64_7(q[23]) + S64_4(q[24]) + S64_5(q[25]);
+/* expand_2(11) */
+       q[27] = 
+               ((  ROTL64(((uint64_t*)m)[11], 12) 
+                 + ROTL64(((uint64_t*)m)[14], 15) 
+                 - ROTL64(((uint64_t*)m)[ 5], 6) 
+                 + 0x8ffffffffffffff7ULL 
+                )^ ((uint64_t*)h)[ 2] 
+               )
+               +       q[11]  + R64_1(q[12]) +       q[13]  + R64_2(q[14])
+               +       q[15]  + R64_3(q[16]) +       q[17]  + R64_4(q[18])
+               +       q[19]  + R64_5(q[20]) +       q[21]  + R64_6(q[22])
+               +       q[23]  + R64_7(q[24]) + S64_4(q[25]) + S64_5(q[26]);
+/* expand_2(12) */
+       q[28] = 
+               ((  ROTL64(((uint64_t*)m)[12], 13) 
+                 + ROTL64(((uint64_t*)m)[15], 16) 
+                 - ROTL64(((uint64_t*)m)[ 6], 7) 
+                 + 0x955555555555554cULL 
+                )^ ((uint64_t*)h)[ 3] 
+               )
+               +       q[12]  + R64_1(q[13]) +       q[14]  + R64_2(q[15])
+               +       q[16]  + R64_3(q[17]) +       q[18]  + R64_4(q[19])
+               +       q[20]  + R64_5(q[21]) +       q[22]  + R64_6(q[23])
+               +       q[24]  + R64_7(q[25]) + S64_4(q[26]) + S64_5(q[27]);
+/* expand_2(13) */
+       q[29] = 
+               ((  ROTL64(((uint64_t*)m)[13], 14) 
+                 + ROTL64(((uint64_t*)m)[ 0], 1) 
+                 - ROTL64(((uint64_t*)m)[ 7], 8) 
+                 + 0x9aaaaaaaaaaaaaa1ULL 
+                )^ ((uint64_t*)h)[ 4] 
+               )
+               +       q[13]  + R64_1(q[14]) +       q[15]  + R64_2(q[16])
+               +       q[17]  + R64_3(q[18]) +       q[19]  + R64_4(q[20])
+               +       q[21]  + R64_5(q[22]) +       q[23]  + R64_6(q[24])
+               +       q[25]  + R64_7(q[26]) + S64_4(q[27]) + S64_5(q[28]);
+/* expand_2(14) */
+       q[30] = 
+               ((  ROTL64(((uint64_t*)m)[14], 15) 
+                 + ROTL64(((uint64_t*)m)[ 1], 2) 
+                 - ROTL64(((uint64_t*)m)[ 8], 9) 
+                 + 0x9ffffffffffffff6ULL 
+                )^ ((uint64_t*)h)[ 5] 
+               )
+               +       q[14]  + R64_1(q[15]) +       q[16]  + R64_2(q[17])
+               +       q[18]  + R64_3(q[19]) +       q[20]  + R64_4(q[21])
+               +       q[22]  + R64_5(q[23]) +       q[24]  + R64_6(q[25])
+               +       q[26]  + R64_7(q[27]) + S64_4(q[28]) + S64_5(q[29]);
+/* expand_2(15) */
+       q[31] = 
+               ((  ROTL64(((uint64_t*)m)[15], 16) 
+                 + ROTL64(((uint64_t*)m)[ 2], 3) 
+                 - ROTL64(((uint64_t*)m)[ 9], 10) 
+                 + 0xa55555555555554bULL 
+                )^ ((uint64_t*)h)[ 6] 
+               )
+               +       q[15]  + R64_1(q[16]) +       q[17]  + R64_2(q[18])
+               +       q[19]  + R64_3(q[20]) +       q[21]  + R64_4(q[22])
+               +       q[23]  + R64_5(q[24]) +       q[25]  + R64_6(q[26])
+               +       q[27]  + R64_7(q[28]) + S64_4(q[29]) + S64_5(q[30]);
+}
+
+/* END of automatic generated code */
+
index 853f3593e7da3f141749af55d316fc8ad6a26a58..db1f16d1d877a6721d43394b8cd2d3362ffd0be0 100644 (file)
 */
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
-// #define F_CPU 20000000
-// #define F_CPU 16000000         /* oscillator-frequency in Hz */
-// #define F_CPU 14745600
-#define F_CPU 20000000 /* this is out of spec but lets try it */
 
-#define DEBUG_METHOD uart
+#include "sysclock.h"
 
-#include "uart_defines.h"
-
-#define UART0_I 1
-#define UART0_BAUD_RATE  115200
-#define UART0_PARATY     UART_PARATY_NONE
-#define UART0_STOPBITS   UART_STOPBITS_ONE
-#define UART0_DATABITS   UART_DATABITS_8
-#define UART0_RXBUFFER_SIZE 120
-#define UART0_TXBUFFER_SIZE 120
-#define UART0_SWFLOWCTRL     1
-#define UART0_THRESH_LOW     0
-#define UART0_THRESH_HIGH   32
-
-#define CLI_AUTO_HELP
+#define SYS_FREQ SYS_FREQ_50MHZ000
 
 #endif
 
index 5ac3cad15f5a3efee2f3eb069138c1b0d915b5d0..7a6fc12c5d7c7ca1431e04442e6b7640a2ecca13 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -153,7 +154,7 @@ cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index c027d74e1afd6f682e05b0cfaacb22a3a2b60607..5134743548ae1e8d6156ad75bb174334449d5a8b 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>\r
 #include <stdlib.h>\r
 #include <string.h>\r
+#include "config.h"\r
 #include "cli.h"\r
 #include "dump.h"\r
 #include "uart_lowlevel.h"\r
@@ -169,7 +170,7 @@ cmdlist_entry_t cmdlist[] = {
 };\r
 \r
 int main(void) {\r
-       sysclk_set_freq(SYS_FREQ_40MHZ000);\r
+       sysclk_set_freq(SYS_FREQ);\r
        sysclk_mosc_verify_enable();\r
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);\r
     gptm_set_timer_32periodic(TIMER0);\r
index ef96612d1e4b6fd23d9ebf4ad17578425a3dc955..e4e7ce7127101f18843da2ececc0675b6a9a6745 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -112,7 +113,7 @@ cmdlist_entry_t cmdlist[]  = {
 
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index 79476c9606026de358b397c4107abb0c91f9206b..a754c2f75480123d8dda3a056909838f517e87f0 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -183,7 +184,7 @@ cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index cc3b3f00d26c3d46f8cdb2d9f5aad466417f374d..3ed24091d53470794ba2e36462787195a788028d 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -156,7 +157,7 @@ cmdlist_entry_t cmdlist[]  = {
 
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index 7686855a0bedd2e80a015ed83cf0e6d2949fd3c3..f6ba4de74d98ad8f66215ed8c183eb68e2dcef16 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -109,7 +110,7 @@ cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index e40a077502b2156c094b5c61e0a0a31813bfaae5..17e67092eb42a63eb4f37dd64154e7133435731c 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -219,7 +220,7 @@ const cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index 6b6f41ebdd0fddcbdc4db9d8ed351db49a951b8a..872e071279f101fed593d7bf180d87e9ce146506 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -163,7 +164,7 @@ const cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index 6e4b67bb9f3297474424137e0b495cf647f8e4b8..27a524aa3fc0fbc1a6ff3818f1671b99c46fba43 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -227,7 +228,7 @@ cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);
index 7bc66e64bed5e0b4e354cfd1ba3371668fe249fd..b52fd43df6d7e11b4d424634b40ef1a362af48c0 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config.h"
 #include "cli.h"
 #include "dump.h"
 #include "uart_lowlevel.h"
@@ -283,7 +284,7 @@ cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_80MHz();
+       sysclk_set_freq(SYS_FREQ);
        sysclk_mosc_verify_enable();
     uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
     gptm_set_timer_32periodic(TIMER0);