Browse Source

Add benchmarks

Youngbin Kim 1 year ago
parent
commit
d5850e511d
42 changed files with 2675 additions and 11 deletions
  1. 2 1
      .gitignore
  2. 1 1
      CMakeLists.txt
  3. 11 0
      Core/Inc/benchmarks/aes/aes.h
  4. 13 0
      Core/Inc/benchmarks/basicmath/pi.h
  5. 55 0
      Core/Inc/benchmarks/basicmath/round.h
  6. 75 0
      Core/Inc/benchmarks/basicmath/snipmath.h
  7. 37 0
      Core/Inc/benchmarks/basicmath/sniptype.h
  8. 7 6
      Core/Inc/benchmarks/benchmark_driver.h
  9. 59 0
      Core/Inc/benchmarks/crc/crc.h
  10. 37 0
      Core/Inc/benchmarks/crc/sniptype.h
  11. 57 0
      Core/Inc/benchmarks/fft/ddc.h
  12. 16 0
      Core/Inc/benchmarks/fft/ddcmath.h
  13. 7 0
      Core/Inc/benchmarks/fft/fft.h
  14. 65 0
      Core/Inc/benchmarks/fft/fourier.h
  15. 31 0
      Core/Inc/benchmarks/sha/sha.h
  16. 385 0
      Core/Src/benchmarks/aes/aes.c
  17. 73 0
      Core/Src/benchmarks/basicmath/basicmath.c
  18. 64 0
      Core/Src/benchmarks/basicmath/cubic.c
  19. 89 0
      Core/Src/benchmarks/basicmath/isqrt.c
  20. 39 0
      Core/Src/benchmarks/basicmath/rad2deg.c
  21. 9 0
      Core/Src/benchmarks/crc/compile_data.sh
  22. 210 0
      Core/Src/benchmarks/crc/crc_32.c
  23. BIN
      Core/Src/benchmarks/crc/crc_input.o
  24. BIN
      Core/Src/benchmarks/crc/small_modified.pcm
  25. BIN
      Core/Src/benchmarks/crc/small_original.pcm
  26. 221 0
      Core/Src/benchmarks/fft/fft.c
  27. 86 0
      Core/Src/benchmarks/fft/fft_original.c
  28. 95 0
      Core/Src/benchmarks/fft/fftmisc.c
  29. 155 0
      Core/Src/benchmarks/fft/fourierf.c
  30. 34 0
      Core/Src/benchmarks/matmul/matmul.c
  31. 9 0
      Core/Src/benchmarks/sha/compile_data.sh
  32. 0 0
      Core/Src/benchmarks/sha/input_small.asc
  33. 0 0
      Core/Src/benchmarks/sha/input_small_original.asc
  34. 18 0
      Core/Src/benchmarks/sha/sha.c
  35. BIN
      Core/Src/benchmarks/sha/sha_input.o
  36. 105 0
      Core/Src/benchmarks/stringsearch/bmhasrch.c
  37. 106 0
      Core/Src/benchmarks/stringsearch/bmhisrch.c
  38. 70 0
      Core/Src/benchmarks/stringsearch/bmhsrch.c
  39. 174 0
      Core/Src/benchmarks/stringsearch/pbmsrch_small.c
  40. 165 0
      Core/Src/benchmarks/stringsearch/stringsearch_local.c
  41. 1 1
      Core/Src/main.c
  42. 94 2
      imc_extension.cmake

+ 2 - 1
.gitignore

@@ -5,4 +5,5 @@
 .vscode
 /Debug/
 imc_freertos_app_m33.launch
-build/
+build/
+build.sh

+ 1 - 1
CMakeLists.txt

@@ -162,7 +162,7 @@ set(CMAKE_ASM_FLAGS "${COMMON_CC_FLAGS} ${ASM_OPTIONS}")
 
 # linker options
 set(ARM_CORTEXM_BUILTINS "-L${ARM_CORTEXM_BUILTINS_DIR}")
-set(LD_ADDITIONAL_FILES "${ARM_CORTEXM_BUILTINS_DIR}/crti.o ${ARM_CORTEXM_BUILTINS_DIR}/crtn.o")
+set(LD_ADDITIONAL_FILES "${ARM_CORTEXM_BUILTINS_DIR}/crti.o ${ARM_CORTEXM_BUILTINS_DIR}/crtn.o ${IMC_LINK_OBJS}")
 
 set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/STM32L552ZETX_FLASH.ld")
 set(CMAKE_EXE_LINKER_FLAGS "${LD_ADDITIONAL_FILES} -T ${LINKER_SCRIPT}")

+ 11 - 0
Core/Inc/benchmarks/aes/aes.h

@@ -0,0 +1,11 @@
+#include <stdint.h>
+
+#define AES_KEYLEN 16 // Key length in bytes
+#define AES_keyExpSize 176
+#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only
+
+struct AES_ctx
+{
+    uint8_t RoundKey[AES_keyExpSize];
+    uint8_t Iv[AES_BLOCKLEN];
+};

+ 13 - 0
Core/Inc/benchmarks/basicmath/pi.h

@@ -0,0 +1,13 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+#ifndef PI__H
+#define PI__H
+
+#ifndef PI
+ #define PI         (4*atan(1))
+#endif
+
+#define deg2rad(d) ((d)*PI/180)
+#define rad2deg(r) ((r)*180/PI)
+
+#endif /* PI__H */

+ 55 - 0
Core/Inc/benchmarks/basicmath/round.h

@@ -0,0 +1,55 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+** rounding macros by Dave Knapp, Thad Smith, Jon Strayer, & Bob Stout
+*/
+
+#ifndef ROUND__H
+#define ROUND__H
+
+#include <math.h>
+
+#if defined(__cplusplus) && __cplusplus
+
+/*
+** Safe C++ inline versions
+*/
+
+/* round to integer */
+
+inline int iround(double x)
+{
+      return (int)floor(x + 0.5);
+}
+
+/* round number n to d decimal points */
+
+inline double fround(double n, unsigned d)
+{
+      return floor(n * pow(10., d) + .5) / pow(10., d);
+}
+
+#else
+
+/*
+** NOTE: These C macro versions are unsafe since arguments are referenced
+**       more than once.
+**
+**       Avoid using these with expression arguments to be safe.
+*/
+
+/*
+** round to integer
+*/
+
+#define iround(x) floor((x) + 0.5)
+
+/*
+** round number n to d decimal points
+*/
+
+#define fround(n,d) (floor((n)*pow(10.,(d))+.5)/pow(10.,(d)))
+
+#endif
+
+#endif /* ROUND__H */

+ 75 - 0
Core/Inc/benchmarks/basicmath/snipmath.h

@@ -0,0 +1,75 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  SNIPMATH.H - Header file for SNIPPETS math functions and macros
+*/
+
+#ifndef SNIPMATH__H
+#define SNIPMATH__H
+
+#include <math.h>
+#include "benchmarks/basicmath/sniptype.h"
+#include "benchmarks/basicmath/round.h"
+
+/*
+**  Callable library functions begin here
+*/
+
+void    SetBCDLen(int n);                             /* Bcdl.C         */
+long    BCDtoLong(char *BCDNum);                      /* Bcdl.C         */
+void    LongtoBCD(long num, char BCDNum[]);           /* Bcdl.C         */
+double  bcd_to_double(void *buf, size_t len,          /* Bcdd.C         */
+                      int digits);
+int     double_to_bcd(double arg, char *buf,          /* Bcdd.C         */
+                      size_t length, size_t digits );
+DWORD   ncomb1 (int n, int m);                        /* Combin.C       */
+DWORD   ncomb2 (int n, int m);                        /* Combin.C       */
+void    SolveCubic(double a, double b, double c,      /* Cubic.C        */
+                  double d, int *solutions,
+                  double *x);
+DWORD   dbl2ulong(double t);                          /* Dbl2Long.C     */
+long    dbl2long(double t);                           /* Dbl2Long.C     */
+double  dround(double x);                             /* Dblround.C     */
+
+/* Use #defines for Permutations and Combinations     -- Factoryl.C     */
+
+#define log10P(n,r) (log10factorial(n)-log10factorial((n)-(r)))
+#define log10C(n,r) (log10P((n),(r))-log10factorial(r))
+
+double  log10factorial(double N);                     /* Factoryl.C     */
+
+double  fibo(unsigned short term);                    /* Fibo.C         */
+double  frandom(int n);                               /* Frand.C        */
+double  ipow(double x, int n);                        /* Ipow.C         */
+int     ispow2(int x);                                /* Ispow2.C       */
+long    double ldfloor(long double a);                /* Ldfloor.C      */
+int     initlogscale(long dmax, long rmax);           /* Logscale.C     */
+long    logscale(long d);                             /* Logscale.C     */
+
+float   MSBINToIEEE(float f);                         /* Msb2Ieee.C     */
+float   IEEEToMSBIN(float f);                         /* Msb2Ieee.C     */
+int     perm_index (char pit[], int size);            /* Perm_Idx.C     */
+int     round_div(int n, int d);                      /* Rnd_Div.C      */
+long    round_ldiv(long n, long d);                   /* Rnd_Div.C      */
+double  rad2deg(double rad);                          /* Rad2Deg.C      */
+double  deg2rad(double deg);                          /* Rad2Deg.C      */
+
+#include "pi.h"
+#ifndef PHI
+ #define PHI      ((1.0+sqrt(5.0))/2.0)         /* the golden number    */
+ #define INV_PHI  (1.0/PHI)                     /* the golden ratio     */
+#endif
+
+/*
+**  File: ISQRT.C
+*/
+
+struct int_sqrt {
+      unsigned sqrt,
+               frac;
+};
+
+void usqrt(unsigned long x, struct int_sqrt *q);
+
+
+#endif /* SNIPMATH__H */

+ 37 - 0
Core/Inc/benchmarks/basicmath/sniptype.h

@@ -0,0 +1,37 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  SNIPTYPE.H - Include file for SNIPPETS data types and commonly used macros
+*/
+
+#ifndef SNIPTYPE__H
+#define SNIPTYPE__H
+
+#include <stdlib.h>                             /* For free()           */
+#include <string.h>                             /* For NULL & strlen()  */
+
+typedef enum {Error_ = -1, Success_, False_ = 0, True_} Boolean_T;
+
+/*#if !defined(WIN32) && !defined(_WIN32) && !defined(__NT__) \
+      && !defined(_WINDOWS)
+      #if !defined(OS2)*/
+  typedef unsigned char  BYTE;
+  typedef unsigned long  DWORD;
+/* #endif*/
+ typedef unsigned short WORD;
+/*#else
+ #define WIN32_LEAN_AND_MEAN
+ #define NOGDI
+ #define NOSERVICE
+ #undef INC_OLE1
+ #undef INC_OLE2
+ #include <windows.h>
+ #define HUGE
+ #endif*/
+
+#define NUL '\0'
+#define LAST_CHAR(s) (((char *)s)[strlen(s) - 1])
+#define TOBOOL(x) (!(!(x)))
+#define FREE(p) (free(p),(p)=NULL)
+
+#endif /* SNIPTYPE__H */

+ 7 - 6
Core/Inc/benchmarks/benchmark_driver.h

@@ -1,18 +1,19 @@
 #ifndef __BENCHMARK_DRIVER_H
 #define __BENCHMARK_DRIVER_H
 
-// void vStringSearch();
-// void vBasicMath();
-// void vCrc();
-// void vFFT();
-// void vSha();
+void vStringSearch();
+void vBasicMath();
+void vCrc();
+void vFFT();
+void vSha();
 // void vEnergyLevelTest();
 // void vTest_nvm();
 // void vCustom();
 // void vMemAccessPatternTest();
-// void vMatMul();
+void vMatMul();
 void vConv2d();
 void adc_demo();
