Use template for vsub.
Change-Id: I8b51223940b883e6ac47e85dd6e6e67594496ffb
diff --git a/softrvv/tests/CMakeLists.txt b/softrvv/tests/CMakeLists.txt
index b102a7d..d6e962c 100644
--- a/softrvv/tests/CMakeLists.txt
+++ b/softrvv/tests/CMakeLists.txt
@@ -12,17 +12,6 @@
vec_cc_test(
NAME
- softrvv_vsub
- SRCS
- softrvv_vsub_test.cpp
- DEPS
- softrvv
- LINKOPTS
- -Xlinker --defsym=__itcm_length__=128K
-)
-
-vec_cc_test(
- NAME
softrvv_vwadd
SRCS
softrvv_vwadd_test.cpp
@@ -109,6 +98,15 @@
softrvv_vec_cc_generated_test(
NAME
+ vsub
+ TEMPLATE
+ softrvv_vsub_test.tpl.cpp
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=128K
+)
+
+softrvv_vec_cc_generated_test(
+ NAME
vmul
TEMPLATE
softrvv_vmul_test.tpl.cpp
diff --git a/softrvv/tests/softrvv_vsub_test.cpp b/softrvv/tests/softrvv_vsub_test.cpp
deleted file mode 100644
index 1b7a4b5..0000000
--- a/softrvv/tests/softrvv_vsub_test.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <riscv_vector.h>
-#include <springbok.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "pw_unit_test/framework.h"
-#include "softrvv.h"
-
-namespace softrvv_vadd_test {
-namespace {
-
-int32_t src1[] = {2, 4, 6, 8, 10};
-int32_t src2[] = {1, 2, 3, 4, 5};
-int32_t rs1 = 2;
-const uint32_t AVL_CONST = sizeof(src1)/sizeof(src1[0]);
-int32_t dest[AVL_CONST];
-
-
-int32_t ref_vv[] = {1, 2, 3, 4, 5};
-int32_t ref_vx[] = {0, 2, 4, 6, 8};
-
-int32_t ref_r_vx[] = {0, -2, -4, -6, -8};
-
-class SoftRvvVsubTest : public ::testing::Test {
- protected:
- void SetUp() override { memset(dest, 0, sizeof(dest)); }
-};
-
-TEST_F(SoftRvvVsubTest, VV) {
- softrvv::vsub_vv<int32_t>(dest, src1, src2, AVL_CONST);
- ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0);
-}
-
-TEST_F(SoftRvvVsubTest, VX) {
- softrvv::vsub_vx<int32_t>(dest, src1, &rs1, AVL_CONST);
- ASSERT_EQ(memcmp(dest, ref_vx, sizeof(dest)), 0);
-}
-
-TEST_F(SoftRvvVsubTest, RVX) {
- softrvv::vrsub_vx<int32_t>(dest, src1, &rs1, AVL_CONST);
- ASSERT_EQ(memcmp(dest, ref_r_vx, sizeof(dest)), 0);
-}
-
-} // namespace
-} // namespace softrvv_vsub_test
diff --git a/softrvv/tests/templates/softrvv_vsub_test.tpl.cpp b/softrvv/tests/templates/softrvv_vsub_test.tpl.cpp
new file mode 100644
index 0000000..9facf2a
--- /dev/null
+++ b/softrvv/tests/templates/softrvv_vsub_test.tpl.cpp
@@ -0,0 +1,9 @@
+<%inherit file="base.tpl.cpp"/>\
+<%namespace name="tests" file="opivv_opivx_test.tpl.cpp"/>
+<%
+import numpy as np
+src1, src2, rs1 = parent.module.get_test_inputs(np.int32, N=5)
+ref_vv = src1 - src2
+ref_vx = src1 - rs1
+%>\
+${tests.test_opivv_opivx("int32_t", op, src1, src2, rs1, ref_vv, ref_vx)}