// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include #include #include "../fpga/hls_simulation/hls_cores.h" TEST_CASE("FPGA_spot_finder_core","[FPGA][SpotFinder]") { STREAM_768 input; STREAM_768 output; hls::stream> strong_pixel; hls::stream> mask_stream; ap_int<32> in_photon_count_threshold = 8; float_uint32 in_strong_pixel_threshold; in_strong_pixel_threshold.f = 4.0; std::vector 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] = INT24_MIN; else input_frame[i] = i % RAW_MODULE_COLS; } input << packet_768_t{.user = 0}; for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++) { ap_int<24> tmp[32]; for (int j = 0; j < 32; j++) tmp[j] = input_frame[i * 32 + j]; input << packet_768_t{.data = pack32(tmp), .user = 0}; mask_stream << UINT32_MAX; } input << packet_768_t{.user = 1}; ap_uint<32> tmp_strong_pixel_threshold = in_strong_pixel_threshold.u; spot_finder(input, mask_stream, output, strong_pixel, in_photon_count_threshold, tmp_strong_pixel_threshold); REQUIRE(input.size() == 0); REQUIRE(output.size() == RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2); REQUIRE(strong_pixel.size() == RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 16 + 1); }