+void vAes();
 
 void vBenchmarkDriver(void *_benchmark);
 

+ 59 - 0
Core/Inc/benchmarks/crc/crc.h

@@ -0,0 +1,59 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  CRC.H - header file for SNIPPETS CRC and checksum functions
+*/
+
+#ifndef CRC__H
+#define CRC__H
+
+#include <stdlib.h>           /* For size_t                 */
+#include "sniptype.h"         /* For BYTE, WORD, DWORD      */
+
+/*
+**  File: ARCCRC16.C
+*/
+
+void init_crc_table(void);
+WORD crc_calc(WORD crc, char *buf, unsigned nbytes);
+void do_file(char *fn);
+
+/*
+**  File: CRC-16.C
+*/
+
+WORD crc16(char *data_p, WORD length);
+
+/*
+**  File: CRC-16F.C
+*/
+
+WORD updcrc(WORD icrc, BYTE *icp, size_t icnt);
+
+/*
+**  File: CRC_32.C
+*/
+
+#define UPDC32(octet,crc) (crc_32_tab[((crc)^((BYTE)octet)) & 0xff] ^ ((crc) >> 8))
+
+DWORD updateCRC32(unsigned char ch, DWORD crc);
+Boolean_T crc32file(char *name, DWORD *crc, long *charcnt);
+DWORD crc32buf(char *buf, size_t len);
+
+/*
+**  File: CHECKSUM.C
+*/
+
+unsigned checksum(void *buffer, size_t len, unsigned int seed);
+
+/*
+**  File: CHECKEXE.C
+*/
+
+void checkexe(char *fname);
+
+void vCrc();
+void vCrcDriver();
+
+
+#endif /* CRC__H */

+ 37 - 0
Core/Inc/benchmarks/crc/sniptype.h

@@ -0,0 +1,37 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  SNIPTYPE.H - Include file for SNIPPETS data types and commonly used macros
+*/
+
+#ifndef SNIPTYPE__H
+#define SNIPTYPE__H
+
+#include <stdlib.h>                             /* For free()           */
+#include <string.h>                             /* For NULL & strlen()  */
+
+typedef enum {Error_ = -1, Success_, False_ = 0, True_} Boolean_T;
+
+/*#if !defined(WIN32) && !defined(_WIN32) && !defined(__NT__) \
+      && !defined(_WINDOWS)
+      #if !defined(OS2)*/
+  typedef unsigned char  BYTE;
+  typedef unsigned long  DWORD;
+/* #endif*/
+ typedef unsigned short WORD;
+/*#else
+ #define WIN32_LEAN_AND_MEAN
+ #define NOGDI
+ #define NOSERVICE
+ #undef INC_OLE1
+ #undef INC_OLE2
+ #include <windows.h>
+ #define HUGE
+ #endif*/
+
+#define NUL '\0'
+#define LAST_CHAR(s) (((char *)s)[strlen(s) - 1])
+#define TOBOOL(x) (!(!(x)))
+#define FREE(p) (free(p),(p)=NULL)
+
+#endif /* SNIPTYPE__H */

+ 57 - 0
Core/Inc/benchmarks/fft/ddc.h

@@ -0,0 +1,57 @@
+/*============================================================================
+
+	 ddc.h  -  Don Cross,  October 1992.
+
+	 Generic ddclib stuff.
+
+============================================================================*/
+
+#ifndef __DDC_DDC_H
+#define __DDC_DDC_H
+
+// If you add something to DDCRET, please add the appropriate string
+// to the function DDCRET_String() in the file 'source\ddcret.cpp'.
+
+enum DDCRET
+{
+   DDC_SUCCESS,           // The operation succeded
+   DDC_FAILURE,           // The operation failed for unspecified reasons
+   DDC_OUT_OF_MEMORY,     // Operation failed due to running out of memory
+   DDC_FILE_ERROR,        // Operation encountered file I/O error
+   DDC_INVALID_CALL,      // Operation was called with invalid parameters
+   DDC_USER_ABORT,        // Operation was aborted by the user
+   DDC_INVALID_FILE       // File format does not match
+};
+
+
+const char *DDCRET_String ( DDCRET );   // See source\ddcret.cpp
+
+
+#define  TRUE     1
+#define  FALSE    0
+
+typedef int dBOOLEAN;
+
+typedef unsigned char BYTE;
+
+typedef unsigned char        UINT8;
+typedef signed   char        INT8;
+
+typedef unsigned short int   UINT16;
+typedef signed   short int   INT16;
+typedef unsigned long  int   UINT32;
+typedef signed   long  int   INT32;
+
+#ifdef __BORLANDC__
+	#if sizeof(UINT16) != 2
+	  #error Need to fix UINT16 and INT16
+	#endif
+
+	#if sizeof(UINT32) != 4
+	  #error Need to fix UINT32 and INT32
+	#endif
+#endif
+
+#endif /* __DDC_DDC_H */
+
+/*--- end of file ddc.h ---*/

+ 16 - 0
Core/Inc/benchmarks/fft/ddcmath.h

@@ -0,0 +1,16 @@
+/*==========================================================================
+
+    ddcmath.h  -  Don Cross <dcross@intersrv.com>, October 1994.
+
+    Contains useful math stuff.
+
+==========================================================================*/
+
+#ifndef __ddcmath_h
+#define __ddcmath_h
+
+#define  DDC_PI  (3.14159265358979323846)
+
+#endif /* __ddcmath_h */
+
+/*--- end of file ddcmath.h ---*/

+ 7 - 0
Core/Inc/benchmarks/fft/fft.h

@@ -0,0 +1,7 @@
+#ifndef __FFT_BENCHMARK_H__
+#define __FFT_BENCHMARK_H__
+
+void vFFT();
+void vFFTDriver();
+
+#endif

+ 65 - 0
Core/Inc/benchmarks/fft/fourier.h

@@ -0,0 +1,65 @@
+/*============================================================================
+
+       fourier.h  -  Don Cross <dcross@intersrv.com>
+
+       http://www.intersrv.com/~dcross/fft.html
+
+       Contains definitions for doing Fourier transforms
+       and inverse Fourier transforms.
+
+============================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+**   fft() computes the Fourier transform or inverse transform
+**   of the complex inputs to produce the complex outputs.
+**   The number of samples must be a power of two to do the
+**   recursive decomposition of the FFT algorithm.
+**   See Chapter 12 of "Numerical Recipes in FORTRAN" by
+**   Press, Teukolsky, Vetterling, and Flannery,
+**   Cambridge University Press.
+**
+**   Notes:  If you pass ImaginaryIn = NULL, this function will "pretend"
+**           that it is an array of all zeroes.  This is convenient for
+**           transforming digital samples of real number data without
+**           wasting memory.
+*/
+
+void fft_double (
+    unsigned  NumSamples,          /* must be a power of 2 */
+    int       InverseTransform,    /* 0=forward FFT, 1=inverse FFT */
+    double   *RealIn,              /* array of input's real samples */
+    double   *ImaginaryIn,         /* array of input's imag samples */
+    double   *RealOut,             /* array of output's reals */
+    double   *ImaginaryOut );      /* array of output's imaginaries */
+
+
+void fft_float (
+    unsigned  NumSamples,          /* must be a power of 2 */
+    int       InverseTransform,    /* 0=forward FFT, 1=inverse FFT */
+    float    *RealIn,              /* array of input's real samples */
+    float    *ImaginaryIn,         /* array of input's imag samples */
+    float    *RealOut,             /* array of output's reals */
+    float    *ImaginaryOut );      /* array of output's imaginaries */
+
+
+int IsPowerOfTwo ( unsigned x );
+unsigned NumberOfBitsNeeded ( unsigned PowerOfTwo );
+unsigned ReverseBits ( unsigned index, unsigned NumBits );
+
+/*
+**   The following function returns an "abstract frequency" of a
+**   given index into a buffer with a given number of frequency samples.
+**   Multiply return value by sampling rate to get frequency expressed in Hz.
+*/
+double Index_to_frequency ( unsigned NumSamples, unsigned Index );
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/*--- end of file fourier.h ---*/

+ 31 - 0
Core/Inc/benchmarks/sha/sha.h

@@ -0,0 +1,31 @@
+#ifndef SHA_H
+#define SHA_H
+
+/* NIST Secure Hash Algorithm */
+/* heavily modified from Peter C. Gutmann's implementation */
+
+/* Useful defines & typedefs */
+
+typedef unsigned char BYTE;
+typedef unsigned long LONG;
+
+#define SHA_BLOCKSIZE		64
+#define SHA_DIGESTSIZE		20
+
+typedef struct {
+    LONG digest[5];		/* message digest */
+    LONG count_lo, count_hi;	/* 64-bit bit count */
+    LONG data[16];		/* SHA data buffer */
+} SHA_INFO;
+
+void sha_init(SHA_INFO *);
+void sha_update(SHA_INFO *, BYTE *, int);
+void sha_final(SHA_INFO *);
+
+void sha_stream(SHA_INFO *);
+void sha_print(SHA_INFO *);
+
+void vSha();
+void vShaDriver();
+
+#endif /* SHA_H */

+ 385 - 0
Core/Src/benchmarks/aes/aes.c

