summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-05-24 01:37:55 -0700
committerGabe Black <gabeblack@google.com>2018-08-08 10:09:54 +0000
commit16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch)
tree7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh
parent7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff)
downloadgem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh')
-rw-r--r--src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh b/src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh
new file mode 100644
index 000000000..592b7ed4e
--- /dev/null
+++ b/src/systemc/tests/systemc/datatypes/fx/bit/test_all.hh
@@ -0,0 +1,80 @@
+// This may look like C code, but it is really -*- C++ -*-
+//
+// test_all.hh<2> --
+// Copyright Synopsys 1998
+// Author : Ric Hilderink
+// Created On : Thu Jan 21 10:32:46 1999
+// Status : none
+//
+
+#ifndef _test_all_hh_
+#define _test_all_hh_
+
+
+
+#define TEST_BIT_T(T_op) \
+{ \
+ out << #T_op << " " << T_WL << " " << T_IWL << "\n"; \
+ sc_fxtype_context fooc(sc_fxtype_params(T_WL, T_IWL)); \
+ T_op a = 0; \
+ int i; \
+ for (i = 0; i < T_WL; ++i) \
+ { \
+ if (a[i]) \
+ out << "|"; \
+ else \
+ out << "."; \
+ } \
+ out << "\t"; \
+ for (i = 0; i < T_WL; i += 3) \
+ a[i] = 1; \
+ for (i = 0; i < T_WL; ++i) \
+ { \
+ if (a[i]) \
+ out << "|"; \
+ else \
+ out << "."; \
+ } \
+ out << "\n"; \
+ a = 0; \
+ a = ~a; \
+ for (i = 0; i < T_WL; ++i) \
+ { \
+ if (a[i]) \
+ out << "|"; \
+ else \
+ out << "."; \
+ } \
+ out << "\t"; \
+ for (i = 0; i < T_WL; i += 3) \
+ a[i] = 0; \
+ for (i = 0; i < T_WL; ++i) \
+ { \
+ if (a[i]) \
+ out << "|"; \
+ else \
+ out << "."; \
+ } \
+ out << "\n"; \
+ out << "a = " << a.to_string(SC_BIN) << "\n"; \
+ a = "0b01010"; \
+ out << "a = " << a.to_string(SC_BIN) << "\n"; \
+}
+
+
+#define TEST_BIT \
+TEST_BIT_T(T_FX_FIX); \
+TEST_BIT_T(T_FX_FIXED); \
+TEST_BIT_T(T_FX_UFIX); \
+TEST_BIT_T(T_FX_UFIXED);
+
+
+#define T_FX_UFIX sc_ufix
+#define T_FX_FIX sc_fix
+#define T_FX_FIXED sc_fixed<T_WL, T_IWL>
+#define T_FX_UFIXED sc_ufixed<T_WL, T_IWL>
+
+#define T_WL 4
+#define T_IWL 4
+
+#endif