FPGA: Added spot_finder_line_sum (work in progress)
This commit is contained in:
@@ -128,6 +128,26 @@ TEST_CASE("FPGA_update_sum" , "[FPGA][SpotFinder]") {
|
||||
REQUIRE(arr_out[i] == 8 * i + 2);
|
||||
}
|
||||
|
||||
int sum_consecutive(int x0, int n) {
|
||||
int ret = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
ret += x0 + i;
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEST_CASE("FPGA_prefix_sum" , "[FPGA][SpotFinder]") {
|
||||
ap_uint<16*(32+2*FPGA_NBX)> input = 0;
|
||||
for (int i = 0; i < 32+2*FPGA_NBX; i++)
|
||||
input(i*16+15, i*16) = i;
|
||||
|
||||
auto output = prefix_sum<16>(input);
|
||||
ap_uint<16> output_unpacked[32];
|
||||
unpack32(output, output_unpacked);
|
||||
REQUIRE(output_unpacked[0] == sum_consecutive(0, 2 * FPGA_NBX + 1));
|
||||
REQUIRE(output_unpacked[2] == sum_consecutive(2, 2 * FPGA_NBX + 1));
|
||||
REQUIRE(output_unpacked[7] == sum_consecutive(7, 2 * FPGA_NBX + 1));
|
||||
}
|
||||
|
||||
bool Isigma_cpu(double val, double sum, double sum2, float threshold) {
|
||||
double mean = sum / ((2*FPGA_NBX+1) * (2*FPGA_NBX+1));
|
||||
double mean2 = sum2 / ((2*FPGA_NBX+1) * (2*FPGA_NBX+1));
|
||||
@@ -161,7 +181,6 @@ TEST_CASE("FPGA_spot_check_threshold","[FPGA][SpotFinder]") {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("FPGA_spot_finder_update_sum","[FPGA][SpotFinder]") {
|
||||
STREAM_512 input;
|
||||
STREAM_512 output;
|
||||
@@ -244,3 +263,49 @@ TEST_CASE("FPGA_spot_finder_update_sum","[FPGA][SpotFinder]") {
|
||||
CHECK(valid[1+511*1024] == FPGA_NBX + 1);
|
||||
}
|
||||
|
||||
TEST_CASE("FPGA_spot_finder_line_sum","[FPGA][SpotFinder]") {
|
||||
STREAM_512 input;
|
||||
STREAM_512 output;
|
||||
|
||||
hls::stream<ap_uint<SUM_BITWIDTH*32>> sum_in;
|
||||
hls::stream<ap_uint<SUM2_BITWIDTH*32>> sum2_in;
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>> valid_in;
|
||||
|
||||
hls::stream<ap_uint<SUM_BITWIDTH*32>> sum_out;
|
||||
hls::stream<ap_uint<SUM2_BITWIDTH*32>> sum2_out;
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>> valid_out;
|
||||
|
||||
ap_int<SUM_BITWIDTH> sum_unpacked[32];
|
||||
ap_int<SUM2_BITWIDTH> sum2_unpacked[32];
|
||||
ap_int<MASK_SUM_BITWIDTH> valid_unpacked[32];
|
||||
|
||||
input << packet_512_t{.user = 0};
|
||||
for (int i = 0; i < 32; i++)
|
||||
input << packet_512_t{.data = 0, .user = 0};
|
||||
|
||||
input << packet_512_t{.user = 1};
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
sum_unpacked[j] = i * 32 + j;
|
||||
sum2_unpacked[j] = 8934 + (i * 32 + j);
|
||||
valid_unpacked[j] = i;
|
||||
}
|
||||
sum_in << pack32(sum_unpacked);
|
||||
sum2_in << pack32(sum2_unpacked);
|
||||
valid_in << pack32(valid_unpacked);
|
||||
}
|
||||
|
||||
spot_finder_line_sum(input, output, sum_in, sum2_in, valid_in, sum_out, sum2_out, valid_out);
|
||||
|
||||
REQUIRE(input.size() == 0);
|
||||
|
||||
REQUIRE(output.size() == 32 + 2);
|
||||
REQUIRE(sum_out.size() == 33);
|
||||
REQUIRE(sum2_out.size() == 33);
|
||||
REQUIRE(valid_out.size() == 33);
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user