@@ -0,0 +1,385 @@
+#include <string.h> // CBC mode, for memset
+#include <stdio.h>
+#include "benchmarks/aes/aes.h"
+
+// The number of columns comprising a state in AES. This is a constant in AES. Value=4
+#define Nb 4
+#define Nk 4  // The number of 32 bit words in a key.
+#define Nr 10 // The number of rounds in AES Cipher.
+
+#define getSBoxValue(num) (sbox[(num)])
+
+// state - array holding the intermediate results during decryption.
+typedef uint8_t state_t[4][4];
+
+static const uint8_t sbox[256] = {
+    // 0     1    2      3     4    5     6     7      8    9     A      B    C     D     E     F
+    0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+    0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+    0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+    0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+    0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+    0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+    0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+    0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+    0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+    0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+    0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+    0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+    0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+    0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+    0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+    0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16};
+
+static const uint8_t rsbox[256] = {
+    0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
+    0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
+    0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
+    0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
+    0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
+    0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
+    0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
+    0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
+    0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
+    0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
+    0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
+    0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
+    0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
+    0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
+    0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
+    0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d};
+
+static const uint8_t Rcon[11] = {
+    0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36};
+
+static void XorWithIv(uint8_t *buf, const uint8_t *Iv)
+{
+    uint8_t i;
+    for (i = 0; i < AES_BLOCKLEN; ++i) // The block in AES is always 128bit no matter the key size
+    {
+        buf[i] ^= Iv[i];
+    }
+}
+
+// This function adds the round key to state.
+// The round key is added to the state by an XOR function.
+static void AddRoundKey(uint8_t round, state_t *state, const uint8_t *RoundKey)
+{
+    uint8_t i, j;
+    for (i = 0; i < 4; ++i)
+    {
+        for (j = 0; j < 4; ++j)
+        {
+            (*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j];
+        }
+    }
+}
+
+// The SubBytes Function Substitutes the values in the
+// state matrix with values in an S-box.
+static void SubBytes(state_t *state)
+{
+    uint8_t i, j;
+    for (i = 0; i < 4; ++i)
+    {
+        for (j = 0; j < 4; ++j)
+        {
+            (*state)[j][i] = getSBoxValue((*state)[j][i]);
+        }
+    }
+}
+
+// The ShiftRows() function shifts the rows in the state to the left.
+// Each row is shifted with different offset.
+// Offset = Row number. So the first row is not shifted.
+static void ShiftRows(state_t *state)
+{
+    uint8_t temp;
+
+    // Rotate first row 1 columns to left
+    temp = (*state)[0][1];
+    (*state)[0][1] = (*state)[1][1];
+    (*state)[1][1] = (*state)[2][1];
+    (*state)[2][1] = (*state)[3][1];
+    (*state)[3][1] = temp;
+
+    // Rotate second row 2 columns to left
+    temp = (*state)[0][2];
+    (*state)[0][2] = (*state)[2][2];
+    (*state)[2][2] = temp;
+
+    temp = (*state)[1][2];
+    (*state)[1][2] = (*state)[3][2];
+    (*state)[3][2] = temp;
+
+    // Rotate third row 3 columns to left
+    temp = (*state)[0][3];
+    (*state)[0][3] = (*state)[3][3];
+    (*state)[3][3] = (*state)[2][3];
+    (*state)[2][3] = (*state)[1][3];
+    (*state)[1][3] = temp;
+}
+
+static uint8_t xtime(uint8_t x)
+{
+    return ((x << 1) ^ (((x >> 7) & 1) * 0x1b));
+}
+
+// MixColumns function mixes the columns of the state matrix
+static void MixColumns(state_t *state)
+{
+    uint8_t i;
+    uint8_t Tmp, Tm, t;
+    for (i = 0; i < 4; ++i)
+    {
+        t = (*state)[i][0];
+        Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3];
+        Tm = (*state)[i][0] ^ (*state)[i][1];
+        Tm = xtime(Tm);
+        (*state)[i][0] ^= Tm ^ Tmp;
+        Tm = (*state)[i][1] ^ (*state)[i][2];
+        Tm = xtime(Tm);
+        (*state)[i][1] ^= Tm ^ Tmp;
+        Tm = (*state)[i][2] ^ (*state)[i][3];
+        Tm = xtime(Tm);
+        (*state)[i][2] ^= Tm ^ Tmp;
+        Tm = (*state)[i][3] ^ t;
+        Tm = xtime(Tm);
+        (*state)[i][3] ^= Tm ^ Tmp;
+    }
+}
+
+static void KeyExpansion(uint8_t *RoundKey, const uint8_t *Key)
+{
+    unsigned i, j, k;
+    uint8_t tempa[4]; // Used for the column/row operations
+
+    // The first round key is the key itself.
+    for (i = 0; i < Nk; ++i)
+    {
+        RoundKey[(i * 4) + 0] = Key[(i * 4) + 0];
+        RoundKey[(i * 4) + 1] = Key[(i * 4) + 1];
+        RoundKey[(i * 4) + 2] = Key[(i * 4) + 2];
+        RoundKey[(i * 4) + 3] = Key[(i * 4) + 3];
+    }
+
+    // All other round keys are found from the previous round keys.
+    for (i = Nk; i < Nb * (Nr + 1); ++i)
+    {
+        {
+            k = (i - 1) * 4;
+            tempa[0] = RoundKey[k + 0];
+            tempa[1] = RoundKey[k + 1];
+            tempa[2] = RoundKey[k + 2];
+            tempa[3] = RoundKey[k + 3];
+        }
+
+        if (i % Nk == 0)
+        {
+            // This function shifts the 4 bytes in a word to the left once.
+            // [a0,a1,a2,a3] becomes [a1,a2,a3,a0]
+
+            // Function RotWord()
+            {
+                const uint8_t u8tmp = tempa[0];
+                tempa[0] = tempa[1];
+                tempa[1] = tempa[2];
+                tempa[2] = tempa[3];
+                tempa[3] = u8tmp;
+            }
+
+            // SubWord() is a function that takes a four-byte input word and
+            // applies the S-box to each of the four bytes to produce an output word.
+
+            // Function Subword()
+            {
+                tempa[0] = getSBoxValue(tempa[0]);
+                tempa[1] = getSBoxValue(tempa[1]);
+                tempa[2] = getSBoxValue(tempa[2]);
+                tempa[3] = getSBoxValue(tempa[3]);
+            }
+
+            tempa[0] = tempa[0] ^ Rcon[i / Nk];
+        }
+        j = i * 4;
+        k = (i - Nk) * 4;
+        RoundKey[j + 0] = RoundKey[k + 0] ^ tempa[0];
+        RoundKey[j + 1] = RoundKey[k + 1] ^ tempa[1];
+        RoundKey[j + 2] = RoundKey[k + 2] ^ tempa[2];
+        RoundKey[j + 3] = RoundKey[k + 3] ^ tempa[3];
+    }
+}
+
+// Cipher is the main function that encrypts the PlainText.
+static void Cipher(state_t *state, const uint8_t *RoundKey)
+{
+    uint8_t round = 0;
+
+    // Add the First round key to the state before starting the rounds.
+    AddRoundKey(0, state, RoundKey);
+
+    // There will be Nr rounds.
+    // The first Nr-1 rounds are identical.
+    // These Nr rounds are executed in the loop below.
+    // Last one without MixColumns()
+    for (round = 1;; ++round)
+    {
+        SubBytes(state);
+        ShiftRows(state);
+        if (round == Nr)
+        {
+            break;
+        }
+        MixColumns(state);
+        AddRoundKey(round, state, RoundKey);
+    }
+    // Add round key to last round
+    AddRoundKey(Nr, state, RoundKey);
+}
+
+void AES_init_ctx_iv(struct AES_ctx *ctx, const uint8_t *key, const uint8_t *iv)
+{
+    KeyExpansion(ctx->RoundKey, key);
+    memcpy(ctx->Iv, iv, AES_BLOCKLEN);
+}
+
+void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t *buf, size_t length)
+{
+    size_t i;
+    uint8_t *Iv = ctx->Iv;
+    for (i = 0; i < length; i += AES_BLOCKLEN)
+    {
+        XorWithIv(buf, Iv);
+        Cipher((state_t *)buf, ctx->RoundKey);
+        Iv = buf;
+        buf += AES_BLOCKLEN;
+    }
+    /* store Iv in ctx for next call */
+    memcpy(ctx->Iv, Iv, AES_BLOCKLEN);
+}
+
+void vAes() {
+    int IMC_REPEAT = 1000;
+    for(int imc=0; imc < IMC_REPEAT; imc++) {
+        uint8_t key[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
+        uint8_t out[] = {0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
+                        0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee, 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
+                        0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b, 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
+                        0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09, 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7};
+
+        uint8_t iv[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
+        uint8_t in[] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+                        0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+                        0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+                        0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10};
+        // struct AES_ctx ctx;
+
+        uint8_t roundKey[AES_keyExpSize];
+        uint8_t ctxIv[AES_BLOCKLEN];
+
+        // AES_init_ctx_iv(&ctx, key, iv);
+        // KeyExpansion(ctx.RoundKey, key);
+        {
+            uint8_t *RoundKey = roundKey;
+            const uint8_t *Key = key;
+            unsigned i, j, k;
+            uint8_t tempa[4]; // Used for the column/row operations
+
+            // The first round key is the key itself.
+            for (i = 0; i < Nk; ++i)
+            {
+                RoundKey[(i * 4) + 0] = Key[(i * 4) + 0];
+                RoundKey[(i * 4) + 1] = Key[(i * 4) + 1];
+                RoundKey[(i * 4) + 2] = Key[(i * 4) + 2];
+                RoundKey[(i * 4) + 3] = Key[(i * 4) + 3];
+            }
+
+            // All other round keys are found from the previous round keys.
+            for (i = Nk; i < Nb * (Nr + 1); ++i)
+            {
+                {
+                    k = (i - 1) * 4;
+                    tempa[0] = RoundKey[k + 0];
+                    tempa[1] = RoundKey[k + 1];
+                    tempa[2] = RoundKey[k + 2];
+                    tempa[3] = RoundKey[k + 3];
+                }
+
+                if (i % Nk == 0)
+                {
+                    // This function shifts the 4 bytes in a word to the left once.
+                    // [a0,a1,a2,a3] becomes [a1,a2,a3,a0]
+
+                    // Function RotWord()
+                    {
+                        const uint8_t u8tmp = tempa[0];
+                        tempa[0] = tempa[1];
+                        tempa[1] = tempa[2];
+                        tempa[2] = tempa[3];
+                        tempa[3] = u8tmp;
+                    }
+
+                    // SubWord() is a function that takes a four-byte input word and
+                    // applies the S-box to each of the four bytes to produce an output word.
+
+                    // Function Subword()
+                    {
+                        tempa[0] = getSBoxValue(tempa[0]);
+                        tempa[1] = getSBoxValue(tempa[1]);
+                        tempa[2] = getSBoxValue(tempa[2]);
+                        tempa[3] = getSBoxValue(tempa[3]);
+                    }
+
+                    tempa[0] = tempa[0] ^ Rcon[i / Nk];
+                }
+                j = i * 4;
+                k = (i - Nk) * 4;
+                RoundKey[j + 0] = RoundKey[k + 0] ^ tempa[0];
+                RoundKey[j + 1] = RoundKey[k + 1] ^ tempa[1];
+                RoundKey[j + 2] = RoundKey[k + 2] ^ tempa[2];
+                RoundKey[j + 3] = RoundKey[k + 3] ^ tempa[3];
+            }
+        }
+        memcpy(ctxIv, iv, AES_BLOCKLEN);
+
+        // AES_CBC_encrypt_buffer(&ctx, in, 64);
+        {
+            size_t i;
+            uint8_t *Iv = ctxIv;
+            // uint8_t *buf = in;
+            for (i = 0; i < 64; i += AES_BLOCKLEN)
+            {
+                // XorWithIv(buf, Iv);
+                {
+                    uint8_t j;
+                    for (j = 0; j < AES_BLOCKLEN; ++j) // The block in AES is always 128bit no matter the key size
+                    {
+                        // buf[j] ^= Iv[j];
+                        in[i + j] ^= Iv[j];
+                    }
+                }
+                // Cipher((state_t *)buf, roundKey);
+                Cipher((state_t *)(in + i), roundKey);
+                // Iv = buf;
+                Iv = in + i;
+                // buf += AES_BLOCKLEN;
+            }
+            /* store Iv in ctx for next call */
+            memcpy(ctxIv, Iv, AES_BLOCKLEN);
+        }
+
+        if(imc == IMC_REPEAT-1) {
+            printf("CBC encrypt: ");
+
+            if (0 == memcmp((char *)out, (char *)in, 64))
+            {
+                printf("SUCCESS!\r\n");
+            }
+            else
+            {
+                printf("FAILURE!\r\n");
+            }
+        }
+    }
+    return;
+}

+ 73 - 0
Core/Src/benchmarks/basicmath/basicmath.c

@@ -0,0 +1,73 @@
+#include "benchmarks/basicmath/snipmath.h"
+#include "cmsis_os.h"
+// #include "imc.h"
+
+#include <stdio.h>
+
+void vBasicMath()
+{
+  double a1 = 1.0, b1 = -10.5, c1 = 32.0, d1 = -30.0;
+  double a2 = 1.0, b2 = -4.5, c2 = 17.0, d2 = -30.0;
+  double a3 = 1.0, b3 = -3.5, c3 = 22.0, d3 = -31.0;
+  double a4 = 1.0, b4 = -13.7, c4 = 1.0, d4 = -35.0;
+  double x[3];
+  double X;
+  int solutions;
+  int i;
+  unsigned long l = 0x3fed0169L;
+  struct int_sqrt q;
+
+  double sum = 0;
+
+  // portDISABLE_INTERRUPTS();
+  // printf("Sum: %f\r\n", sum);
+  // portENABLE_INTERRUPTS();
+
+  // while (1)
+  // {
+  int IMC_REPEAT = 2;
+  // IMC_REPEAT = 4;
+  for(int imc_repeat=0; imc_repeat<IMC_REPEAT; imc_repeat++) {
+
+    /* Now solve some random equations */
+    for (a1 = 1; a1 < 3; a1++)
+    {
+      for (b1 = 10; b1 > 0; b1--)
+      {
+        for (c1 = 5; c1 < 15; c1 += 0.5)
+        {
+          for (d1 = -1; d1 > -11; d1--)
+          {
+            SolveCubic(a1, b1, c1, d1, &solutions, x);
+            sum += x[0];
+            // portDISABLE_INTERRUPTS();
+            // printf("Solutions:");
+            // portENABLE_INTERRUPTS();
+            // for (i = 0; i < solutions; i++)
+            // {
+            //   portDISABLE_INTERRUPTS();
+            //   printf(" %f", x[i]);
+            //   portENABLE_INTERRUPTS();
+            // }
+            // portDISABLE_INTERRUPTS();
+            // printf("\r\n");
+            // portENABLE_INTERRUPTS();
+            // for(int j=0; j<1000000; j++) { __asm__("  nop"); }
+          }
+        }
+      }
+    }
+  }
+
+  portDISABLE_INTERRUPTS();
+  // printf("Sum: %f\r\n", sum);
+  printf("Sum: %d\r\n", (int)sum);
+  portENABLE_INTERRUPTS();
+
+  // #if( imcDEBUG_ITM_MESSAGES == 1 )
+  //   imcLOG_BENCHMARK_END();
+  // #endif
+  // exit(0);
+
+  // }
+}

+ 64 - 0
Core/Src/benchmarks/basicmath/cubic.c

@@ -0,0 +1,64 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  CUBIC.C - Solve a cubic polynomial
+**  public domain by Ross Cottrell
+*/
+
+#include <math.h>
+#include <stdlib.h>
+#include "benchmarks/basicmath/snipmath.h"
+
+void SolveCubic(double a,
+                double b,
+                double c,
+                double d,
+                int *solutions,
+                double *x)
+{
+      long double a1 = b / a, a2 = c / a, a3 = d / a;
+      long double Q = (a1 * a1 - 3.0 * a2) / 9.0;
+      long double R = (2.0 * a1 * a1 * a1 - 9.0 * a1 * a2 + 27.0 * a3) / 54.0;
+      double R2_Q3 = R * R - Q * Q * Q;
+
+      double theta;
+
+      if (R2_Q3 <= 0)
+      {
+            *solutions = 3;
+            theta = acos(R / sqrt(Q * Q * Q));
+            x[0] = -2.0 * sqrt(Q) * cos(theta / 3.0) - a1 / 3.0;
+            x[1] = -2.0 * sqrt(Q) * cos((theta + 2.0 * PI) / 3.0) - a1 / 3.0;
+            x[2] = -2.0 * sqrt(Q) * cos((theta + 4.0 * PI) / 3.0) - a1 / 3.0;
+      }
+      else
+      {
+            *solutions = 1;
+            x[0] = pow(sqrt(R2_Q3) + fabs(R), 1 / 3.0);
+            x[0] += Q / x[0];
+            x[0] *= (R < 0.0) ? 1 : -1;
+            x[0] -= a1 / 3.0;
+      }
+}
+
+#ifdef TEST
+
+int main(void)
+{
+      double a1 = 1.0, b1 = -10.5, c1 = 32.0, d1 = -30.0;
+      double a2 = 1.0, b2 = -4.5, c2 = 17.0, d2 = -30.0;
+      double x[3];
+      int solutions;
+
+      SolveCubic(a1, b1, c1, d1, &solutions, x);
+
+      /* should get 3 solutions: 2, 6 & 2.5   */
+
+      SolveCubic(a2, b2, c2, d2, &solutions, x);
+
+      /* should get 1 solution: 2.5           */
+
+      return 0;
+}
+
+#endif /* TEST */

+ 89 - 0
Core/Src/benchmarks/basicmath/isqrt.c

@@ -0,0 +1,89 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+#include <string.h>
+#include "benchmarks/basicmath/snipmath.h"
+
+#define BITSPERLONG 32
+
+#define TOP2BITS(x) ((x & (3L << (BITSPERLONG-2))) >> (BITSPERLONG-2))
+
+
+/* usqrt:
+    ENTRY x: unsigned long
+    EXIT  returns floor(sqrt(x) * pow(2, BITSPERLONG/2))
+
+    Since the square root never uses more than half the bits
+    of the input, we use the other half of the bits to contain
+    extra bits of precision after the binary point.
+
+    EXAMPLE
+        suppose BITSPERLONG = 32
+        then    usqrt(144) = 786432 = 12 * 65536
+                usqrt(32) = 370727 = 5.66 * 65536
+
+    NOTES
+        (1) change BITSPERLONG to BITSPERLONG/2 if you do not want
+            the answer scaled.  Indeed, if you want n bits of
+            precision after the binary point, use BITSPERLONG/2+n.
+            The code assumes that BITSPERLONG is even.
+        (2) This is really better off being written in assembly.
+            The line marked below is really a "arithmetic shift left"
+            on the double-long value with r in the upper half
+            and x in the lower half.  This operation is typically
+            expressible in only one or two assembly instructions.
+        (3) Unrolling this loop is probably not a bad idea.
+
+    ALGORITHM
+        The calculations are the base-two analogue of the square
+        root algorithm we all learned in grammar school.  Since we're
+        in base 2, there is only one nontrivial trial multiplier.
+
+        Notice that absolutely no multiplications or divisions are performed.
+        This means it'll be fast on a wide range of processors.
+*/
+
+void usqrt(unsigned long x, struct int_sqrt *q)
+{
+      unsigned long a = 0L;                   /* accumulator      */
+      unsigned long r = 0L;                   /* remainder        */
+      unsigned long e = 0L;                   /* trial product    */
+
+      int i;
+
+      for (i = 0; i < BITSPERLONG; i++)   /* NOTE 1 */
+      {
+            r = (r << 2) + TOP2BITS(x); x <<= 2; /* NOTE 2 */
+            a <<= 1;
+            e = (a << 1) + 1;
+            if (r >= e)
+            {
+                  r -= e;
+                  a++;
+            }
+      }
+      memcpy(q, &a, sizeof(long));
+}
+
+#ifdef TEST
+
+#include <stdio.h>
+#include <stdlib.h>
+
+main(void)
+{
+      int i;
+      unsigned long l = 0x3fed0169L;
+      struct int_sqrt q;
+
+      for (i = 0; i < 101; ++i)
+      {
+            usqrt(i, &q);
+            printf("sqrt(%3d) = %2d, remainder = %2d\n",
+                  i, q.sqrt, q.frac);
+      }
+      usqrt(l, &q);
+      printf("\nsqrt(%lX) = %X, remainder = %X\n", l, q.sqrt, q.frac);
+      return 0;
+}
+
+#endif /* TEST */

+ 39 - 0
Core/Src/benchmarks/basicmath/rad2deg.c

@@ -0,0 +1,39 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  RAD2DEG.C - Functions to convert between radians and degrees
+*/
+
+#include <math.h>
+#include "benchmarks/basicmath/snipmath.h"
+
+#undef rad2deg                /* These are macros defined in PI.H */
+#undef deg2rad
+
+double rad2deg(double rad)
+{
+      return (180.0 * rad / (PI));
+}
+
+double deg2rad(double deg)
+{
+      return (PI * deg / 180.0);
+}
+
+#ifdef TEST
+
+#include <stdio.h>
+
+main()
+{
+      double X;
+
+      for (X = 0.0; X <= 360.0; X += 45.0)
+            printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X));
+      puts("");
+      for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 6))
+            printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X));
+      return 0;
+}
+
+#endif /* TEST */

