blob: ff13403a90ea7f0c465651561c66ef1634637ecb [file] [log] [blame]
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
#include "pw_unit_test/framework.h"
#include "softrvv/include/softrvv.h"
namespace softrvv_vwadd_test {
namespace {
int16_t src1[] = {1, 2, 3, -4, 5};
int16_t src2[] = {1, 2, 3, 4, -6};
int16_t rs1 = 3;
const uint32_t AVL_CONST = sizeof(src1) / sizeof(src1[0]);
int32_t dest[AVL_CONST];
int32_t ref_vv[] = {2, 4, 6, 0, -1};
int32_t ref_vx[] = {4, 5, 6, -1, 8};
class SoftRvvVwaddTest : public ::testing::Test {
protected:
void SetUp() override { memset(dest, 0, sizeof(dest)); }
};
TEST_F(SoftRvvVwaddTest, VV) {
softrvv::vwadd_vv<int32_t, int16_t>(dest, src1, src2, AVL_CONST);
ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0);
}
TEST_F(SoftRvvVwaddTest, VX) {
softrvv::vwadd_vx<int32_t, int16_t>(dest, src1, &rs1, AVL_CONST);
ASSERT_EQ(memcmp(dest, ref_vx, sizeof(dest)), 0);
}
} // namespace
} // namespace softrvv_vwadd_test