File indexing completed on 2024-04-06 12:21:27
0001 #ifndef NNET_COMMON_H_
0002 #define NNET_COMMON_H_
0003
0004 #include "ap_fixed.h"
0005
0006
0007 #define DIV_ROUNDUP(n, d) ((n + d - 1) / d)
0008 #define MIN(n, d) (n > d ? d : n)
0009 #define MAX(n, d) (n > d ? n : d)
0010
0011 #define STRINGIFY(x) #x
0012 #define EXPAND_STRING(x) STRINGIFY(x)
0013
0014 namespace nnet {
0015
0016
0017 enum io_type { io_parallel = 0, io_stream };
0018 enum strategy { latency, resource };
0019
0020 template <class T>
0021 class Op_add {
0022 public:
0023 T operator()(T a, T b) { return a + b; }
0024 };
0025
0026 template <class T>
0027 class Op_and {
0028 public:
0029 T operator()(T a, T b) { return a && b; }
0030 };
0031
0032 template <class T>
0033 class Op_or {
0034 public:
0035 T operator()(T a, T b) { return a || b; }
0036 };
0037
0038 template <class T>
0039 class Op_max {
0040 public:
0041 T operator()(T a, T b) { return a >= b ? a : b; }
0042 };
0043
0044 template <class T>
0045 class Op_min {
0046 public:
0047 T operator()(T a, T b) { return a <= b ? a : b; }
0048 };
0049
0050 }
0051
0052 #endif