+ 9 - 0
Core/Src/benchmarks/crc/compile_data.sh

@@ -0,0 +1,9 @@
+CC=arm-none-eabi-ld
+${CC} -z noexecstack -r -b binary small_modified.pcm -o crc_input.o \
+&& arm-none-eabi-objcopy \
+    --rename-section .data=.rodata,alloc,load,readonly \
+    crc_input.o \
+    crc_input_2.o \
+&& readelf -a crc_input_2.o
+rm crc_input.o
+mv crc_input_2.o crc_input.o

+ 210 - 0
Core/Src/benchmarks/crc/crc_32.c

@@ -0,0 +1,210 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/* Crc - 32 BIT ANSI X3.66 CRC checksum files */
+
+#include <stdio.h>
+#include "crc.h"
+
+#ifdef __TURBOC__
+#pragma warn - cln
+#endif
+
+/**********************************************************************\
+|* Demonstration program to compute the 32-bit CRC used as the frame  *|
+|* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71     *|
+|* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level     *|
+|* protocol).  The 32-bit FCS was added via the Federal Register,     *|
+|* 1 June 1982, p.23798.  I presume but don't know for certain that   *|
+|* this polynomial is or will be included in CCITT V.41, which        *|
+|* defines the 16-bit CRC (often called CRC-CCITT) polynomial.  FIPS  *|
+|* PUB 78 says that the 32-bit FCS reduces otherwise undetected       *|
+|* errors by a factor of 10^-5 over 16-bit FCS.                       *|
+\**********************************************************************/
+
+/* Need an unsigned type capable of holding 32 bits; */
+
+typedef DWORD UNS_32_BITS;
+
+/* Copyright (C) 1986 Gary S. Brown.  You may use this program, or
+   code or tables extracted from it, as desired without restriction.*/
+
+/* First, the polynomial itself and its table of feedback terms.  The  */
+/* polynomial is                                                       */
+/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
+/* Note that we take it "backwards" and put the highest-order term in  */
+/* the lowest-order bit.  The X^32 term is "implied"; the LSB is the   */
+/* X^31 term, etc.  The X^0 term (usually shown as "+1") results in    */
+/* the MSB being 1.                                                    */
+
+/* Note that the usual hardware shift register implementation, which   */
+/* is what we're using (we're merely optimizing it by doing eight-bit  */
+/* chunks at a time) shifts bits into the lowest-order term.  In our   */
+/* implementation, that means shifting towards the right.  Why do we   */
+/* do it this way?  Because the calculated CRC must be transmitted in  */
+/* order from highest-order term to lowest-order term.  UARTs transmit */
+/* characters in order from LSB to MSB.  By storing the CRC this way,  */
+/* we hand it to the UART in the order low-byte to high-byte; the UART */
+/* sends each low-bit to hight-bit; and the result is transmission bit */
+/* by bit from highest- to lowest-order term without requiring any bit */
+/* shuffling on our part.  Reception works similarly.                  */
+
+/* The feedback terms table consists of 256, 32-bit entries.  Notes:   */
+/*                                                                     */
+/*  1. The table can be generated at runtime if desired; code to do so */
+/*     is shown later.  It might not be obvious, but the feedback      */
+/*     terms simply represent the results of eight shift/xor opera-    */
+/*     tions for all combinations of data and CRC register values.     */
+/*                                                                     */
+/*  2. The CRC accumulation logic is the same for all CRC polynomials, */
+/*     be they sixteen or thirty-two bits wide.  You simply choose the */
+/*     appropriate table.  Alternatively, because the table can be     */
+/*     generated at runtime, you can start by generating the table for */
+/*     the polynomial in question and use exactly the same "updcrc",   */
+/*     if your application needn't simultaneously handle two CRC       */
+/*     polynomials.  (Note, however, that XMODEM is strange.)          */
+/*                                                                     */
+/*  3. For 16-bit CRCs, the table entries need be only 16 bits wide;   */
+/*     of course, 32-bit entries work OK if the high 16 bits are zero. */
+/*                                                                     */
+/*  4. The values must be right-shifted by eight bits by the "updcrc"  */
+/*     logic; the shift must be unsigned (bring in zeroes).  On some   */
+/*     hardware you could probably optimize the shift in assembler by  */
+/*     using byte-swap instructions.                                   */
+
+static UNS_32_BITS crc_32_tab[] = {/* CRC polynomial 0xedb88320 */
+                                   0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+                                   0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+                                   0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
+                                   0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+                                   0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+                                   0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+                                   0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
+                                   0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+                                   0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
+                                   0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+                                   0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+                                   0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+                                   0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
+                                   0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+                                   0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+                                   0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+                                   0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
+                                   0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+                                   0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
+                                   0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+                                   0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+                                   0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+                                   0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
+                                   0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+                                   0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+                                   0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+                                   0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
+                                   0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+                                   0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
+                                   0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+                                   0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+                                   0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+                                   0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
+                                   0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+                                   0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+                                   0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+                                   0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
+                                   0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+                                   0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
+                                   0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+                                   0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+                                   0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+                                   0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
+
+extern const char _binary_small_modified_pcm_start;
+extern const char _binary_small_modified_pcm_end;
+extern const char _binary_small_modified_pcm_size;
+
+DWORD updateCRC32(unsigned char ch, DWORD crc)
+{
+      return UPDC32(ch, crc);
+}
+
+Boolean_T crc32file(char *name, DWORD *crc, long *charcnt)
+{
+      register FILE *fin;
+      register DWORD oldcrc32;
+      register int c;
+
+      oldcrc32 = 0xFFFFFFFF;
+      *charcnt = 0;
+#ifdef MSDOS
+      if ((fin = fopen(name, "rb")) == NULL)
+#else
+      if ((fin = fopen(name, "r")) == NULL)
+#endif
+      {
+            perror(name);
+            return Error_;
+      }
+      while ((c = getc(fin)) != EOF)
+      {
+            ++*charcnt;
+            oldcrc32 = UPDC32(c, oldcrc32);
+      }
+
+      if (ferror(fin))
+      {
+            perror(name);
+            *charcnt = -1;
+      }
+      fclose(fin);
+
+      *crc = oldcrc32 = ~oldcrc32;
+
+      return Success_;
+}
+
+DWORD crc32buf(char *buf, size_t len)
+{
+      register DWORD oldcrc32;
+
+      oldcrc32 = 0xFFFFFFFF;
+
+      for (; len; --len, ++buf)
+      {
+            oldcrc32 = UPDC32(*buf, oldcrc32);
+      }
+
+      return ~oldcrc32;
+}
+
+void vCrc()
+{
+      register FILE *fin;
+      register DWORD oldcrc32;
+      register int c;
+
+      int IMC_REPEAT = 2000;
+      // IMC_REPEAT = 6000;
+
+      for (int imc_repeat = 0; imc_repeat < IMC_REPEAT; imc_repeat++)
+      {
+
+            oldcrc32 = 0xFFFFFFFF;
+            // *charcnt = 0;
+
+            int size = (int)&_binary_small_modified_pcm_size;
+            size /= 4;
+            int *input = (int *)&_binary_small_modified_pcm_start;
+
+            // printf("%d\r\n", &_binary_small_modified_pcm_size);
+            // printf("%d\r\n", &_binary_small_modified_pcm_start);
+            // printf("%d\r\n", &_binary_small_modified_pcm_end);
+
+            for (int i = 0; i < size; i += 1)
+            {
+                  c = input[i];
+                  oldcrc32 = UPDC32(c, oldcrc32);
+            }
+      }
+
+      printf("%ld\r\n", oldcrc32);
+
+      // *crc = oldcrc32 = ~oldcrc32;
+}

BIN
Core/Src/benchmarks/crc/crc_input.o


BIN
Core/Src/benchmarks/crc/small_modified.pcm


BIN
Core/Src/benchmarks/crc/small_original.pcm


+ 221 - 0
Core/Src/benchmarks/fft/fft.c

@@ -0,0 +1,221 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include "fourier.h"
+#include "ddcmath.h"
+
+#include "fft.h"
+#include "cmsis_os.h"
+
+#define CHECKPOINTER(p) CheckPointer(p, #p)
+
+static void CheckPointer(void *p, char *name)
+{
+    if (p == NULL)
+    {
+        // fprintf(stderr, "Error in fft_float():  %s == NULL\n", name);
+        printf("Error in fft_float():  %s == NULL\n", name);
+        exit(1);
+    }
+}
+
+void vFFT()
+{
+    unsigned MAXSIZE;
+    unsigned MAXWAVES;
+    unsigned i, j;
+    int invfft = 0;
+
+    MAXSIZE = 128;
+    MAXWAVES = 4;
+
+    int IMC_REPEAT = 10;
+    // IMC_REPEAT = 100;
+
+    // srand(1);
+    
+    float RealIn[MAXSIZE];
+    float ImagIn[MAXSIZE];
+    float RealOut[MAXSIZE];
+    float ImagOut[MAXSIZE];
+    float coeff[MAXWAVES];
+    float amp[MAXWAVES];
+
+    for (int imc_repeat=0; imc_repeat < IMC_REPEAT; imc_repeat++) {
+
+    /* Makes MAXWAVES waves of random amplitude and period */
+    for (i = 0; i < MAXWAVES; i++)
+    {
+        // coeff[i] = rand() % 1000;
+        // amp[i] = rand() % 1000;
+        coeff[i] = 123;
+        amp[i] = 456;
+    }
+    for (i = 0; i < MAXSIZE; i++)
+    {
+        /*   RealIn[i]=rand();*/
+        RealIn[i] = 0;
+        ImagIn[i] = 0;
+        float sum = 0;
+        for (j = 0; j < MAXWAVES; j++)
+        {
+            /* randomly select sin or cos */
+            if (i % 2)
+            {
+                sum += coeff[j] * cos(amp[j] * i);
+                // RealIn[i] += coeff[j] * cos(amp[j] * i);
+            }
+            else
+            {
+                // RealIn[i] += coeff[j] * sin(amp[j] * i);
+                sum += coeff[j] * sin(amp[j] * i);
+            }
+        }
+        RealIn[i] = sum;
+    }
+
+    /* regular*/
+    {
+        unsigned NumBits; /* Number of bits needed to store indices */
+        unsigned i, j, k, n;
+        unsigned BlockSize, BlockEnd;
+
+        double angle_numerator = 2.0 * DDC_PI;
+        double tr, ti; /* temp real, temp imaginary */
+
+        unsigned NumSamples = MAXSIZE;
+        int InverseTransform = invfft;
+
+        if (!IsPowerOfTwo(NumSamples))
+        {
+            // fprintf(
+            //     stderr,
+            //     "Error in fft():  NumSamples=%u is not power of two\n",
+            //     NumSamples);
+            printf(
+                "Error in fft():  NumSamples=%u is not power of two\n",
+                NumSamples);
+
+            exit(1);
+        }
+
+        if (InverseTransform)
+            angle_numerator = -angle_numerator;
+
+        NumBits = NumberOfBitsNeeded(NumSamples);
+
+        /*
+        **   Do simultaneous data copy and bit-reversal ordering into outputs...
+        */
+
+        for (i = 0; i < NumSamples; i++)
+        {
+            j = ReverseBits(i, NumBits);
+            RealOut[j] = RealIn[i];
+            // ImagOut[j] = (ImagIn == NULL) ? 0.0 : ImagIn[i];
+            ImagOut[j] = ImagIn[i];
+        }
+
+        /*
+        **   Do the FFT itself...
+        */
+
+        BlockEnd = 1;
+        for (BlockSize = 2; BlockSize <= NumSamples; BlockSize <<= 1)
+        {
+            double delta_angle = angle_numerator / (double)BlockSize;
+            double sm2 = sin(-2 * delta_angle);
+            double sm1 = sin(-delta_angle);
+            double cm2 = cos(-2 * delta_angle);
+            double cm1 = cos(-delta_angle);
+            double w = 2 * cm1;
+            double ar[3], ai[3];
+            double temp;
+
+            for (i = 0; i < NumSamples; i += BlockSize)
+            {
+                ar[2] = cm2;
+                ar[1] = cm1;
+
+                ai[2] = sm2;
+                ai[1] = sm1;
+
+                for (j = i, n = 0; n < BlockEnd; j++, n++)
+                {
+                    ar[0] = w * ar[1] - ar[2];
+                    ar[2] = ar[1];
+                    ar[1] = ar[0];
+
+                    ai[0] = w * ai[1] - ai[2];
+                    ai[2] = ai[1];
+                    ai[1] = ai[0];
+
+                    k = j + BlockEnd;
+                    tr = ar[0] * RealOut[k] - ai[0] * ImagOut[k];
+                    ti = ar[0] * ImagOut[k] + ai[0] * RealOut[k];
+
+                    RealOut[k] = RealOut[j] - tr;
+                    ImagOut[k] = ImagOut[j] - ti;
+
+                    RealOut[j] += tr;
+                    ImagOut[j] += ti;
+                }
+            }
+
+            BlockEnd = BlockSize;
+        }
+
+        /*
+        **   Need to normalize if inverse transform...
+        */
+
+        if (InverseTransform)
+        {
+            double denom = (double)NumSamples;
+
+            for (i = 0; i < NumSamples; i++)
+            {
+                RealOut[i] /= denom;
+                ImagOut[i] /= denom;
+            }
+        }
+    }
+
+    } //imc_repeat
+
+    /*
+    portDISABLE_INTERRUPTS();
+    printf("RealOut:\r\n");
+    portENABLE_INTERRUPTS();
+    for (i = 0; i < MAXSIZE; i++)
+        printf("%f \t", RealOut[i]);
+    printf("\r\n");
+
+    printf("ImagOut:\r\n");
+    for (i = 0; i < MAXSIZE; i++)
+        printf("%f \t", ImagOut[i]);
+    printf("\r\n");
+    */
+
+    float real_sum = 0;
+    float imag_sum = 0;
+
+    for (i = 0; i < MAXSIZE; i++) {
+        real_sum += RealOut[i];
+        imag_sum += ImagOut[i];
+    }
+
+    portDISABLE_INTERRUPTS();
+    printf("%d, %d\r\n", (int)(real_sum*1000000), (int)(imag_sum*1000000));
+    portENABLE_INTERRUPTS();
+
+    // printf("RealOut: ");
+    // for (i = 0; i < 3; i++)
+    //     printf("%f\t", RealOut[i]);
+    // printf("\r\n");
+    // printf("ImagOut: ");
+    // for (i = 0; i < 3; i++)
+    //     printf("%f\t", ImagOut[i]);
+    // printf("\r\n");
+}

+ 86 - 0
Core/Src/benchmarks/fft/fft_original.c

@@ -0,0 +1,86 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+int main(int argc, char *argv[]) {
+	unsigned MAXSIZE;
+	unsigned MAXWAVES;
+	unsigned i,j;
+	float *RealIn;
+	float *ImagIn;
+	float *RealOut;
+	float *ImagOut;
+	float *coeff;
+	float *amp;
+	int invfft=0;
+
+	if (argc<3)
+	{
+		printf("Usage: fft <waves> <length> -i\n");
+		printf("-i performs an inverse fft\n");
+		printf("make <waves> random sinusoids");
+		printf("<length> is the number of samples\n");
+		exit(-1);
+	}
+	else if (argc==4)
+		invfft = !strncmp(argv[3],"-i",2);
+	MAXSIZE=atoi(argv[2]);
+	MAXWAVES=atoi(argv[1]);
+		
+ srand(1);
+
+ RealIn=(float*)malloc(sizeof(float)*MAXSIZE);
+ ImagIn=(float*)malloc(sizeof(float)*MAXSIZE);
+ RealOut=(float*)malloc(sizeof(float)*MAXSIZE);
+ ImagOut=(float*)malloc(sizeof(float)*MAXSIZE);
+ coeff=(float*)malloc(sizeof(float)*MAXWAVES);
+ amp=(float*)malloc(sizeof(float)*MAXWAVES);
+
+ /* Makes MAXWAVES waves of random amplitude and period */
+	for(i=0;i<MAXWAVES;i++) 
+	{
+		coeff[i] = rand()%1000;
+		amp[i] = rand()%1000;
+	}
+ for(i=0;i<MAXSIZE;i++) 
+ {
+   /*   RealIn[i]=rand();*/
+	 RealIn[i]=0;
+	 for(j=0;j<MAXWAVES;j++) 
+	 {
+		 /* randomly select sin or cos */
+		 if (rand()%2)
+		 {
+		 		RealIn[i]+=coeff[j]*cos(amp[j]*i);
+			}
+		 else
+		 {
+		 	RealIn[i]+=coeff[j]*sin(amp[j]*i);
+		 }
+  	 ImagIn[i]=0;
+	 }
+ }
+
+ /* regular*/
+ fft_float (MAXSIZE,invfft,RealIn,ImagIn,RealOut,ImagOut);
+ 
+ printf("RealOut:\n");
+ for (i=0;i<MAXSIZE;i++)
+   printf("%f \t", RealOut[i]);
+ printf("\n");
+
+printf("ImagOut:\n");
+ for (i=0;i<MAXSIZE;i++)
+   printf("%f \t", ImagOut[i]);
+   printf("\n");
+
+ free(RealIn);
+ free(ImagIn);
+ free(RealOut);
+ free(ImagOut);
+ free(coeff);
+ free(amp);
+ exit(0);
+
+
+}

+ 95 - 0
Core/Src/benchmarks/fft/fftmisc.c

@@ -0,0 +1,95 @@
+/*============================================================================
+
+    fftmisc.c  -  Don Cross <dcross@intersrv.com>
+
+    http://www.intersrv.com/~dcross/fft.html
+
+    Helper routines for Fast Fourier Transform implementation.
+    Contains common code for fft_float() and fft_double().
+
+    See also:
+        fourierf.c
+        fourierd.c
+        ..\include\fourier.h
+
+    Revision history:
+
+1998 September 19 [Don Cross]
+    Improved the efficiency of IsPowerOfTwo().
+    Updated coding standards.
+
+============================================================================*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "fourier.h"
+
+#define TRUE  1
+#define FALSE 0
+
+#define BITS_PER_WORD   (sizeof(unsigned) * 8)
+
+
+int IsPowerOfTwo ( unsigned x )
+{
+    if ( x < 2 )
+        return FALSE;
+
+    if ( x & (x-1) )        // Thanks to 'byang' for this cute trick!
+        return FALSE;
+
+    return TRUE;
+}
+
+
+unsigned NumberOfBitsNeeded ( unsigned PowerOfTwo )
+{
+    unsigned i;
+
+    if ( PowerOfTwo < 2 )
+    {
+        // fprintf (
+        //     stderr,
+        //     ">>> Error in fftmisc.c: argument %d to NumberOfBitsNeeded is too small.\n",
+        //     PowerOfTwo );
+
+        exit(1);
+    }
+
+    for ( i=0; ; i++ )
+    {
+        if ( PowerOfTwo & (1 << i) )
+            return i;
+    }
+}
+
+
+
+unsigned ReverseBits ( unsigned index, unsigned NumBits )
+{
+    unsigned i, rev;
+
+    for ( i=rev=0; i < NumBits; i++ )
+    {
+        rev = (rev << 1) | (index & 1);
+        index >>= 1;
+    }
+
+    return rev;
+}
+
+
+double Index_to_frequency ( unsigned NumSamples, unsigned Index )
+{
+    if ( Index >= NumSamples )
+        return 0.0;
+    else if ( Index <= NumSamples/2 )
+        return (double)Index / (double)NumSamples;
+
+    return -(double)(NumSamples-Index) / (double)NumSamples;
+}
+
+
+/*--- end of file fftmisc.c---*/

+ 155 - 0
Core/Src/benchmarks/fft/fourierf.c

@@ -0,0 +1,155 @@
+/*============================================================================
+
+    fourierf.c  -  Don Cross <dcross@intersrv.com>
+
+    http://www.intersrv.com/~dcross/fft.html
+
+    Contains definitions for doing Fourier transforms
+    and inverse Fourier transforms.
+
+    This module performs operations on arrays of 'float'.
+
+    Revision history:
+
+1998 September 19 [Don Cross]
+    Updated coding standards.
+    Improved efficiency of trig calculations.
+
+============================================================================*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "fourier.h"
+#include "ddcmath.h"
+
+#define CHECKPOINTER(p)  CheckPointer(p,#p)
+
+static void CheckPointer ( void *p, char *name )
+{
+    if ( p == NULL )
+    {
+        // fprintf ( stderr, "Error in fft_float():  %s == NULL\n", name );
+        printf ( "Error in fft_float():  %s == NULL\n", name );
+        exit(1);
+    }
+}
+
+
+void fft_float (
+    unsigned  NumSamples,
+    int       InverseTransform,
+    float    *RealIn,
+    float    *ImagIn,
+    float    *RealOut,
+    float    *ImagOut )
+{
+    unsigned NumBits;    /* Number of bits needed to store indices */
+    unsigned i, j, k, n;
+    unsigned BlockSize, BlockEnd;
+
+    double angle_numerator = 2.0 * DDC_PI;
+    double tr, ti;     /* temp real, temp imaginary */
+
+    if ( !IsPowerOfTwo(NumSamples) )
+    {
+        // fprintf (
+        //     stderr,
+        //     "Error in fft():  NumSamples=%u is not power of two\n",
+        //     NumSamples );
+
+        printf (
+            "Error in fft():  NumSamples=%u is not power of two\n",
+            NumSamples );
+
+        exit(1);
+    }
+
+    if ( InverseTransform )
+        angle_numerator = -angle_numerator;
+
+    CHECKPOINTER ( RealIn );
+    CHECKPOINTER ( RealOut );
+    CHECKPOINTER ( ImagOut );
+
+    NumBits = NumberOfBitsNeeded ( NumSamples );
+
+    /*
+    **   Do simultaneous data copy and bit-reversal ordering into outputs...
+    */
+
+    for ( i=0; i < NumSamples; i++ )
+    {
+        j = ReverseBits ( i, NumBits );
+        RealOut[j] = RealIn[i];
+        ImagOut[j] = (ImagIn == NULL) ? 0.0 : ImagIn[i];
+    }
+
+    /*
+    **   Do the FFT itself...
+    */
+
+    BlockEnd = 1;
+    for ( BlockSize = 2; BlockSize <= NumSamples; BlockSize <<= 1 )
+    {
+        double delta_angle = angle_numerator / (double)BlockSize;
+        double sm2 = sin ( -2 * delta_angle );
+        double sm1 = sin ( -delta_angle );
+        double cm2 = cos ( -2 * delta_angle );
+        double cm1 = cos ( -delta_angle );
+        double w = 2 * cm1;
+        double ar[3], ai[3];
+        double temp;
+
+        for ( i=0; i < NumSamples; i += BlockSize )
+        {
+            ar[2] = cm2;
+            ar[1] = cm1;
+
+            ai[2] = sm2;
+            ai[1] = sm1;
+
+            for ( j=i, n=0; n < BlockEnd; j++, n++ )
+            {
+                ar[0] = w*ar[1] - ar[2];
+                ar[2] = ar[1];
+                ar[1] = ar[0];
+
+                ai[0] = w*ai[1] - ai[2];
+                ai[2] = ai[1];
+                ai[1] = ai[0];
+
+                k = j + BlockEnd;
+                tr = ar[0]*RealOut[k] - ai[0]*ImagOut[k];
+                ti = ar[0]*ImagOut[k] + ai[0]*RealOut[k];
+
+                RealOut[k] = RealOut[j] - tr;
+                ImagOut[k] = ImagOut[j] - ti;
+
+                RealOut[j] += tr;
+                ImagOut[j] += ti;
+            }
+        }
+
+        BlockEnd = BlockSize;
+    }
+
+    /*
+    **   Need to normalize if inverse transform...
+    */
+
+    if ( InverseTransform )
+    {
+        double denom = (double)NumSamples;
+
+        for ( i=0; i < NumSamples; i++ )
+        {
+            RealOut[i] /= denom;
+            ImagOut[i] /= denom;
+        }
+    }
+}
+
+
+/*--- end of file fourierf.c ---*/

