summaryrefslogtreecommitdiff
path: root/src/test/lib/tests/test_multiply.sail
diff options
context:
space:
mode:
authorRobert Norton2017-07-19 18:08:02 +0100
committerRobert Norton2017-07-19 18:08:02 +0100
commit632b10c0d4b01dc1af8593b8ae1f088fbfd9e342 (patch)
treeac566808213125670da5f4dc3d702fe663333f7e /src/test/lib/tests/test_multiply.sail
parentd8969b1f9631dc15d5fb6b3b33a4a69dbfb7358a (diff)
split library tests into separate files to avoid risk of sail compiler stack overflow.
Diffstat (limited to 'src/test/lib/tests/test_multiply.sail')
-rw-r--r--src/test/lib/tests/test_multiply.sail21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/lib/tests/test_multiply.sail b/src/test/lib/tests/test_multiply.sail
new file mode 100644
index 00000000..03adfa27
--- /dev/null
+++ b/src/test/lib/tests/test_multiply.sail
@@ -0,0 +1,21 @@
+function unit test () = {
+ test_assert ("multiply", 6 * 9 == 54);
+ test_assert ("multiply_vec", ((bit[8])(0x6 * 0xb)) == 0x42);
+ test_assert ("mult_range_vec", ((bit[8])(6 * 0xb)) == 0x42);
+ test_assert ("mult_vec_range", ((bit[8])(0x6 * 11)) == 0x42);
+ (* XXX mult_oveflow_vec missing *)
+
+ (* XXX not implmented
+ test_assert ("multiply_signed", 6 *_s 9 == 54); *)
+ test_assert ("multiply_vec_signed", ((bit[8])(0x6 *_s 0xb)) == 0xe2);
+ test_assert ("mult_range_vec_signed", ((bit[8])(6 *_s 0xb)) == 0xe2);
+ test_assert ("mult_vec_range_signed", ((bit[8])(0x6 *_s 11)) == 0xe2);
+
+ (* XXX don't think it's possible to set carryout out bit *)
+ test_assert ("mult_overflow_vec_signed0", (((bit[8], bit, bit)) (0xf *_s 0x2)) == (0xfe, false, false));
+ test_assert ("mult_overflow_vec_signed1", (((bit[8], bit, bit)) (0xf *_s 0xf)) == (0x01, false, false));
+ test_assert ("mult_overflow_vec_signed2", (((bit[8], bit, bit)) (0x8 *_s 0x8)) == (0x40, true, false));
+ test_assert ("mult_overflow_vec_signed3", (((bit[8], bit, bit)) (0x7 *_s 0x7)) == (0x31, true, false));
+ test_assert ("mult_overflow_vec_signed4", (((bit[8], bit, bit)) (0x8 *_s 0x7)) == (0xc8, true, false));
+}
+