summaryrefslogtreecommitdiff
path: root/VA/support/common.h
diff options
context:
space:
mode:
authorJuan Gomez Luna <juan.gomez@safari.ethz.ch>2021-06-16 19:46:05 +0200
committerJuan Gomez Luna <juan.gomez@safari.ethz.ch>2021-06-16 19:46:05 +0200
commit3de4b495fb176eba9a0eb517a4ce05903cb67acb (patch)
treefc6776a94549d2d4039898f183dbbeb2ce013ba9 /VA/support/common.h
parentef5c3688c486b80a56d3c1cded25f2b2387f2668 (diff)
PrIM -- first commit
Diffstat (limited to 'VA/support/common.h')
-rwxr-xr-xVA/support/common.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/VA/support/common.h b/VA/support/common.h
new file mode 100755
index 0000000..c1043fd
--- /dev/null
+++ b/VA/support/common.h
@@ -0,0 +1,62 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+// Structures used by both the host and the dpu to communicate information
+typedef struct {
+ uint32_t size;
+ uint32_t transfer_size;
+ enum kernels {
+ kernel1 = 0,
+ nr_kernels = 1,
+ } kernel;
+} dpu_arguments_t;
+
+// Transfer size between MRAM and WRAM
+#ifdef BL
+#define BLOCK_SIZE_LOG2 BL
+#define BLOCK_SIZE (1 << BLOCK_SIZE_LOG2)
+#else
+#define BLOCK_SIZE_LOG2 8
+#define BLOCK_SIZE (1 << BLOCK_SIZE_LOG2)
+#define BL BLOCK_SIZE_LOG2
+#endif
+
+// Data type
+#ifdef UINT32
+#define T uint32_t
+#define DIV 2 // Shift right to divide by sizeof(T)
+#elif UINT64
+#define T uint64_t
+#define DIV 3 // Shift right to divide by sizeof(T)
+#elif INT32
+#define T int32_t
+#define DIV 2 // Shift right to divide by sizeof(T)
+#elif INT64
+#define T int64_t
+#define DIV 3 // Shift right to divide by sizeof(T)
+#elif FLOAT
+#define T float
+#define DIV 2 // Shift right to divide by sizeof(T)
+#elif DOUBLE
+#define T double
+#define DIV 3 // Shift right to divide by sizeof(T)
+#elif CHAR
+#define T char
+#define DIV 0 // Shift right to divide by sizeof(T)
+#elif SHORT
+#define T short
+#define DIV 1 // Shift right to divide by sizeof(T)
+#endif
+
+#ifndef ENERGY
+#define ENERGY 0
+#endif
+#define PRINT 0
+
+#define ANSI_COLOR_RED "\x1b[31m"
+#define ANSI_COLOR_GREEN "\x1b[32m"
+#define ANSI_COLOR_RESET "\x1b[0m"
+
+#define divceil(n, m) (((n)-1) / (m) + 1)
+#define roundup(n, m) ((n / m) * m + m)
+#endif