re-implement wait_for_interrupt and get rid of multiplication in
check_results for better performance
This commit is contained in:
parent
685f25e2ce
commit
7f8ddf3201
Binary file not shown.
|
@ -12,7 +12,7 @@ typedef void (*function_ptr_t) (void);
|
||||||
//! Instance data for the PLIC.
|
//! Instance data for the PLIC.
|
||||||
plic_instance_t g_plic;
|
plic_instance_t g_plic;
|
||||||
std::array<function_ptr_t,PLIC_NUM_INTERRUPTS> g_ext_interrupt_handlers;
|
std::array<function_ptr_t,PLIC_NUM_INTERRUPTS> g_ext_interrupt_handlers;
|
||||||
bool hw_interrupt{false};
|
bool hw_interrupt{true};
|
||||||
|
|
||||||
|
|
||||||
/*! \brief external interrupt handler
|
/*! \brief external interrupt handler
|
||||||
|
@ -44,14 +44,18 @@ void configure_irq(size_t irq_num, function_ptr_t handler, unsigned char prio=1)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msi_interrupt_handler(){
|
static void msi_interrupt_handler(){
|
||||||
hw_interrupt = true;
|
hw_interrupt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_for_interrupt() {
|
void wait_for_interrupt() {
|
||||||
while (!hw_interrupt) {
|
// wait until HW is done
|
||||||
delayUS(1);
|
if(hw_interrupt) {
|
||||||
};
|
do{
|
||||||
hw_interrupt = false;
|
asm("wfi");
|
||||||
|
asm("nop");
|
||||||
|
}while(hw_interrupt);
|
||||||
|
}
|
||||||
|
hw_interrupt=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!\brief initializes platform
|
/*!\brief initializes platform
|
||||||
|
|
|
@ -2,14 +2,11 @@
|
||||||
#include "spn_regs.h"
|
#include "spn_regs.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
#include <cmath> // log
|
|
||||||
|
|
||||||
using spn =spn_regs<0x90000000>;
|
using spn =spn_regs<0x90000000>;
|
||||||
|
|
||||||
// huge arrays of XSPN input and referance data
|
// huge arrays of XSPN input and referance data
|
||||||
extern std::array<uint8_t, 50000> input_data;
|
extern std::array<uint8_t, 50000> input_data;
|
||||||
extern std::array<double, 10000> ref_data;
|
extern std::array<double, 10000> ref_data;
|
||||||
constexpr auto ln2 = std::log(2);
|
|
||||||
|
|
||||||
bool double_equals(double a, double b, double epsilon = 0.001)
|
bool double_equals(double a, double b, double epsilon = 0.001)
|
||||||
{
|
{
|
||||||
|
@ -21,12 +18,12 @@ void run_xspn(int in_addr, int out_addr) {
|
||||||
spn::input_length_reg() = 500; // each sample consists of 5 uint8 values
|
spn::input_length_reg() = 500; // each sample consists of 5 uint8 values
|
||||||
spn::input_addr_reg() = in_addr;
|
spn::input_addr_reg() = in_addr;
|
||||||
spn::output_addr_reg() = out_addr;
|
spn::output_addr_reg() = out_addr;
|
||||||
spn::num_of_in_beats_reg() = 40; // Number of AXI4 burst beats needed to load all input data
|
spn::num_of_in_beats_reg() = 40; // Number of AXI4 burst beats needed to load all input data
|
||||||
spn::num_of_out_beats_reg() = 64; // Number of AXI4 burst beats needed to store all result data
|
spn::num_of_out_beats_reg() = 64; // Number of AXI4 burst beats needed to store all result data
|
||||||
spn::start_reg() = 1;
|
spn::start_reg() = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_results(int addr, int k) {
|
void check_results(int addr, int k) {
|
||||||
bool result = 0;
|
bool result = 0;
|
||||||
int step = 500;
|
int step = 500;
|
||||||
double *res_base = (double*) (addr);
|
double *res_base = (double*) (addr);
|
||||||
|
@ -34,14 +31,13 @@ bool check_results(int addr, int k) {
|
||||||
printf("Start result comparison %d - %d\n", k, k+step);
|
printf("Start result comparison %d - %d\n", k, k+step);
|
||||||
|
|
||||||
for (int i = 0; i < step; i++) {
|
for (int i = 0; i < step; i++) {
|
||||||
if (!double_equals(res_base[i] * ln2, ref_data.at(k + i))) {
|
if (!double_equals(res_base[i], ref_data.at(k + i))) {
|
||||||
printf("XSPN ref %d comparison FAILED\n", k + i);
|
printf("XSPN ref %d comparison FAILED\n", k + i);
|
||||||
*error_exit = 0x1;
|
*error_exit = 0x1;
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Compared samples %d - %d with the reference\n", k, k+step);
|
printf("Compared samples %d - %d with the reference\n", k, k+step);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief main function
|
/*! \brief main function
|
||||||
|
@ -49,29 +45,29 @@ bool check_results(int addr, int k) {
|
||||||
*/
|
*/
|
||||||
int main() {
|
int main() {
|
||||||
platform_init();
|
platform_init();
|
||||||
int ret_val = 0;
|
|
||||||
|
|
||||||
spn::mode_reg() = 1;
|
spn::mode_reg() = 1;
|
||||||
spn::start_reg() = 1;
|
spn::start_reg() = 1;
|
||||||
wait_for_interrupt();
|
wait_for_interrupt();
|
||||||
spn::interrupt_reg() = 1;
|
spn::interrupt_reg() = 1;
|
||||||
printf("READOUT HW:0x%x\n", spn::readout_reg());
|
printf("READOUT HW:0x%x\n", spn::readout_reg());
|
||||||
|
|
||||||
int in_addr = (int)input_data.data();
|
int in_addr = (int)input_data.data();
|
||||||
int out_addr = 0x800B0000;
|
int out_addr = 0x800B0000;
|
||||||
|
|
||||||
|
run_xspn(in_addr, out_addr);
|
||||||
|
|
||||||
int step = 500; // number of samples to be process at once
|
int step = 500; // number of samples to be process at once
|
||||||
for (int k = 0; k < 10000; k+=step) {
|
for (int k = 0; k < 10000; k+=step) {
|
||||||
|
|
||||||
run_xspn(in_addr, out_addr);
|
|
||||||
printf("XSPN processes samples %d - %d\n", k, k+step);
|
printf("XSPN processes samples %d - %d\n", k, k+step);
|
||||||
|
|
||||||
wait_for_interrupt();
|
wait_for_interrupt();
|
||||||
spn::interrupt_reg() = 1;
|
spn::interrupt_reg() = 1;
|
||||||
|
check_results(out_addr, k);
|
||||||
|
|
||||||
ret_val = check_results(out_addr, k);
|
|
||||||
in_addr += step * 5; // 5 bytes in each sample
|
in_addr += step * 5; // 5 bytes in each sample
|
||||||
|
run_xspn(in_addr, out_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_val;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue