run 10000 XSPN samples
This commit is contained in:
parent
06cc727883
commit
db22ccbce5
Binary file not shown.
|
@ -76,7 +76,7 @@ void platform_init(){
|
||||||
clear_csr(mie, MIP_MEIP);
|
clear_csr(mie, MIP_MEIP);
|
||||||
clear_csr(mie, MIP_MTIP);
|
clear_csr(mie, MIP_MTIP);
|
||||||
for (auto& h:g_ext_interrupt_handlers) h=no_interrupt_handler;
|
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.
|
// Enable interrupts in general.
|
||||||
set_csr(mstatus, MSTATUS_MIE);
|
set_csr(mstatus, MSTATUS_MIE);
|
||||||
// Enable the Machine-External bit in 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() {
|
void run_xspn() {
|
||||||
printf("Start SPN HW accelerator\n");
|
|
||||||
|
|
||||||
spn::mode_reg() = 0;
|
spn::mode_reg() = 0;
|
||||||
spn::input_length_reg() = 100; // each sample consists of 5 uint8 values
|
spn::input_length_reg() = 100; // each sample consists of 5 uint8 values
|
||||||
spn::input_addr_reg() = 0x80001000;
|
spn::input_addr_reg() = 0x800C0000;
|
||||||
spn::output_addr_reg() = 0x80002000;
|
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_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::num_of_out_beats_reg() = 13; // Number of AXI4 burst beats needed to store all result data
|
||||||
spn::start_reg() = 1;
|
spn::start_reg() = 1;
|
||||||
delayUS(50);
|
delayUS(50);
|
||||||
printf("Cycle count:%d\n", spn::start_reg());
|
|
||||||
spn::interrupt_reg() = 1;
|
spn::interrupt_reg() = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,27 +110,26 @@ int main() {
|
||||||
printf("READOUT HW:0x%x\n", spn::readout_reg());
|
printf("READOUT HW:0x%x\n", spn::readout_reg());
|
||||||
spn::interrupt_reg() = 1;
|
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
|
// write input samples into the memory
|
||||||
int * mem_base = (int *) 0x80001000;
|
int * mem_base = (int *) 0x800C0000;
|
||||||
int offset = k * 5;
|
int offset = k * 5;
|
||||||
|
|
||||||
for(size_t i = 0, j = 0; j < 125; i += 4, j++) {
|
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);
|
||||||
*(mem_base+j) |= input_data.at(offset+i+1) << 8;
|
*(mem_base+j) |= (input_data.at(offset+i+1) << 8) & 0x0000FF00;
|
||||||
*(mem_base+j) |= input_data.at(offset+i+2) << 16;
|
*(mem_base+j) |= (input_data.at(offset+i+2) << 16) & 0x00FF0000;
|
||||||
*(mem_base+j) |= input_data.at(offset+i+3) << 24;
|
*(mem_base+j) |= (input_data.at(offset+i+3) << 24) & 0xFF000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("XSPN process samples %d - %d\n", k, k+100);
|
||||||
run_xspn();
|
run_xspn();
|
||||||
|
|
||||||
// read calculation results from the memory
|
// read calculation results from the memory
|
||||||
double * res_base = (double*) 0x80002000;
|
double * res_base = (double*) 0x8001C000;
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
if (double_equals(res_base[i] * ln2, ref_data.at(k+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);
|
printf("XSPN ref %d comparison FAILED\n", k+i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue