run 10000 XSPN samples

This commit is contained in:
Stanislaw Kaushanski 2020-12-11 17:01:35 +01:00
parent 06cc727883
commit db22ccbce5
2 changed files with 11 additions and 15 deletions

Binary file not shown.

View File

@ -76,7 +76,7 @@ void platform_init(){
clear_csr(mie, MIP_MEIP);
clear_csr(mie, MIP_MTIP);
for (auto& h:g_ext_interrupt_handlers) h=no_interrupt_handler;
configure_irq(1, msi_interrupt_handler);
configure_irq(2, msi_interrupt_handler);
// Enable interrupts in general.
set_csr(mstatus, MSTATUS_MIE);
// Enable the Machine-External bit in MIE
@ -89,17 +89,14 @@ bool double_equals(double a, double b, double epsilon = 0.001)
}
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::input_addr_reg() = 0x800C0000;
spn::output_addr_reg() = 0x8001C000;
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;
}
@ -113,27 +110,26 @@ int main() {
printf("READOUT HW:0x%x\n", spn::readout_reg());
spn::interrupt_reg() = 1;
for (int k = 0; k < 200; k+=100) {
for (int k = 0; k < 10000; k+=100) {
// write input samples into the memory
int * mem_base = (int *) 0x80001000;
int * mem_base = (int *) 0x800C0000;
int offset = k * 5;
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;
*(mem_base+j) |= (input_data.at(offset+i+1) << 8) & 0x0000FF00;
*(mem_base+j) |= (input_data.at(offset+i+2) << 16) & 0x00FF0000;
*(mem_base+j) |= (input_data.at(offset+i+3) << 24) & 0xFF000000;
}
printf("XSPN process samples %d - %d\n", k, k+100);
run_xspn();
// read calculation results from the memory
double * res_base = (double*) 0x80002000;
double * res_base = (double*) 0x8001C000;
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 {
if (!double_equals(res_base[i] * ln2, ref_data.at(k+i))) {
printf("XSPN ref %d comparison FAILED\n", k+i);
}
}