42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include <iostream>
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include "../fpga/hls/hls_jfjoch.h"
|
|
#include "../fpga/hls/spot_finder.h"
|
|
|
|
TEST_CASE("FPGA_spot_finder_core","[FPGA][SpotFinder]") {
|
|
STREAM_512 input;
|
|
STREAM_512 output;
|
|
hls::stream<ap_axiu<32,1,1,1>> strong_pixel;
|
|
|
|
ap_int<16> in_photon_count_threshold = 8;
|
|
ap_uint<16> in_strong_pixel_threshold = 16;
|
|
|
|
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;
|
|
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 << packet_512_t{.user = 0};
|
|
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++)
|
|
input << packet_512_t{.data = input_frame_512[i], .user = 0};
|
|
|
|
input << packet_512_t{.user = 1};
|
|
|
|
spot_finder(input,
|
|
output,
|
|
strong_pixel,
|
|
in_photon_count_threshold,
|
|
in_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);
|
|
} |