+ 34 - 0
Core/Src/benchmarks/matmul/matmul.c

@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+#define MAT_SIZE 10
+
+int A[MAT_SIZE][MAT_SIZE] = {
+    [0 ... MAT_SIZE - 1] = {[0 ... MAT_SIZE - 1] = 2}};
+int B[MAT_SIZE][MAT_SIZE] = {
+    [0 ... MAT_SIZE - 1] = {[0 ... MAT_SIZE - 1] = 2}};
+
+void vMatMul() {
+    int IMC_REPEAT = 50;
+    int C[MAT_SIZE * MAT_SIZE] = { 0 };
+    for(int imc=0; imc<IMC_REPEAT; imc++) {
+
+        for(int _i=0; _i<MAT_SIZE*MAT_SIZE; _i++) {
+            int sum = 0;
+            int i = _i / MAT_SIZE;
+            int j = _i % MAT_SIZE;
+            for(int k=0; k<MAT_SIZE; k++) {
+                sum += A[i][k] * B[k][j];
+            }
+            C[_i] = sum;
+        }
+    }
+
+    for (int _i = 0; _i < MAT_SIZE * MAT_SIZE; _i++)
+    {
+        if(_i % MAT_SIZE == 0) {
+            printf("\r\n");
+        }
+        printf("%d ", C[_i]);
+    }
+    printf("\r\n");
+}

