Compile XSPN input and ref data in flash memory.

Comparison of first 15 samples passed.
This commit is contained in:
Stanislaw Kaushanski 2020-12-08 17:07:21 +01:00
parent afb8a677f1
commit 50428965e9
3 changed files with 20022 additions and 22 deletions

Binary file not shown.

View File

@ -7,11 +7,17 @@
#include <cstdio>
#include <cstdint>
#include <array>
#include <cmath>
using spn =spn_regs<0x90000000>;
#define IOF_ENABLE_TERMINAL (0x30000)
// huge arrays of XSPN input and referance data
extern std::array<uint8_t, 50000> input_data;
extern std::array<double, 10000> ref_data;
constexpr auto ln2 = std::log(2);
typedef void (*function_ptr_t) (void);
//! Instance data for the PLIC.
@ -92,18 +98,8 @@ int main() {
// write input samples into the memory
int * mem_base = (int *) 0x80001000;
std::array<uint8_t, 64> input_data = {
0, 0, 0, 1, 0,
0, 1, 5, 2, 0,
0, 0, 8, 0, 0,
0, 0, 5, 4, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0
};
for(size_t i = 0, j = 0; j < 16; i += 4, j++) {
for(size_t i = 0, j = 0; j < 19; i += 4, j++) {
*(mem_base+j) = input_data.at(i);
*(mem_base+j) |= input_data.at(i+1) << 8;
*(mem_base+j) |= input_data.at(i+2) << 16;
@ -118,11 +114,11 @@ int main() {
printf("Start SPN HW accelerator\n");
spn::mode_reg() = 0;
spn::input_length_reg() = 8;
spn::input_length_reg() = 15;
spn::input_addr_reg() = 0x80001000;
spn::output_addr_reg() = 0x80001000;
spn::num_of_in_beats_reg() = 1;
spn::num_of_out_beats_reg() = 1;
spn::num_of_in_beats_reg() = 2;
spn::num_of_out_beats_reg() = 2;
spn::start_reg() = 1;
delayUS(50);
@ -133,14 +129,13 @@ int main() {
// read calculation results from the memory
double * res_base = (double*)mem_base;
if (double_equals(res_base[0], -3.5530456851)) {
printf("XSPN reference value comparison PASSED\n");
} else {
printf("XSPN reference value comparison FAILED\n");
return 1;
}
for (int i = 0; i < 15; i++) {
if (double_equals(res_base[i] * ln2, ref_data.at(i))) {
printf("XSPN ref %d comparison PASSED\n", i);
} else {
printf("XSPN ref %d comparison FAILED\n", i);
}
}
printf("End of execution");
return 0;
}

20005
raven_spn/src/xspn_data.cpp Normal file

File diff suppressed because it is too large Load Diff