FPGA: Spot finder 2nd version improved

This commit is contained in:
2023-10-04 12:12:43 +02:00
parent 5460c10f76
commit 7889f1666a
6 changed files with 88 additions and 38 deletions

View File

@@ -190,7 +190,7 @@ TEST_CASE("FPGA_spot_finder_update_sum","[FPGA][SpotFinder]") {
hls::stream<ap_uint<SUM2_BITWIDTH*32>> sum2_out;
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>> valid_out;
std::vector<int16_t> input_frame(RAW_MODULE_SIZE);
std::vector<int16_t> input_frame(RAW_MODULE_SIZE), output_frame(RAW_MODULE_SIZE);
for (int i = 0; i < RAW_MODULE_SIZE; i++) {
if (i % RAW_MODULE_COLS == 1023)
input_frame[i] = INT16_MIN;
@@ -198,6 +198,7 @@ TEST_CASE("FPGA_spot_finder_update_sum","[FPGA][SpotFinder]") {
input_frame[i] = i % RAW_MODULE_COLS;
}
auto input_frame_512 = (ap_uint<512> *) input_frame.data();
auto output_frame_512 = (ap_uint<512> *) output_frame.data();
input << packet_512_t{.user = 0};
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++)
@@ -205,7 +206,7 @@ TEST_CASE("FPGA_spot_finder_update_sum","[FPGA][SpotFinder]") {
input << packet_512_t{.user = 1};
spot_finder_update_sum(input, output, sum_out, sum2_out, valid_out);
spot_finder_col_sum(input, output, sum_out, sum2_out, valid_out);
REQUIRE(input.size() == 0);
@@ -262,6 +263,14 @@ TEST_CASE("FPGA_spot_finder_update_sum","[FPGA][SpotFinder]") {
CHECK(valid[1+509*1024] == FPGA_NBX + 1 + 2);
CHECK(valid[1+510*1024] == FPGA_NBX + 1 + 1);
CHECK(valid[1+511*1024] == FPGA_NBX + 1);
spot_finder_packet packet_out;
output >> packet_out;
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++) {
output >> packet_out;
output_frame_512[i] = packet_out.data;
}
REQUIRE(output_frame == input_frame);
}
TEST_CASE("FPGA_spot_finder_line_sum","[FPGA][SpotFinder]") {
@@ -285,9 +294,19 @@ TEST_CASE("FPGA_spot_finder_line_sum","[FPGA][SpotFinder]") {
ap_int<SUM2_BITWIDTH> sum2_unpacked[32];
ap_int<MASK_SUM_BITWIDTH> valid_unpacked[32];
std::vector<int16_t> input_frame(RAW_MODULE_COLS), output_frame(RAW_MODULE_COLS);
for (int i = 0; i < RAW_MODULE_COLS; i++) {
if (i % RAW_MODULE_COLS == 1023)
input_frame[i] = INT16_MIN;
else
input_frame[i] = i % RAW_MODULE_COLS;
}
auto input_frame_512 = (ap_uint<512> *) input_frame.data();
auto output_frame_512 = (ap_uint<512> *) output_frame.data();
input << spot_finder_packet{.user = 0};
for (int i = 0; i < 32; i++)
input << spot_finder_packet{.data = 0, .user = 0};
input << spot_finder_packet{.data = input_frame_512[i], .user = 0};
input << spot_finder_packet{.user = 1};
@@ -358,4 +377,11 @@ TEST_CASE("FPGA_spot_finder_line_sum","[FPGA][SpotFinder]") {
CHECK(valid_output[1022] == FPGA_NBX+2);
CHECK(valid_output[1023] == FPGA_NBX+1);
spot_finder_packet packet_out;
output >> packet_out;
for (int i = 0; i < 32; i++) {
output >> packet_out;
output_frame_512[i] = packet_out.data;
}
}