HLS: Spot finder outputs parameters + statistics
This commit is contained in:
@@ -130,6 +130,7 @@ void host_writer(STREAM_512 &data_in,
|
||||
read_request(s_axis_work_request, req_handle, req_host_offset);
|
||||
setup_datamover(datamover_out_cmd, req_host_offset,
|
||||
RAW_MODULE_SIZE * sizeof(uint16_t) * (16 + 1) / 16
|
||||
+ 64
|
||||
+ (FPGA_INTEGRATION_BIN_COUNT/2)*64
|
||||
+ ADU_HISTO_BIN_COUNT / 16 * 64);
|
||||
|
||||
@@ -148,7 +149,7 @@ void host_writer(STREAM_512 &data_in,
|
||||
host_memory_out << packet_out;
|
||||
}
|
||||
|
||||
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / (64 * 16); i++) {
|
||||
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / (64 * 16) + 1; i++) {
|
||||
#pragma HLS PIPELINE II=1
|
||||
spot_finder_in >> packet_out.data;
|
||||
host_memory_out << packet_out;
|
||||
|
||||
+29
-11
@@ -308,15 +308,23 @@ 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) {
|
||||
strong_pixel_threshold_t calculate_threshold(ap_uint<16> &in_snr_threshold) {
|
||||
#pragma HLS INLINE
|
||||
ap_uint<16> tmp = in_strong_pixel_threshold;
|
||||
strong_pixel_threshold_t strong_pixel_threshold = 0;
|
||||
ap_uint<16> tmp = in_snr_threshold;
|
||||
strong_pixel_threshold_t snr_threshold = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
#pragma HLS UNROLL
|
||||
strong_pixel_threshold[i] = tmp[i];
|
||||
snr_threshold[i] = tmp[i];
|
||||
}
|
||||
return strong_pixel_threshold * strong_pixel_threshold;
|
||||
return snr_threshold * snr_threshold;
|
||||
}
|
||||
|
||||
ap_uint<32> count_pixels(ap_uint<32> &in) {
|
||||
#pragma HLS INLINE
|
||||
ap_uint<32> ret = 0;
|
||||
for (int i = 0; i < 32; i++)
|
||||
ret += in[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
void spot_finder_check_threshold(hls::stream<spot_finder_packet> &data_in,
|
||||
@@ -325,8 +333,8 @@ void spot_finder_check_threshold(hls::stream<spot_finder_packet> &data_in,
|
||||
hls::stream<ap_uint<SUM2_BITWIDTH*32>> &sum2_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 ap_uint<16> &in_strong_pixel_threshold) {
|
||||
volatile ap_int<16> &in_count_threshold,
|
||||
volatile ap_uint<16> &in_snr_threshold) {
|
||||
spot_finder_packet packet_in;
|
||||
data_in >> packet_in;
|
||||
data_out << packet_512_t{.data=packet_in.data, .user=0, .last=0};
|
||||
@@ -336,8 +344,11 @@ 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_sq = calculate_threshold(in_strong_pixel_threshold);
|
||||
ap_int<16> count_threshold = in_count_threshold;
|
||||
ap_uint<16> snr_threshold = in_snr_threshold;
|
||||
strong_pixel_threshold_t snr_threshold_sq = calculate_threshold(snr_threshold);
|
||||
uint32_t strong_pixel_count = 0;
|
||||
|
||||
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};
|
||||
@@ -346,11 +357,18 @@ void spot_finder_check_threshold(hls::stream<spot_finder_packet> &data_in,
|
||||
valid_in >> line_valid;
|
||||
ap_axiu<32, 1, 1, 1> strong_pixel{.user = 0};
|
||||
|
||||
strong_pixel.data = check_threshold(packet_in.data, line_sum, line_sum2, line_valid,
|
||||
strong_pixel_threshold_sq, photon_count_threshold);
|
||||
strong_pixel.data = check_threshold(packet_in.data, line_sum, line_sum2, line_valid, snr_threshold_sq, count_threshold);
|
||||
strong_pixel_count += count_pixels(strong_pixel.data);
|
||||
strong_pixel_out << strong_pixel;
|
||||
data_in >> packet_in;
|
||||
}
|
||||
|
||||
// Save parameters used for spot finding + count of
|
||||
strong_pixel_out << ap_axiu<32, 1, 1, 1>{.data = count_threshold, .user = 0};
|
||||
strong_pixel_out << ap_axiu<32, 1, 1, 1>{.data = snr_threshold, .user = 0};
|
||||
strong_pixel_out << ap_axiu<32, 1, 1, 1>{.data = strong_pixel_count, .user = 0};
|
||||
for (int i = 0; i < 13; i++)
|
||||
strong_pixel_out << ap_axiu<32, 1, 1, 1>{.data = 0, .user = 0};
|
||||
}
|
||||
strong_pixel_out << ap_axiu<32,1,1,1>{.data = 0, .user = 1};
|
||||
data_out << packet_512_t{.data=0, .user=1, .last=1};
|
||||
|
||||
@@ -39,12 +39,11 @@ int main() {
|
||||
for (int i = 0; i < 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2; i++)
|
||||
output.read();
|
||||
|
||||
if (strong_pixel.size() != 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 1)
|
||||
if (strong_pixel.size() != 4 * (RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 1) + 1)
|
||||
ret = 1;
|
||||
for (int i = 0; i < 4 * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 1; i++)
|
||||
for (int i = 0; i < 4 * (RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 1) + 1; i++)
|
||||
strong_pixel.read();
|
||||
|
||||
|
||||
if (ret != 0) {
|
||||
printf("Test failed !!!\n");
|
||||
ret = 1;
|
||||
|
||||
@@ -163,12 +163,12 @@ const int16_t *AcquisitionDevice::GetFrameBuffer(size_t frame_number, uint16_t m
|
||||
|
||||
const IntegrationResult *AcquisitionDevice::GetIntegrationResult(size_t frame_number, uint16_t module_number) const {
|
||||
return reinterpret_cast<const IntegrationResult *>(GetFrameBuffer(frame_number, module_number)
|
||||
+ 17 * RAW_MODULE_SIZE / 16);
|
||||
+ 17 * RAW_MODULE_SIZE / 16 + 32);
|
||||
}
|
||||
|
||||
const uint32_t *AcquisitionDevice::GetADUHistogram(size_t frame_number, uint16_t module_number) const {
|
||||
return reinterpret_cast<const uint32_t *>(GetFrameBuffer(frame_number, module_number)
|
||||
+ 17 * RAW_MODULE_SIZE / 16
|
||||
+ 17 * RAW_MODULE_SIZE / 16 + 32
|
||||
+ FPGA_INTEGRATION_BIN_COUNT * sizeof(IntegrationResult) / sizeof(uint16_t));
|
||||
}
|
||||
|
||||
|
||||
@@ -418,5 +418,5 @@ TEST_CASE("FPGA_spot_finder_core","[FPGA][SpotFinder]") {
|
||||
|
||||
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 + 1);
|
||||
REQUIRE(strong_pixel.size() == RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 16 + 1);
|
||||
}
|
||||
Reference in New Issue
Block a user