FPGA: Spot finder accepts 16-bit number for strong pixel threshold
This commit is contained in:
@@ -200,7 +200,7 @@ void spot_finder(STREAM_512 &data_in,
|
||||
STREAM_512 &data_out,
|
||||
hls::stream<ap_axiu<32,1,1,1>> &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,
|
||||
|
||||
@@ -308,6 +308,17 @@ void spot_finder_line_sum_align(hls::stream<spot_finder_packet> &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<spot_finder_packet> &data_in,
|
||||
STREAM_512 &data_out,
|
||||
hls::stream<ap_uint<SUM_BITWIDTH*32>> &sum_in,
|
||||
@@ -315,7 +326,7 @@ void spot_finder_check_threshold(hls::stream<spot_finder_packet> &data_in,
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>> &valid_in,
|
||||
hls::stream<ap_axiu<32,1,1,1>> &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<spot_finder_packet> &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<ap_axiu<32,1,1,1>> &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
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ void spot_finder_check_threshold(hls::stream<spot_finder_packet> &data_in,
|
||||
hls::stream<ap_uint<MASK_SUM_BITWIDTH*32>> &valid_in,
|
||||
hls::stream<ap_axiu<32,1,1,1>> &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_BITWIDTH*32> sum_packed,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user