+ 9 - 0
Core/Src/benchmarks/sha/compile_data.sh

@@ -0,0 +1,9 @@
+CC=arm-none-eabi-ld
+${CC} -z noexecstack -r -b binary input_small.asc -o sha_input.o \
+&& arm-none-eabi-objcopy \
+    --rename-section .data=.rodata,alloc,load,readonly \
+    sha_input.o \
+    sha_input_2.o \
+&& readelf -a sha_input_2.o
+rm sha_input.o
+mv sha_input_2.o sha_input.o

File diff suppressed because it is too large
+ 0 - 0
Core/Src/benchmarks/sha/input_small.asc


File diff suppressed because it is too large
+ 0 - 0
Core/Src/benchmarks/sha/input_small_original.asc


File diff suppressed because it is too large
+ 18 - 0
Core/Src/benchmarks/sha/sha.c


BIN
Core/Src/benchmarks/sha/sha_input.o


+ 105 - 0
Core/Src/benchmarks/stringsearch/bmhasrch.c

@@ -0,0 +1,105 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  Boyer-Moore-Horspool pattern match
+**  Case-insensitive with accented character translation
+**
+**  public domain by Raymond Gardner 7/92
+**
+**  limitation: pattern length + subject length must be less than 32767
+**
+**  10/21/93 rdg  Fixed bug found by Jeff Dunlop
+*/
+#include <limits.h>                                         /* rdg 10/93 */
+#include <stddef.h>
+#include <string.h>
+typedef unsigned char uchar;
+
+#define LOWER_ACCENTED_CHARS
+
+unsigned char lowervec[UCHAR_MAX+1] = {                     /* rdg 10/93 */
+  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32,'!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',
+'0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?',
+'@','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
+'p','q','r','s','t','u','v','w','x','y','z','[','\\',']','^','_',
+'`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
+'p','q','r','s','t','u','v','w','x','y','z','{','|','}','~',127,
+#ifdef LOWER_ACCENTED_CHARS
+'c','u','e','a','a','a','a','c','e','e','e','i','i','i','a','a',
+'e',145,146,'o','o','o','u','u','y','o','u',155,156,157,158,159,
+'a','i','o','u','n','n',166,167,168,169,170,171,172,173,174,175,
+#else
+128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
+144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
+160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
+#endif
+176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
+192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
+208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
+224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
+240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
+};
+
+#define lowerc(c) lowervec[(uchar)(c)]
+
+#define LARGE 32767
+
+static int patlen;
+static int skip[UCHAR_MAX+1];                               /* rdg 10/93 */
+static int skip2;
+static uchar *pat;
+
+void bmha_init(const char *pattern)
+{
+      int i, j;
+      pat = (uchar *)pattern;
+      patlen = strlen(pattern);
+      for (i = 0; i <= UCHAR_MAX; ++i)                      /* rdg 10/93 */
+      {
+            skip[i] = patlen;
+            for (j = patlen - 1; j >= 0; --j)
+            {
+                  if (lowerc(i) == lowerc(pat[j]))
+                        break;
+            }
+            if (j >= 0)
+                  skip[i] = patlen - j - 1;
+            if (j == patlen - 1)
+                  skip[i] = LARGE;
+      }
+      skip2 = patlen;
+      for (i = 0; i < patlen - 1; ++i)
+      {
+            if ( lowerc(pat[i]) == lowerc(pat[patlen - 1]) )
+                  skip2 = patlen - i - 1;
+      }
+}
+
+char *bmha_search(const char *string, const int stringlen)
+{
+      int i, j;
+      char *s;
+
+      i = patlen - 1 - stringlen;
+      if (i >= 0)
+            return NULL;
+      string += stringlen;
+      for ( ;; )
+      {
+            while ((i += skip[((uchar *)string)[i]]) < 0)
+                  ;                           /* mighty fast inner loop */
+            if (i < (LARGE - stringlen))
+                  return NULL;
+            i -= LARGE;
+            j = patlen - 1;
+            s = (char *)string + (i - j);
+            while (--j >= 0 && lowerc(s[j]) == lowerc(pat[j]))
+                  ;
+            if ( j < 0 )                                    /* rdg 10/93 */
+                  return s;                                 /* rdg 10/93 */
+            if ( (i += skip2) >= 0 )                        /* rdg 10/93 */
+                  return NULL;                              /* rdg 10/93 */
+      }
+}

