200 XSPN samples passed

This commit is contained in:
Stanislaw Kaushanski 2020-12-10 15:38:25 +01:00
parent 50428965e9
commit 06cc727883
1 changed files with 37 additions and 34 deletions

View File

@ -54,7 +54,6 @@ void configure_irq(size_t irq_num, function_ptr_t handler, unsigned char prio=1)
}
static void msi_interrupt_handler(){
int * local_mem_base = (int *) 0x80000100;
printf("INterrupt handler call\n");
}
@ -89,52 +88,56 @@ bool double_equals(double a, double b, double epsilon = 0.001)
return std::abs(a - b) < epsilon;
}
void run_xspn() {
printf("Start SPN HW accelerator\n");
spn::mode_reg() = 0;
spn::input_length_reg() = 100; // each sample consists of 5 uint8 values
spn::input_addr_reg() = 0x80001000;
spn::output_addr_reg() = 0x80002000;
spn::num_of_in_beats_reg() = 8; // Number of AXI4 burst beats needed to load all input data
spn::num_of_out_beats_reg() = 13; // Number of AXI4 burst beats needed to store all result data
spn::start_reg() = 1;
delayUS(50);
printf("Cycle count:%d\n", spn::start_reg());
spn::interrupt_reg() = 1;
}
/*! \brief main function
*
*/
int main() {
platform_init();
// write input samples into the memory
int * mem_base = (int *) 0x80001000;
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;
*(mem_base+j) |= input_data.at(i+3) << 24;
}
////////////////////////////////////////////////
spn::mode_reg() = 1;
spn::start_reg() = 1;
printf("READOUT HW:0x%x\n", spn::readout_reg());
spn::interrupt_reg() = 1;
printf("Start SPN HW accelerator\n");
spn::mode_reg() = 0;
spn::input_length_reg() = 15;
spn::input_addr_reg() = 0x80001000;
spn::output_addr_reg() = 0x80001000;
spn::num_of_in_beats_reg() = 2;
spn::num_of_out_beats_reg() = 2;
spn::start_reg() = 1;
for (int k = 0; k < 200; k+=100) {
// write input samples into the memory
int * mem_base = (int *) 0x80001000;
int offset = k * 5;
delayUS(50);
printf("Cycle count:0x%x\n", spn::start_reg());
spn::interrupt_reg() = 1;
delayUS(10);
// read calculation results from the memory
double * res_base = (double*)mem_base;
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);
for(size_t i = 0, j = 0; j < 125; i += 4, j++) {
*(mem_base+j) = input_data.at(offset+i);
*(mem_base+j) |= input_data.at(offset+i+1) << 8;
*(mem_base+j) |= input_data.at(offset+i+2) << 16;
*(mem_base+j) |= input_data.at(offset+i+3) << 24;
}
run_xspn();
// read calculation results from the memory
double * res_base = (double*) 0x80002000;
for (int i = 0; i < 100; i++) {
if (double_equals(res_base[i] * ln2, ref_data.at(k+i))) {
// printf("XSPN ref %d comparison PASSED\n", k+i);
} else {
printf("XSPN ref %d comparison FAILED\n", k+i);
}
}
}
return 0;