41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include "hls_jfjoch.h"
|
|
|
|
void spot_finder(STREAM_512 &data_in,
|
|
hls::stream<ap_uint<512>> &result_out) {
|
|
#pragma HLS INTERFACE ap_ctrl_none port=return
|
|
#pragma HLS INTERFACE register both axis port=data_in
|
|
#pragma HLS INTERFACE register both axis port=result_out
|
|
|
|
packet_512_t packet;
|
|
data_in >> packet;
|
|
ap_int<16> threshold = ACT_REG_SPOT_FINDER_THRESHOLD(packet.data);
|
|
|
|
ap_uint<32> result[RAW_MODULE_SIZE * sizeof(uint16_t) / 64];
|
|
#pragma HLS ARRAY_PARTITION variable=result type=cyclic factor=16
|
|
|
|
ap_int<16> val[32];
|
|
data_in >> packet;
|
|
while (!packet.user) {
|
|
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++) {
|
|
#pragma HLS PIPELINE II=1
|
|
unpack32(packet.data, val);
|
|
|
|
ap_uint<32> output;
|
|
for (int j = 0; j < 32; j++)
|
|
output[j] = ((val[j] > threshold) ? 1 : 0);
|
|
|
|
data_in >> packet;
|
|
result[i] = output;
|
|
}
|
|
for (int i = 0; i < RAW_MODULE_SIZE * sizeof(uint16_t) / (64 * 16); i++) {
|
|
#pragma HLS PIPELINE II=1
|
|
ap_uint<512> output = 0;
|
|
for (int j = 0; j < 16; j++)
|
|
output(j*32+31, j * 32) = result[i * 16 + j];
|
|
result_out << output;
|
|
}
|
|
}
|
|
}
|