+ 106 - 0
Core/Src/benchmarks/stringsearch/bmhisrch.c

@@ -0,0 +1,106 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  Case-Insensitive Boyer-Moore-Horspool pattern match
+**
+**  Public Domain version by Thad Smith 7/21/1992,
+**  based on a 7/92 public domain BMH version by Raymond Gardner.
+**
+**  This program is written in ANSI C and inherits the compilers
+**  ability (or lack thereof) to support non-"C" locales by use of
+**  toupper() and tolower() to perform case conversions.
+**  Limitation: pattern length + string length must be less than 32767.
+**
+**  10/21/93 rdg  Fixed bugs found by Jeff Dunlop
+*/
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+typedef unsigned char uchar;
+
+void bmhi_init(const char *);
+char *bmhi_search(const char *, const int);
+void bhmi_cleanup(void);
+
+
+#define LARGE 32767             /* flag for last character match    */
+
+static int patlen;              /* # chars in pattern               */
+static int skip[UCHAR_MAX+1];   /* skip-ahead count for test chars  */
+static int skip2;               /* skip-ahead after non-match with
+                                ** matching final character         */
+static uchar *pat = NULL;       /* uppercase copy of pattern        */
+
+/*
+** bmhi_init() is called prior to bmhi_search() to calculate the
+** skip array for the given pattern.
+** Error: exit(1) is called if no memory is available.
+*/
+
+void bmhi_init(const char *pattern)
+{
+      int i, lastpatchar;
+      patlen = strlen(pattern);
+
+      /* Make uppercase copy of pattern */
+
+      pat = realloc ((void*)pat, patlen);
+      if (!pat)
+            exit(1);
+      else  atexit(bhmi_cleanup);
+      for (i=0; i < patlen; i++)
+            pat[i] = toupper(pattern[i]);
+
+      /* initialize skip array */
+
+      for ( i = 0; i <= UCHAR_MAX; ++i )                    /* rdg 10/93 */
+            skip[i] = patlen;
+      for ( i = 0; i < patlen - 1; ++i )
+      {
+            skip[        pat[i] ] = patlen - i - 1;
+            skip[tolower(pat[i])] = patlen - i - 1;
+      }
+      lastpatchar = pat[patlen - 1];
+      skip[        lastpatchar ] = LARGE;
+      skip[tolower(lastpatchar)] = LARGE;
+      skip2 = patlen;                     /* Horspool's fixed second shift */
+      for (i = 0; i < patlen - 1; ++i)
+      {
+            if ( pat[i] == lastpatchar )
+                  skip2 = patlen - i - 1;
+      }
+}
+
+char *bmhi_search(const char *string, const int stringlen)
+{
+      int i, j;
+      char *s;
+
+      i = patlen - 1 - stringlen;
+      if (i >= 0)
+            return NULL;
+      string += stringlen;
+      for ( ;; )
+      {
+            while ( (i += skip[((uchar *)string)[i]]) < 0 )
+                  ;                           /* mighty fast inner loop */
+            if (i < (LARGE - stringlen))
+                  return NULL;
+            i -= LARGE;
+            j = patlen - 1;
+            s = (char *)string + (i - j);
+            while ( --j >= 0 && toupper(s[j]) == pat[j] )
+                  ;
+            if ( j < 0 )                                    /* rdg 10/93 */
+                  return s;                                 /* rdg 10/93 */
+            if ( (i += skip2) >= 0 )                        /* rdg 10/93 */
+                  return NULL;                              /* rdg 10/93 */
+      }
+}
+
+void bhmi_cleanup(void)
+{
+      free(pat);
+}

+ 70 - 0
Core/Src/benchmarks/stringsearch/bmhsrch.c

@@ -0,0 +1,70 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**  Case-sensitive Boyer-Moore-Horspool pattern match
+**
+**  public domain by Raymond Gardner 7/92
+**
+**  limitation: pattern length + string length must be less than 32767
+**
+**  10/21/93 rdg  Fixed bug found by Jeff Dunlop
+*/
+#include <limits.h>                                         /* rdg 10/93 */
+#include <stddef.h>
+#include <string.h>
+typedef unsigned char uchar;
+
+
+#define LARGE 32767
+
+static int patlen;
+static int skip[UCHAR_MAX+1];                               /* rdg 10/93 */
+static int skip2;
+static uchar *pat;
+
+void bmh_init(const char *pattern)
+{
+          int i, lastpatchar;
+
+          pat = (uchar *)pattern;
+          patlen = strlen(pattern);
+          for (i = 0; i <= UCHAR_MAX; ++i)                  /* rdg 10/93 */
+                skip[i] = patlen;
+          for (i = 0; i < patlen; ++i)
+                skip[pat[i]] = patlen - i - 1;
+          lastpatchar = pat[patlen - 1];
+          skip[lastpatchar] = LARGE;
+          skip2 = patlen;                 /* Horspool's fixed second shift */
+          for (i = 0; i < patlen - 1; ++i)
+          {
+                if (pat[i] == lastpatchar)
+                      skip2 = patlen - i - 1;
+          }
+}
+
+char *bmh_search(const char *string, const int stringlen)
+{
+      int i, j;
+      char *s;
+
+      i = patlen - 1 - stringlen;
+      if (i >= 0)
+            return NULL;
+      string += stringlen;
+      for ( ;; )
+      {
+            while ( (i += skip[((uchar *)string)[i]]) < 0 )
+                  ;                           /* mighty fast inner loop */
+            if (i < (LARGE - stringlen))
+                  return NULL;
+            i -= LARGE;
+            j = patlen - 1;
+            s = (char *)string + (i - j);
+            while (--j >= 0 && s[j] == pat[j])
+                  ;
+            if ( j < 0 )                                    /* rdg 10/93 */
+                  return s;                                 /* rdg 10/93 */
+            if ( (i += skip2) >= 0 )                        /* rdg 10/93 */
+                  return NULL;                              /* rdg 10/93 */
+      }
+}

+ 174 - 0
Core/Src/benchmarks/stringsearch/pbmsrch_small.c

@@ -0,0 +1,174 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**        A Pratt-Boyer-Moore string search, written by Jerry Coffin
+**  sometime or other in 1991.  Removed from original program, and
+**  (incorrectly) rewritten for separate, generic use in early 1992.
+**  Corrected with help from Thad Smith, late March and early
+**  April 1992...hopefully it's correct this time. Revised by Bob Stout.
+**
+**  This is hereby placed in the Public Domain by its author.
+**
+**  10/21/93 rdg  Fixed bug found by Jeff Dunlop
+*/
+
+#include <stddef.h>
+#include <string.h>
+#include <limits.h>
+
+#include "cmsis_os.h"
+
+static size_t table[UCHAR_MAX + 1] IMC_GLOBAL;
+static size_t len IMC_GLOBAL;
+static char *findme IMC_GLOBAL;
+
+/*
+**  Call this with the string to locate to initialize the table
+*/
+
+void init_search(const char *string)
+{
+      size_t i;
+
+      len = strlen(string);
+      for (i = 0; i <= UCHAR_MAX; i++)                      /* rdg 10/93 */
+            table[i] = len;
+      for (i = 0; i < len; i++)
+            table[(unsigned char)string[i]] = len - i - 1;
+      findme = (char *)string;
+}
+
+/*
+**  Call this with a buffer to search
+*/
+
+char *strsearch(const char *string)
+{
+      register size_t shift;
+      register size_t pos = len - 1;
+      char *here;
+      size_t limit=strlen(string);
+
+      while (pos < limit)
+      {
+            while( pos < limit &&
+                  (shift = table[(unsigned char)string[pos]]) > 0)
+            {
+                  pos += shift;
+            }
+            if (0 == shift)
+            {
+                  if (0 == strncmp(findme,
+                        here = (char *)&string[pos-len+1], len))
+                  {
+                        return(here);
+                  }
+                  else  pos++;
+            }
+      }
+      return NULL;
+}
+
+#include <stdio.h>
+
+void vStringSearch()
+{
+      char *here;
+      char *find_strings[] = {"abb",  "you", "not", "it", "dad", "yoo", "hoo",
+                              "oo", "oh", "xx", "xx", "x", "x", "field", "new", "row",
+			      "regime", "boom", "that", "impact", "and", "zoom", "texture",
+			      "magnet", "doom", "loom", "freq", "current", "phase",
+			      "images", 
+			      "appears", "phase", "conductor", "wavez", 
+			      "normal", "free", "termed",
+			      "provide", "for", "and", "struct", "about", "have",
+			      "proper",
+			      "involve",
+			      "describedly",
+			      "thats",
+			      "spaces",
+			      "circumstance",
+			      "the",
+			      "member",
+			      "such",
+			      "guide",
+			      "regard",
+			      "officers",
+			      "implement",
+			      "principalities",			      
+			      NULL};
+      char *search_strings[] = {"cabbie", "your", "It isn't here",
+                                "But it is here", "hodad", "yoohoo", "yoohoo",
+                                "yoohoo", "yoohoo", "yoohoo", "xx", "x", ".", 
+				"In recent years, the field of photonic ",
+				"crystals has found new",
+				"applications in the RF and microwave",
+				"regime. A new type of metallic",
+				"electromagnetic crystal has been", 
+				"developed that is having a",
+				"significant impact on the field of", 
+				"antennas. It consists of a",
+				"conductive surface, covered with a",
+				"special texture which alters its",
+				"electromagnetic properties. Made of solid",
+				"metal, the structure",
+				"conducts DC currents, but over a",
+				"particular frequency range it does",
+				"not conduct AC currents. It does not",
+				"reverse the phase of reflected",
+				"waves, and the effective image currents",
+
+				"appear in-phase, rather than",
+				"out-of-phase as they are on normal",
+				"conductors. Furthermore, surface",
+				"waves do not propagate, and instead",
+				"radiate efficiently into free",
+				"space. This new material, termed a",
+				"high-impedance surface, provides",
+				"a useful new ground plane for novel",
+				"low-profile antennas and other",
+				"electromagnetic structures.",
+				"The recent protests about the Michigamua",
+				"student organization have raised an",
+				"important question as to the proper nature",
+				"and scope of University involvement",
+				"with student organizations. Accordingly",
+				"the panel described in my Statement of",
+				"February 25, 2000 that is considering the",
+				"question of privileged space also will",
+				"consider under what circumstances and in", 
+				"what ways the University, its",
+				"administrators and faculty members should",
+				"be associated with such organizations",
+				"and it will recommend guiding principles",
+				"in this regard. The University's",
+				"Executive Officers and I will then decide",
+				"whether and how to implement such",
+				"principles."			       
+};
+      int i;
+
+    //   while(1) {
+
+      for (i = 0; find_strings[i]; i++)
+      {
+            init_search(find_strings[i]);
+            here = strsearch(search_strings[i]);
+			portDISABLE_INTERRUPTS();
+			printf("\"%s\" is%s in \"%s\"", find_strings[i],
+				   here ? "" : " not", search_strings[i]);
+			if (here)
+                  printf(" [\"%s\"]", here);
+            putchar('\r'); putchar('\n');
+			portENABLE_INTERRUPTS();
+			// for(int j=0; j<1000000; j++) {__asm__(" nop");}
+      }
+
+	#if(imcDEBUG_ITM_MESSAGES == 1)
+		imcLOG_BENCHMARK_END();
+	#endif
+
+    //   }
+
+}
+

