From 06cc727883f3aafed8c5aecf77d59d7a520b32b8 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 10 Dec 2020 15:38:25 +0100 Subject: [PATCH] 200 XSPN samples passed --- raven_spn/src/raven_spn.cpp | 71 +++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/raven_spn/src/raven_spn.cpp b/raven_spn/src/raven_spn.cpp index 30d50ae..382365c 100644 --- a/raven_spn/src/raven_spn.cpp +++ b/raven_spn/src/raven_spn.cpp @@ -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;