diff --git a/fpga/hls/hls_jfjoch.h b/fpga/hls/hls_jfjoch.h index 5332e2a8..3e6cef7c 100644 --- a/fpga/hls/hls_jfjoch.h +++ b/fpga/hls/hls_jfjoch.h @@ -200,7 +200,7 @@ void spot_finder(STREAM_512 &data_in, STREAM_512 &data_out, hls::stream> &strong_pixel_out, volatile ap_int<16> &in_photon_count_threshold, - volatile strong_pixel_threshold_t &in_strong_pixel_threshold); + volatile ap_uint<16> &in_strong_pixel_threshold); void adu_histo(STREAM_512 &data_in, STREAM_512 &data_out, diff --git a/fpga/hls/spot_finder.cpp b/fpga/hls/spot_finder.cpp index 511ed5ef..1c3108a3 100644 --- a/fpga/hls/spot_finder.cpp +++ b/fpga/hls/spot_finder.cpp @@ -308,6 +308,17 @@ void spot_finder_line_sum_align(hls::stream &data_in, data_out << packet_in; } +strong_pixel_threshold_t calculate_threshold(volatile ap_uint<16> &in_strong_pixel_threshold) { +#pragma HLS INLINE + ap_uint<16> tmp = in_strong_pixel_threshold; + strong_pixel_threshold_t strong_pixel_threshold = 0; + for (int i = 0; i < 16; i++) { +#pragma HLS UNROLL + strong_pixel_threshold[i] = tmp[i]; + } + return strong_pixel_threshold * strong_pixel_threshold; +} + void spot_finder_check_threshold(hls::stream &data_in, STREAM_512 &data_out, hls::stream> &sum_in, @@ -315,7 +326,7 @@ void spot_finder_check_threshold(hls::stream &data_in, hls::stream> &valid_in, hls::stream> &strong_pixel_out, volatile ap_int<16> &in_photon_count_threshold, - volatile strong_pixel_threshold_t &in_strong_pixel_threshold) { + volatile ap_uint<16> &in_strong_pixel_threshold) { spot_finder_packet packet_in; data_in >> packet_in; data_out << packet_512_t{.data=packet_in.data, .user=0, .last=0}; @@ -326,8 +337,7 @@ void spot_finder_check_threshold(hls::stream &data_in, data_in >> packet_in; while (!packet_in.user) { ap_int<16> photon_count_threshold = in_photon_count_threshold; - strong_pixel_threshold_t strong_pixel_threshold = in_strong_pixel_threshold; - strong_pixel_threshold_t strong_pixel_threshold_sq = strong_pixel_threshold * strong_pixel_threshold; + strong_pixel_threshold_t strong_pixel_threshold_sq = calculate_threshold(in_strong_pixel_threshold); for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++) { #pragma HLS PIPELINE II=1 data_out << packet_512_t{.data=packet_in.data, .user=0, .last=0}; @@ -350,7 +360,7 @@ void spot_finder(STREAM_512 &data_in, STREAM_512 &data_out, hls::stream> &strong_pixel_out, volatile ap_int<16> &in_photon_count_threshold, - volatile strong_pixel_threshold_t &in_strong_pixel_threshold) { + volatile ap_uint<16> &in_strong_pixel_threshold) { #pragma HLS INTERFACE ap_ctrl_none port=return #pragma HLS DATAFLOW diff --git a/fpga/hls/spot_finder.h b/fpga/hls/spot_finder.h index b9bfff4d..34b07499 100644 --- a/fpga/hls/spot_finder.h +++ b/fpga/hls/spot_finder.h @@ -137,7 +137,7 @@ void spot_finder_check_threshold(hls::stream &data_in, hls::stream> &valid_in, hls::stream> &strong_pixel_out, volatile ap_int<16> &in_photon_count_threshold, - volatile strong_pixel_threshold_t &in_strong_pixel_threshold); + volatile ap_uint<16> &in_strong_pixel_threshold); ap_uint<32> check_threshold(const ap_uint<512> data_packed, const ap_uint sum_packed, diff --git a/receiver/HLSSimulatedDevice.cpp b/receiver/HLSSimulatedDevice.cpp index 50339526..5e0981dc 100644 --- a/receiver/HLSSimulatedDevice.cpp +++ b/receiver/HLSSimulatedDevice.cpp @@ -349,7 +349,7 @@ void HLSSimulatedDevice::HLSMainThread() { ap_int<16> photon_count_threshold = 5; - strong_pixel_threshold_t strong_pixel_threshold = 7; + ap_uint<16> strong_pixel_threshold = 7; // 6. Spot finding hls_cores.emplace_back([&] { spot_finder(converted_5, converted_6,