* Enhancements for EIGER * Writer is more flexible and capable of handling DECTRIS data
36 lines
1.4 KiB
C++
36 lines
1.4 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include "hls_jfjoch.h"
|
|
|
|
void stream_merge(AXI_STREAM &input_network,
|
|
AXI_STREAM &input_frame_generator,
|
|
AXI_STREAM &data_out,
|
|
volatile ap_uint<2> &source) {
|
|
#pragma HLS INTERFACE ap_ctrl_none port=return
|
|
#pragma HLS INTERFACE axis register both port=input_network
|
|
#pragma HLS INTERFACE axis register both port=input_frame_generator
|
|
#pragma HLS INTERFACE axis register both port=data_out
|
|
#pragma HLS INTERFACE ap_none register port=source
|
|
#pragma HLS PIPELINE II=1 style=flp
|
|
|
|
static ap_uint<2> data_source_local = STREAM_MERGE_SRC_NONE;
|
|
ap_uint<2> data_source_local_read = source;
|
|
if (data_source_local != data_source_local_read) {
|
|
data_source_local = data_source_local_read;
|
|
data_out.write(packet_512_t{.user = 1, .last = 1});
|
|
} else {
|
|
packet_512_t packet_in_frame_gen, packet_in_network;
|
|
|
|
bool rcv_frame_gen = input_frame_generator.read_nb(packet_in_frame_gen);
|
|
bool rcv_network = input_network.read_nb(packet_in_network);
|
|
|
|
if (data_source_local == STREAM_MERGE_SRC_NETWORK) {
|
|
if (rcv_network)
|
|
data_out.write(packet_in_network);
|
|
} else if (data_source_local == STREAM_MERGE_SRC_FRAME_GEN) {
|
|
if (rcv_frame_gen)
|
|
data_out.write(packet_in_frame_gen);
|
|
}
|
|
}
|
|
}
|