FPGA: spot_finder early work in progress
This commit is contained in:
@@ -17,7 +17,8 @@ ADD_LIBRARY( HLSSimulation STATIC
|
||||
save_to_hbm.cpp
|
||||
load_from_hbm.cpp
|
||||
integration.cpp
|
||||
mask_missing.cpp)
|
||||
mask_missing.cpp
|
||||
spot_finder.cpp)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(HLSSimulation PUBLIC ../include)
|
||||
TARGET_LINK_LIBRARIES(HLSSimulation CommonFunctions)
|
||||
@@ -54,6 +55,7 @@ MAKE_HLS_MODULE(load_from_hbm.cpp load_from_hbm)
|
||||
MAKE_HLS_MODULE(save_to_hbm.cpp save_to_hbm)
|
||||
MAKE_HLS_MODULE(mask_missing.cpp mask_missing)
|
||||
MAKE_HLS_MODULE(integration.cpp integration)
|
||||
MAKE_HLS_MODULE(spot_finder.cpp spot_finder)
|
||||
|
||||
SET (HLS_IPS psi_ch_hls_data_collection_fsm_1_0.zip
|
||||
psi_ch_hls_timer_host_1_0.zip
|
||||
@@ -70,6 +72,7 @@ SET (HLS_IPS psi_ch_hls_data_collection_fsm_1_0.zip
|
||||
psi_ch_hls_save_to_hbm_1_0.zip
|
||||
psi_ch_hls_mask_missing_1_0.zip
|
||||
psi_ch_hls_frame_generator_1_0.zip
|
||||
psi_ch_hls_spot_finder_1_0.zip
|
||||
psi_ch_hls_integration_1_0.zip
|
||||
psi_ch_hls_stream_merge_1_0.zip)
|
||||
|
||||
|
||||
@@ -185,6 +185,10 @@ void integration(STREAM_512 &data_in,
|
||||
ap_uint<256> *d_hbm_p0,
|
||||
ap_uint<256> *d_hbm_p1);
|
||||
|
||||
void spot_finder(STREAM_512 &data_in,
|
||||
STREAM_512 &data_out,
|
||||
hls::stream<ap_uint<512>> &result_out);
|
||||
|
||||
template<int N> ap_uint<N*32> pack32(ap_int<N> in[32]) {
|
||||
#pragma HLS INLINE
|
||||
ap_uint<N*32> out;
|
||||
|
||||
46
fpga/hls/spot_finder.cpp
Normal file
46
fpga/hls/spot_finder.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
// Copyright (2019-2023) Paul Scherrer Institute
|
||||
|
||||
#include "hls_jfjoch.h"
|
||||
|
||||
void spot_finder(STREAM_512 &data_in,
|
||||
STREAM_512 &data_out,
|
||||
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=data_out
|
||||
#pragma HLS INTERFACE register both axis port=result_out
|
||||
|
||||
packet_512_t packet;
|
||||
data_in >> packet;
|
||||
data_out << packet;
|
||||
|
||||
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
|
||||
ap_uint<32> output = 0;
|
||||
data_out << packet;
|
||||
unpack32(packet.data, val);
|
||||
for (int j = 0; j < 32; j++) {
|
||||
if (val[j] > 5)
|
||||
output[j] = 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
data_out << packet;
|
||||
}
|
||||
Reference in New Issue
Block a user