aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2023-08-27 21:18:53 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2023-08-27 21:18:53 +0200
commitf396fab26611d6107e223a6a3f41c9dff3e2ee9e (patch)
treed1b22fd265f883404d7e484b7f7c460367a136be /src/utils.h
parent7a0f884c6b11db6a59cfafce7b53158ad59a365e (diff)
downloadsysc-playground-f396fab26611d6107e223a6a3f41c9dff3e2ee9e.tar.gz
sysc-playground-f396fab26611d6107e223a6a3f41c9dff3e2ee9e.zip
move sources into src/ subdir
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..5584027
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,32 @@
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <cstdio>
+
+#define LOG(FMT, ...) \
+ do { \
+ std::fprintf(stderr, "%10s | %4lld:%2lld | %10s | " FMT "\n", \
+ sc_core::sc_time_stamp().to_string().c_str(), \
+ sc_core::sc_delta_count(), \
+ sc_core::sc_delta_count_at_current_time(), __FUNCTION__, \
+ ##__VA_ARGS__); \
+ } while (0)
+
+#define LOGM(FMT, ...) LOG("%12s | " FMT, name(), ##__VA_ARGS__)
+
+// -- COLOR LOGS ---------------------------------------------------------------
+
+#define RESET "\e[0m"
+#define BLACK "\e[0;30m"
+#define RED "\e[0;31m"
+#define GREEN "\e[0;32m"
+#define YELLOW "\e[0;33m"
+#define BLUE "\e[0;34m"
+#define MAGENTA "\e[0;35m"
+#define CYAN "\e[0;36m"
+#define WHITE "\e[0;37m"
+
+#define CLOG(COL, FMT, ...) LOG(COL FMT "\e[0m", ##__VA_ARGS__)
+#define CLOGM(COL, FMT, ...) LOGM(COL FMT "\e[0m", ##__VA_ARGS__)
+
+#endif