From 01cfbd34fecf11ddbea7e2feb2464f53f8dd9c71 Mon Sep 17 00:00:00 2001 From: Stas Date: Fri, 4 Dec 2020 12:34:49 +0100 Subject: [PATCH] 1st successful XSPN run. Insert few samples and get one result --- raven_spn/src/raven_spn.cpp | 52 ++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/raven_spn/src/raven_spn.cpp b/raven_spn/src/raven_spn.cpp index 4117cb6..9b4ea08 100644 --- a/raven_spn/src/raven_spn.cpp +++ b/raven_spn/src/raven_spn.cpp @@ -84,24 +84,52 @@ void platform_init(){ int main() { platform_init(); + // write input samples into the memory + int * mem_base = (int *) 0x80001000; + std::array 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++) { + *(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 reuslt:0x%x\n", spn::readout_reg()); + printf("READOUT HW:0x%x\n", spn::readout_reg()); spn::interrupt_reg() = 1; - spn::input_length_reg() = 5; - spn::input_addr_reg() = 0x80000000; - spn::output_addr_reg() = 0x80100000; - spn::num_of_in_beats_reg() = 5; - spn::num_of_out_beats_reg() = 1; - spn::mode_reg() = 0; - - uint32_t result_addr = spn::output_addr_reg(); - - spn::start_reg() = 1; printf("Start SPN HW accelerator\n"); + spn::mode_reg() = 0; + spn::input_length_reg() = 8; + 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::start_reg() = 1; + + delayUS(50); + printf("Cycle count:0x%x\n", spn::start_reg()); + spn::interrupt_reg() = 1; + delayUS(10); + + // read calculation results from the memory + int result = *mem_base; + printf("HW Result:0x%lx\n", result); + result = *(mem_base+1); + printf("HW Result:0x%lx\n", result); - delayUS(100); printf("End of execution"); return 0;