+ 165 - 0
Core/Src/benchmarks/stringsearch/stringsearch_local.c

@@ -0,0 +1,165 @@
+/* +++Date last modified: 05-Jul-1997 */
+
+/*
+**        A Pratt-Boyer-Moore string search, written by Jerry Coffin
+**  sometime or other in 1991.  Removed from original program, and
+**  (incorrectly) rewritten for separate, generic use in early 1992.
+**  Corrected with help from Thad Smith, late March and early
+**  April 1992...hopefully it's correct this time. Revised by Bob Stout.
+**
+**  This is hereby placed in the Public Domain by its author.
+**
+**  10/21/93 rdg  Fixed bug found by Jeff Dunlop
+*/
+
+#include <stddef.h>
+#include <string.h>
+#include <limits.h>
+
+#include "cmsis_os.h"
+
+
+/*
+**  Call this with the string to locate to initialize the table
+*/
+
+#include <stdio.h>
+
+void vStringSearch()
+{
+      char *here;
+      char *find_strings[] = {"abb",  "you", "not", "it", "dad", "yoo", "hoo",
+                              "oo", "oh", "xx", "xx", "x", "x", "field", "new", "row",
+			      "regime", "boom", "that", "impact", "and", "zoom", "texture",
+			      "magnet", "doom", "loom", "freq", "current", "phase",
+			      "images", 
+			      "appears", "phase", "conductor", "wavez", 
+			      "normal", "free", "termed",
+			      "provide", "for", "and", "struct", "about", "have",
+			      "proper",
+			      "involve",
+			      "describedly",
+			      "thats",
+			      "spaces",
+			      "circumstance",
+			      "the",
+			      "member",
+			      "such",
+			      "guide",
+			      "regard",
+			      "officers",
+			      "implement",
+			      "principalities",			      
+			      NULL};
+      char *search_strings[] = {"cabbie", "your", "It isn't here",
+                                "But it is here", "hodad", "yoohoo", "yoohoo",
+                                "yoohoo", "yoohoo", "yoohoo", "xx", "x", ".", 
+				"In recent years, the field of photonic ",
+				"crystals has found new",
+				"applications in the RF and microwave",
+				"regime. A new type of metallic",
+				"electromagnetic crystal has been", 
+				"developed that is having a",
+				"significant impact on the field of", 
+				"antennas. It consists of a",
+				"conductive surface, covered with a",
+				"special texture which alters its",
+				"electromagnetic properties. Made of solid",
+				"metal, the structure",
+				"conducts DC currents, but over a",
+				"particular frequency range it does",
+				"not conduct AC currents. It does not",
+				"reverse the phase of reflected",
+				"waves, and the effective image currents",
+
+				"appear in-phase, rather than",
+				"out-of-phase as they are on normal",
+				"conductors. Furthermore, surface",
+				"waves do not propagate, and instead",
+				"radiate efficiently into free",
+				"space. This new material, termed a",
+				"high-impedance surface, provides",
+				"a useful new ground plane for novel",
+				"low-profile antennas and other",
+				"electromagnetic structures.",
+				"The recent protests about the Michigamua",
+				"student organization have raised an",
+				"important question as to the proper nature",
+				"and scope of University involvement",
+				"with student organizations. Accordingly",
+				"the panel described in my Statement of",
+				"February 25, 2000 that is considering the",
+				"question of privileged space also will",
+				"consider under what circumstances and in", 
+				"what ways the University, its",
+				"administrators and faculty members should",
+				"be associated with such organizations",
+				"and it will recommend guiding principles",
+				"in this regard. The University's",
+				"Executive Officers and I will then decide",
+				"whether and how to implement such",
+				"principles."			       
+};
+      int i;
+	  int table[UCHAR_MAX + 1];
+	  size_t len;
+	  char *findme;
+
+    //   while(1) {
+	  
+	//   int IMC_REPEAT = 2500;
+	  int IMC_REPEAT = 50;
+	  for(int imc_repeat=0; imc_repeat < IMC_REPEAT; imc_repeat++) {
+
+      for (i = 0; find_strings[i]; i++)
+      {
+            // init_search(find_strings[i], table, &len, &findme);
+			size_t j;
+			char *string = find_strings[i];
+			len = strlen(string);
+			for(j=0; j<=UCHAR_MAX; j++) table[j] = len;
+			for(j=0; j<len; j++) table[(unsigned char)string[j]] = len - j - 1;
+			findme = (char *)string;
+
+            // here = strsearch(search_strings[i], table, len, findme);
+			string = search_strings[i];
+			register size_t shift;
+			register size_t pos = len - 1;
+			char *here_local;
+			size_t limit=strlen(string);
+			int found = 0;
+
+			while(!found && pos < limit) {
+				while(pos < limit && (shift = table[(unsigned char)string[pos]]) > 0) {
+					pos += shift;
+				}
+				if(0 == shift) {
+					if(0 == strncmp(findme, here_local = (char *)&string[pos-len+1], len)) {
+						found = 1;
+						here = here_local;
+						break;
+					}
+					else {
+						pos++;
+					}
+				}
+			}
+			if(!found) here = NULL;
+
+			// portDISABLE_INTERRUPTS();
+			// printf("\"%s\" is%s in \"%s\"", find_strings[i],
+			// 	   here ? "" : " not", search_strings[i]);
+			// if (here)
+            //       printf(" [\"%s\"]", here);
+            // putchar('\r'); putchar('\n');
+			// portENABLE_INTERRUPTS();
+			// for(int j=0; j<1000000; j++) {__asm__(" nop");}
+      }
+
+	  } // imc_repeat
+	
+
+    //   }
+
+}
+

+ 1 - 1
Core/Src/main.c

@@ -86,7 +86,7 @@ typedef StaticTask_t osStaticThreadDef_t;
 /* USER CODE END PM */
 
 /* Private variables ---------------------------------------------------------*/
-ADC_HandleTypeDef hadc1;
+ADC_HandleTypeDef ADC_HANDLER_SBC;
 ADC_HandleTypeDef hadc2;
 
 FDCAN_HandleTypeDef hfdcan1;

+ 94 - 2
imc_extension.cmake

@@ -1,5 +1,5 @@
-set(IMC_BENCH_NAME "vConv2d" CACHE STRING "" FORCE)
-set(AVAILABLE_BENCHES "vBasicMath" "vStringSearch" "vFFT" "vSha" "vCrc" "vTest_nvm" "vCustom" "vMemAccessPatternTest" "vMatMul" "vConv2d" "adc_demo")
+set(IMC_BENCH_NAME "vAes" CACHE STRING "" FORCE)
+set(AVAILABLE_BENCHES "vBasicMath" "vStringSearch" "vFFT" "vSha" "vCrc" "vMatMul" "vConv2d" "adc_demo" "vAes")
 if(NOT IMC_BENCH_NAME IN_LIST AVAILABLE_BENCHES)
     message( FATAL_ERROR "incorrect benchmark name: ${IMC_BENCH_NAME}")
 endif()
@@ -26,6 +26,98 @@ if(IMC_BENCH_NAME MATCHES "adc_demo")
     )
 endif()
 
+if(IMC_BENCH_NAME MATCHES "vBasicMath")
+    set(BENCHMARK_SRC_FILES
+        Core/Src/benchmarks/basicmath/cubic.c
+        Core/Src/benchmarks/basicmath/isqrt.c
+        Core/Src/benchmarks/basicmath/rad2deg.c
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/basicmath/basicmath.c
+    )
+    set(IMC_LINK_OBJS
+    )
+    include_directories(
+        Core/Inc/benchmarks/basicmath
+    )
+endif()
+
+if(IMC_BENCH_NAME MATCHES "vCrc")
+    set(BENCHMARK_SRC_FILES
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/crc/crc_32.c
+    )
+    set(IMC_LINK_OBJS
+        ${CMAKE_SOURCE_DIR}/Core/Src/benchmarks/crc/crc_input.o
+    )
+    include_directories(
+        Core/Inc/benchmarks/crc
+    )
+endif()
+
+if(IMC_BENCH_NAME MATCHES "vFFT")
+    set(BENCHMARK_SRC_FILES
+        Core/Src/benchmarks/fft/fftmisc.c
+        Core/Src/benchmarks/fft/fourierf.c
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/fft/fft.c
+    )
+    set(IMC_LINK_OBJS
+    )
+    include_directories(
+        Core/Inc/benchmarks/fft
+    )
+endif()
+
+if(IMC_BENCH_NAME MATCHES "vSha")
+    set(BENCHMARK_SRC_FILES
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/sha/sha.c
+    )
+    set(IMC_LINK_OBJS
+        ${CMAKE_SOURCE_DIR}/Core/Src/benchmarks/sha/sha_input.o
+    )
+    include_directories(
+        Core/Inc/benchmarks/sha
+    )
+endif()
+
+if(IMC_BENCH_NAME MATCHES "vMatMul")
+    set(BENCHMARK_SRC_FILES
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/matmul/matmul.c
+    )
+    set(IMC_LINK_OBJS
+    )
+endif()
+
+if(IMC_BENCH_NAME MATCHES "vStringSearch")
+    set(BENCHMARK_SRC_FILES
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/stringsearch/stringsearch_local.c
+    )
+    set(IMC_LINK_OBJS
+    )
+endif()
+
+if(IMC_BENCH_NAME MATCHES "vAes")
+    set(BENCHMARK_SRC_FILES
+    )
+    set(IMC_APP_FILES
+        Core/Src/benchmarks/aes/aes.c
+    )
+    set(IMC_LINK_OBJS
+    )
+    include_directories(
+        Core/Inc/benchmarks/aes
+    )
+endif()
+
 foreach(BENCH_SRC ${BENCHMARK_SRC_FILES})
     list(APPEND SRC_FILES ${BENCH_SRC})
 endforeach()

Some files were not shown because too many files changed in this diff