Files
Jungfraujoch/fpga/hls/spot_finder_tb.cpp
T

60 lines
1.5 KiB
C++

#include "hls_jfjoch.h"
#include <thread>
int main() {
size_t nframes = 4;
int ret = 0;
STREAM_768 input;
STREAM_768 output;
hls::stream<ap_axiu<32, 1, 1, 1>> strong_pixel;
ap_int<16> in_photon_count_threshold = 8;
ap_uint<8> in_strong_pixel_threshold = 16;
std::vector<int32_t> input_frame(nframes * 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 < nframes * 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};
}
input << packet_768_t{.user = 1};
spot_finder(input, output, strong_pixel, in_photon_count_threshold,
in_strong_pixel_threshold);
if (input.size() != 0)
ret = 1;
if (output.size() != nframes * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2)
ret = 1;
for (int i = 0; i < nframes * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2; i++)
output.read();
if (strong_pixel.size() != nframes * (RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 16) + 1)
ret = 1;
for (int i = 0; i < nframes * (RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 16) + 1; i++)
strong_pixel.read();
if (ret != 0) {
printf("Test failed !!!\n");
ret = 1;
} else {
printf("Test passed !\n");
}
return ret;
}