/*
 * 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 <cstdio>

#include "tests/kelvin_isa/kelvin_test.h"

template <int bits>
void test_acset() {
  vconv_u8_t cmd;
  cmd.mode = 0;
  cmd.start = 0;
  cmd.stop = 7;
  cmd.sbias1 = 0x56;
  cmd.sdata1 = false;
  cmd.sbias2 = 0xbc;
  cmd.sdata2 = true;

  uint32_t cmdw;
  memcpy(&cmdw, &cmd, 4);

  // clang-format off
  const uint8_t ina[8][bits/8] = {
    { 0xea, 0xe6, 0xaa, 0xb0, 0x5e, 0x46, 0x43, 0x2c,
      0x58, 0x69, 0xd4, 0x25, 0xf0, 0xe9, 0x74, 0xd5,
      0x34, 0x16, 0x4c, 0x86, 0xa8, 0x0c, 0xac, 0xa8,
      0x9f, 0x99, 0x5d, 0xe0, 0x1a, 0x93, 0x65, 0x88, },
    { 0x4a, 0x3a, 0x57, 0x8b, 0x50, 0x6c, 0x1b, 0x37,
      0x76, 0x8c, 0x72, 0x55, 0xb3, 0xce, 0xf3, 0x50,
      0x74, 0x51, 0xb2, 0xb9, 0xb9, 0x76, 0xc4, 0x94,
      0x29, 0x52, 0x16, 0xa8, 0x68, 0xa7, 0x8e, 0xe2, },
    { 0x61, 0xe8, 0xb8, 0xae, 0x43, 0x0a, 0xbe, 0xfa,
      0x0b, 0x32, 0x7a, 0x92, 0x44, 0x3a, 0x60, 0xd3,
      0x11, 0xc0, 0xb3, 0x8c, 0x7e, 0x5b, 0x9c, 0xe9,
      0x03, 0x94, 0x7f, 0x10, 0x38, 0xd5, 0xc6, 0xeb, },
    { 0x5c, 0x79, 0x44, 0xe9, 0xfb, 0x32, 0x00, 0xf0,
      0x79, 0xed, 0x92, 0x77, 0x93, 0x45, 0xc3, 0x63,
      0x33, 0x7e, 0x07, 0xc5, 0x07, 0x76, 0x9d, 0xf0,
      0x4e, 0x6a, 0x67, 0xcc, 0xca, 0xab, 0xd4, 0x24, },
    { 0x82, 0x86, 0xbb, 0xd9, 0x4b, 0xda, 0x2e, 0xbb,
      0x8d, 0xbb, 0x82, 0x0e, 0x53, 0xaa, 0xb8, 0xfa,
      0xa1, 0x75, 0x6e, 0x4a, 0x3c, 0xba, 0xa1, 0x88,
      0x88, 0x6c, 0x74, 0x5b, 0x09, 0x83, 0x98, 0xdc, },
    { 0x91, 0x9a, 0x9f, 0xcd, 0x87, 0xd7, 0x74, 0x90,
      0xa5, 0x25, 0xcf, 0x56, 0x5d, 0x41, 0x56, 0xc2,
      0x0d, 0xdd, 0xd8, 0x2c, 0x59, 0x1d, 0x1c, 0x66,
      0x06, 0xe9, 0xd3, 0x51, 0x83, 0x16, 0x65, 0x56, },
    { 0xf6, 0x95, 0x7c, 0x47, 0xf5, 0x56, 0x53, 0x58,
      0x87, 0x9c, 0xde, 0xac, 0x76, 0x78, 0x71, 0x86,
      0x5c, 0xdb, 0x5f, 0x0d, 0xc4, 0x5f, 0x48, 0x61,
      0x48, 0x6f, 0x77, 0x26, 0x68, 0xf1, 0x39, 0x58, },
    { 0x32, 0x36, 0x68, 0x29, 0x67, 0xb8, 0x7c, 0xdd,
      0xb9, 0x17, 0xb0, 0xec, 0x2e, 0xcc, 0xa5, 0x54,
      0x76, 0x56, 0xc8, 0x0b, 0x77, 0xa1, 0xef, 0xf5,
      0xcf, 0xd6, 0x84, 0x7a, 0x84, 0x0f, 0x4e, 0x16, },
  };

  const uint8_t inb[8][bits/8] = {
    { 0x33, 0xc9, 0xb8, 0xa1, 0xea, 0x2d, 0x2c, 0x18,
      0x92, 0x98, 0x8e, 0x19, 0xf2, 0xd8, 0x55, 0x92,
      0x26, 0x4a, 0x8d, 0x3e, 0xb0, 0x01, 0x81, 0x6c,
      0x3e, 0xcc, 0x8f, 0x9b, 0xf9, 0xde, 0x94, 0x9e, },
    { 0x7f, 0xa9, 0xa8, 0x3a, 0xa3, 0xef, 0xb7, 0xb5,
      0x44, 0x93, 0xa1, 0xf7, 0x09, 0x7b, 0xb6, 0x6f,
      0x98, 0x9e, 0xaa, 0x60, 0xb4, 0xe2, 0x9b, 0x93,
      0x4b, 0x8f, 0xa7, 0xe4, 0x96, 0xe6, 0xcd, 0x93, },
    { 0x63, 0xfd, 0x8e, 0xd2, 0xfd, 0xe0, 0x13, 0x5b,
      0xd7, 0x5f, 0xa0, 0x56, 0x02, 0x29, 0x4e, 0xfa,
      0x9b, 0x30, 0xa5, 0xdb, 0xb4, 0xe7, 0xb9, 0x52,
      0x05, 0xda, 0x57, 0xa8, 0xbd, 0x65, 0xfe, 0xf0, },
    { 0x1c, 0x22, 0x48, 0x3f, 0x5c, 0xae, 0x08, 0x8c,
      0x40, 0xd4, 0x97, 0xeb, 0xb1, 0x92, 0x50, 0xd4,
      0x66, 0xac, 0x58, 0x20, 0x3c, 0x92, 0xc0, 0x5c,
      0x50, 0x89, 0x42, 0x93, 0x7b, 0x8b, 0x0a, 0x33, },
    { 0x3e, 0x98, 0x0c, 0x1a, 0xcd, 0x6c, 0xd5, 0x26,
      0xad, 0x94, 0xd0, 0x6a, 0xbd, 0x19, 0x02, 0x42,
      0xc1, 0x69, 0x20, 0x94, 0xc2, 0x74, 0xb7, 0xbf,
      0x9f, 0x45, 0xd5, 0x6f, 0x22, 0x92, 0xbe, 0x88, },
    { 0x4c, 0xbc, 0xed, 0x2f, 0x9e, 0xe5, 0x27, 0xf9,
      0x0e, 0xd3, 0xb5, 0x74, 0x83, 0x5f, 0x5a, 0xa2,
      0xaf, 0x0f, 0x49, 0x0a, 0xe3, 0x1b, 0xc7, 0xd1,
      0xd1, 0x51, 0xa9, 0x86, 0x75, 0xb3, 0xbc, 0xe9, },
    { 0x9f, 0x2a, 0xe9, 0xfc, 0x4f, 0x10, 0x57, 0x7d,
      0x14, 0xec, 0x5f, 0x39, 0xa3, 0x0e, 0x92, 0x62,
      0x86, 0xad, 0xae, 0x38, 0x95, 0x7f, 0xde, 0x30,
      0x9d, 0xbf, 0xe5, 0xb2, 0xb3, 0xb6, 0xf1, 0x42, },
    { 0x0c, 0xd7, 0xd4, 0xa8, 0xae, 0x1a, 0xe6, 0x3c,
      0xf0, 0xd7, 0x4f, 0x36, 0x37, 0xeb, 0x1d, 0xe9,
      0xc7, 0xe4, 0x82, 0xe4, 0x44, 0x1c, 0x6a, 0xa1,
      0x96, 0xfe, 0x2e, 0x9d, 0x36, 0xb4, 0x1c, 0x03, },
  };
  // clang-format on

  uint32_t ref[bits / 32][bits / 32];
  uint32_t dut[bits / 32][bits / 32];

  vld_b_x(v0, ina[0]);
  vld_b_x(v1, ina[1]);
  vld_b_x(v2, ina[2]);
  vld_b_x(v3, ina[3]);
  vld_b_x(v4, ina[4]);
  vld_b_x(v5, ina[5]);
  vld_b_x(v6, ina[6]);
  vld_b_x(v7, ina[7]);

  vld_b_x(v16, inb[0]);
  vld_b_x(v17, inb[1]);
  vld_b_x(v18, inb[2]);
  vld_b_x(v19, inb[3]);
  vld_b_x(v20, inb[4]);
  vld_b_x(v21, inb[5]);
  vld_b_x(v22, inb[6]);
  vld_b_x(v23, inb[7]);

  // REF.
  aconv_vxv(v48, v0, cmdw, v16);
  aconv_vxv(v48, v16, cmdw, v0);
  vcget(v48);
  vst_w_x(v48, ref[0]);
  vst_w_x(v49, ref[1]);
  vst_w_x(v50, ref[2]);
  vst_w_x(v51, ref[3]);
  vst_w_x(v52, ref[4]);
  vst_w_x(v53, ref[5]);
  vst_w_x(v54, ref[6]);
  vst_w_x(v55, ref[7]);

  // DUT.
  aconv_vxv(v48, v0, cmdw, v16);
  vcget(v48);
  acset_v(v48, v48);
  aconv_vxv(v48, v16, cmdw, v0);
  vcget(v48);
  vst_w_x(v48, dut[0]);
  vst_w_x(v49, dut[1]);
  vst_w_x(v50, dut[2]);
  vst_w_x(v51, dut[3]);
  vst_w_x(v52, dut[4]);
  vst_w_x(v53, dut[5]);
  vst_w_x(v54, dut[6]);
  vst_w_x(v55, dut[7]);

  // Check the results.
  for (int i = 0; i < 8; ++i) {
    for (int j = 0; j < 8; ++j) {
      const uint32_t r = ref[i][j];
      const uint32_t d = dut[i][j];
      if (r != d) {
        printf("**error::test_acset[%d,%d] %08lx %08lx\n", i, j, r, d);
        exit(-1);
      }
    }
  }
}

int main() {
  test_acset<VLEN>();
  return 0;
}
