blob: f5db3947d30a760d96ff52e9496fd6760ad2c334 [file] [log] [blame]
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
#include "pw_unit_test/framework.h"
#include "softrvv.h"
namespace softrvv_vand_test {
namespace {
uint32_t src1[] = {0xAA, 0xA5, 0x5A, 0x55, 0xFF}; // 0x55 = 0b0101
// vector test
uint32_t src2[] = {0xAA, 0xAA, 0x00, 0xAA, 0xAA}; // 0xAA = 0b1010
// register tests
uint32_t rs1[] = {0xAA, 0x0A, 0xA0};
const uint32_t kAVL = sizeof(src1) / sizeof(src1[0]);
uint32_t dest[kAVL];
uint32_t ref_vv[] = {0xAA, 0xA0, 0x00, 0x00, 0xAA};
uint32_t ref_vx[3][kAVL] = {{0xAA, 0xA0, 0x0A, 0x00, 0xAA},
{0x0A, 0x00, 0x0A, 0x00, 0x0A},
{0xA0, 0xA0, 0x00, 0x00, 0xA0}};
class SoftRvvVandTest : public ::testing::Test {
protected:
void SetUp() override { memset(dest, 0, sizeof(dest)); }
};
TEST_F(SoftRvvVandTest, VV) {
softrvv::vand_vv<uint32_t>(dest, src1, src2, kAVL);
ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0);
}
TEST_F(SoftRvvVandTest, VX) {
const int32_t num_vx_tests = sizeof(rs1) / sizeof(rs1[0]);
for (int32_t i = 0; i < num_vx_tests; i++) {
softrvv::vand_vx<uint32_t>(dest, src1, &rs1[i], kAVL);
ASSERT_EQ(memcmp(dest, &ref_vx[i], sizeof(dest)), 0);
}
}
} // namespace
} // namespace softrvv_vand_test