From 7d5694139f22936982e4de4b52840b058602dda6 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 17 May 2023 21:30:42 +0200 Subject: [PATCH] FPGA: Save full JF timestamp and exptime --- common/Definitions.h | 2 +- frame_serialize/ImageMessage.h | 1 + frame_serialize/JFJochFrameDeserializer.cpp | 2 ++ frame_serialize/JFJochFrameSerializer.cpp | 3 +- receiver/JFJochReceiver.cpp | 1 + receiver/hls/hls_jfjoch.h | 7 +++-- receiver/hls/host_writer.cpp | 33 ++++++++++++++------- receiver/hls/internal_packet_generator.cpp | 4 ++- receiver/hls/sls_detector.cpp | 4 +-- receiver/host/AcquisitionDevice.cpp | 6 +++- receiver/host/AcquisitionDevice.h | 3 +- receiver/host/AcquisitionOnlineCounters.cpp | 14 +++++++++ receiver/host/AcquisitionOnlineCounters.h | 2 ++ receiver/host/Completion.cpp | 12 ++++---- receiver/host/Completion.h | 5 ++-- receiver/host/FPGAAcquisitionDevice.h | 2 +- receiver/host/HLSSimulatedDevice.cpp | 6 ++-- receiver/host/HLSSimulatedDevice.h | 5 ++-- receiver/host/PCIExpressDevice.h | 2 +- receiver/pcie_driver/jfjoch_function.c | 2 +- receiver/pcie_driver/jfjoch_ioctl.c | 4 +-- tests/CBORTest.cpp | 2 ++ tests/FPGAIntegrationTest.cpp | 4 +++ writer/HDF5DataFile.cpp | 5 ++++ writer/HDF5DataFile.h | 1 + 25 files changed, 96 insertions(+), 36 deletions(-) diff --git a/common/Definitions.h b/common/Definitions.h index ce764a01..f6721194 100644 --- a/common/Definitions.h +++ b/common/Definitions.h @@ -51,7 +51,7 @@ // For FPGA /* This number is unique and is declared in ~snap/ActionTypes.md */ #define ACTION_TYPE 0x52324158 -#define RELEASE_LEVEL 0x0034 +#define RELEASE_LEVEL 0x0035 #define MODE_CONV 0x0001L #define MODE_INTERNAL_PACKET_GEN 0x0002L diff --git a/frame_serialize/ImageMessage.h b/frame_serialize/ImageMessage.h index 52ba1e4a..b2a0fbde 100644 --- a/frame_serialize/ImageMessage.h +++ b/frame_serialize/ImageMessage.h @@ -32,6 +32,7 @@ struct DataMessage { uint32_t jf_info; uint64_t timestamp; uint32_t storage_cell; + uint32_t exptime; std::string series_unique_id; uint64_t series_id; diff --git a/frame_serialize/JFJochFrameDeserializer.cpp b/frame_serialize/JFJochFrameDeserializer.cpp index ec9c43a0..48ac1968 100644 --- a/frame_serialize/JFJochFrameDeserializer.cpp +++ b/frame_serialize/JFJochFrameDeserializer.cpp @@ -350,6 +350,8 @@ void JFJochFrameDeserializer::ProcessImageMessageUserDataElement(CborValue &valu data_message.jf_info = GetCBORUInt(map_value) & UINT32_MAX; else if (key == "storage_cell") data_message.storage_cell = GetCBORUInt(map_value) & UINT32_MAX; + else if (key == "exptime") + data_message.exptime = GetCBORUInt(map_value) & UINT32_MAX; else if (key == "bunch_id") data_message.bunch_id = GetCBORUInt(map_value); else if (key == "timestamp") diff --git a/frame_serialize/JFJochFrameSerializer.cpp b/frame_serialize/JFJochFrameSerializer.cpp index 490d2806..3b3c89c9 100644 --- a/frame_serialize/JFJochFrameSerializer.cpp +++ b/frame_serialize/JFJochFrameSerializer.cpp @@ -412,7 +412,7 @@ void JFJochFrameSerializer::SerializeImage(const DataMessage& message) { CBOR_ENC(mapEncoder, "image_id", message.number); cborErr(cbor_encode_text_stringz(&mapEncoder, "user_data")); - cborErr(cbor_encoder_create_map(&mapEncoder, &userDataMapEncoder, 7)); + cborErr(cbor_encoder_create_map(&mapEncoder, &userDataMapEncoder, 8)); CBOR_ENC(userDataMapEncoder, "spots", message.spots); CBOR_ENC(userDataMapEncoder, "rad_int_profile", message.rad_int_profile); @@ -421,6 +421,7 @@ void JFJochFrameSerializer::SerializeImage(const DataMessage& message) { CBOR_ENC(userDataMapEncoder, "jf_info", (uint64_t) message.jf_info); CBOR_ENC(userDataMapEncoder, "timestamp", message.timestamp); CBOR_ENC(userDataMapEncoder, "storage_cell", (uint64_t) message.storage_cell); + CBOR_ENC(userDataMapEncoder, "exptime", (uint64_t) message.exptime); cborErr(cbor_encoder_close_container(&mapEncoder, &userDataMapEncoder)); CBOR_ENC(mapEncoder, "data", message.image); diff --git a/receiver/JFJochReceiver.cpp b/receiver/JFJochReceiver.cpp index 291d9fde..078fbb9d 100644 --- a/receiver/JFJochReceiver.cpp +++ b/receiver/JFJochReceiver.cpp @@ -287,6 +287,7 @@ int64_t JFJochReceiver::MiniSummationThread(int d, int m, size_t image_number, b message.jf_info = acquisition_device[d]->GetJFInfo(frame_number, m); message.storage_cell = (message.jf_info >> 8) & 0xF; message.timestamp = acquisition_device[d]->GetTimestamp(frame_number, m); + message.exptime = acquisition_device[d]->GetExptime(frame_number, m); } send_image = true; } else diff --git a/receiver/hls/hls_jfjoch.h b/receiver/hls/hls_jfjoch.h index 149d5b9b..7ac8519f 100644 --- a/receiver/hls/hls_jfjoch.h +++ b/receiver/hls/hls_jfjoch.h @@ -22,7 +22,7 @@ // Number of modules that can be simultaneously handled by the FPGA #define MAX_MODULES_FPGA 16 -#define ADDR_STREAM_WIDTH 256 +#define ADDR_STREAM_WIDTH 320 typedef ap_ufixed<16,2, AP_RND_CONV> gainG0_t; typedef ap_ufixed<16,4, AP_RND_CONV> gainG1_t; @@ -57,6 +57,7 @@ typedef hls::stream STREAM_512; #define addr_jf_debug(x) x(127, 96) #define addr_timestamp(x) x(191,128) #define addr_bunch_id(x) x(255,192) +#define addr_exptime(x) x(256+63, 256) #define ACT_REG_MODE(x) ((x)(63, 0)) // 64 bit #define ACT_REG_ONE_OVER_ENERGY(x) ((x)(95, 64)) // 32 bit @@ -148,7 +149,8 @@ inline ap_uint addr_packet(ap_uint<8> eth_packet, ap_uint<64> frame, ap_uint<32> jf_debug, ap_uint<64> timestamp, - ap_uint<64> bunchid) { + ap_uint<64> bunchid, + ap_uint<32> expttime) { #pragma HLS INLINE ap_uint retval = 0; addr_eth_packet(retval) = eth_packet; @@ -157,6 +159,7 @@ inline ap_uint addr_packet(ap_uint<8> eth_packet, addr_jf_debug(retval) = jf_debug; addr_timestamp(retval) = timestamp; addr_bunch_id(retval) = bunchid; + addr_exptime(retval) = expttime; return retval; } diff --git a/receiver/hls/host_writer.cpp b/receiver/hls/host_writer.cpp index 2d30588e..13898579 100644 --- a/receiver/hls/host_writer.cpp +++ b/receiver/hls/host_writer.cpp @@ -17,7 +17,8 @@ inline void write_completion(hls::stream > &m_axis_completion, const ap_uint<16> &packet_count, const ap_uint<32> &debug, const ap_uint<64> ×tamp, - const ap_uint<64> &bunchid) { + const ap_uint<64> &bunchid, + const ap_uint<32> &exptime) { #pragma HLS INLINE ap_uint<1> all_packets_ok = packet_mask.and_reduce(); ap_uint<1> any_packets_received = packet_mask.or_reduce(); @@ -33,11 +34,16 @@ inline void write_completion(hls::stream > &m_axis_completion, m_axis_completion << frame_num(63, 32); m_axis_completion << frame_num(31, 0); - m_axis_completion << debug; + m_axis_completion << timestamp(63,32); m_axis_completion << timestamp(31,0); m_axis_completion << bunchid(63,32); m_axis_completion << bunchid(31,0); + m_axis_completion << exptime; + m_axis_completion << debug; + m_axis_completion << 0; + m_axis_completion << 0; + m_axis_completion << packet_mask(127,96); m_axis_completion << packet_mask( 95,64); m_axis_completion << packet_mask( 63,32); @@ -106,6 +112,8 @@ void host_writer(STREAM_512 &data_in, #pragma HLS RESOURCE variable=debug core=RAM_1P ap_uint<64> timestamp[MAX_MODULES_FPGA*2]; #pragma HLS RESOURCE variable=timestamp core=RAM_1P + ap_uint<32> exptime[MAX_MODULES_FPGA*2]; +#pragma HLS RESOURCE variable=exptime core=RAM_1P ap_uint<64> jf_bunchid[MAX_MODULES_FPGA*2]; #pragma HLS RESOURCE variable=jf_bunchid core=RAM_1P ap_uint<64> curr_offset[MAX_MODULES_FPGA*2]; @@ -118,12 +126,13 @@ void host_writer(STREAM_512 &data_in, packet_mask[i] = 0; packet_count[i] = 0; curr_offset[i] = 0; - debug[i] = 0; - timestamp[i] = 0; + debug[i] = 0; + timestamp[i] = 0; + exptime[i] = 0; jf_bunchid[i] = 0; } - write_completion(m_axis_completion, UINT32_MAX - 1, 0, 0, 0, 0, 0, 0, 0); + write_completion(m_axis_completion, UINT32_MAX - 1, 0, 0, 0, 0, 0, 0, 0, 0); uint64_t total_counter = 0; packets_processed = 0; @@ -165,12 +174,14 @@ void host_writer(STREAM_512 &data_in, ap_uint<256> comp_packet_mask = packet_mask[id]; ap_uint<16> comp_packet_count = packet_count[id]; ap_uint<32> comp_debug = debug[id]; - ap_uint<32> comp_timestamp = timestamp[id]; - ap_uint<32> comp_bunchid = jf_bunchid[id]; + ap_uint<64> comp_timestamp = timestamp[id]; + ap_uint<64> comp_bunchid = jf_bunchid[id]; + ap_uint<32> comp_exptime = exptime[id]; write_completion(m_axis_completion, comp_handle, module, comp_frame, comp_packet_mask, comp_packet_count, - comp_debug, comp_timestamp, comp_bunchid); + comp_debug, comp_timestamp, comp_bunchid, + comp_exptime); } if (read_request(s_axis_work_request, req_handle, req_host_offset)) @@ -186,6 +197,7 @@ void host_writer(STREAM_512 &data_in, debug[id] = addr_jf_debug(addr); timestamp[id] = addr_timestamp(addr); jf_bunchid[id] = addr_bunch_id(addr); + exptime[id] = addr_exptime(addr); packet_mask[id] = ap_uint<128>(1) << eth_packet; packet_count[id] = 1; @@ -215,12 +227,13 @@ void host_writer(STREAM_512 &data_in, if (packet_mask[m] > 0) write_completion(m_axis_completion, handle[m], m / 2, curr_frame[m], packet_mask[m], packet_count[m], - debug[m], timestamp[m], jf_bunchid[m]); + debug[m], timestamp[m], jf_bunchid[m], + exptime[m]); } data_in >> packet_in; - write_completion(m_axis_completion, UINT32_MAX, 0, total_counter, 0, 0, 0, 0, 0); + write_completion(m_axis_completion, UINT32_MAX, 0, total_counter, 0, 0, 0, 0, 0, 0); read_request(s_axis_work_request, req_handle, req_host_offset); diff --git a/receiver/hls/internal_packet_generator.cpp b/receiver/hls/internal_packet_generator.cpp index 55f182b0..4f462af7 100644 --- a/receiver/hls/internal_packet_generator.cpp +++ b/receiver/hls/internal_packet_generator.cpp @@ -57,6 +57,7 @@ void internal_packet_generator(STREAM_512 &data_in, STREAM_512 &data_out, if (internal_packet_generator) { generate_frames: for (uint32_t frame_number = 1; frame_number <= nframes; frame_number++ ) { + for (uint8_t module = 0; module < modules; module++) { ap_uint<1> cancel = in_cancel; if (cancel) @@ -67,7 +68,8 @@ void internal_packet_generator(STREAM_512 &data_in, STREAM_512 &data_out, uint32_t eth_packet = i / 128; uint32_t axis_packet = i % 128; if (axis_packet == 0) - addr_out << addr_packet(eth_packet, module, frame_number, 0, 0xABCDEF, 0); + addr_out << addr_packet(eth_packet, module, frame_number, 0, + 0xABCDEFABCDEF, 0xCACACACACA, 10000); packet_out.user = 0; packet_out.id = 0; packet_out.last = (axis_packet == 127) ? 1 : 0; diff --git a/receiver/hls/sls_detector.cpp b/receiver/hls/sls_detector.cpp index 1364adde..74783036 100644 --- a/receiver/hls/sls_detector.cpp +++ b/receiver/hls/sls_detector.cpp @@ -73,11 +73,11 @@ void sls_detector(AXI_STREAM &udp_payload_in, ap_uint<5> module = (column % 32) / 2; ap_uint<1> module_part = column[0]; ap_uint<7> eth_packet = (packet_in.data(127, 96) % 128) | (module_part * 64); - + ap_uint<32> exptime = packet_in.data(95, 64); beat_counter = 0; reminder = packet_in.data(511, 384); - addr_out << addr_packet(eth_packet, module, frame_number, jf_debug, timestamp, bunchid); + addr_out << addr_packet(eth_packet, module, frame_number, jf_debug, timestamp, bunchid,exptime); state = FORWARD; internal_counter++; } else { diff --git a/receiver/host/AcquisitionDevice.cpp b/receiver/host/AcquisitionDevice.cpp index 6768bc14..1426dd57 100644 --- a/receiver/host/AcquisitionDevice.cpp +++ b/receiver/host/AcquisitionDevice.cpp @@ -428,6 +428,10 @@ uint32_t AcquisitionDevice::GetJFInfo(size_t curr_frame, uint16_t module_number) return counters.GetJFInfo(curr_frame, module_number); } -uint32_t AcquisitionDevice::GetTimestamp(size_t curr_frame, uint16_t module_number) const { +uint32_t AcquisitionDevice::GetExptime(size_t curr_frame, uint16_t module_number) const { + return counters.GetExptime(curr_frame, module_number); +} + +uint64_t AcquisitionDevice::GetTimestamp(size_t curr_frame, uint16_t module_number) const { return counters.GetTimestamp(curr_frame, module_number); } \ No newline at end of file diff --git a/receiver/host/AcquisitionDevice.h b/receiver/host/AcquisitionDevice.h index 98ae5a93..e75ccb89 100644 --- a/receiver/host/AcquisitionDevice.h +++ b/receiver/host/AcquisitionDevice.h @@ -111,7 +111,8 @@ public: uint64_t GetBufferHandle(size_t frame, uint8_t module_number) const; uint64_t GetBunchID(size_t curr_frame, uint16_t module_number) const; uint32_t GetJFInfo(size_t curr_frame, uint16_t module_number) const; - uint32_t GetTimestamp(size_t curr_frame, uint16_t module_number) const; + uint64_t GetTimestamp(size_t curr_frame, uint16_t module_number) const; + uint32_t GetExptime(size_t curr_frame, uint16_t module_number) const; bool IsFullModuleCollected(size_t frame, uint8_t module_number) const; ActionConfig ReadActionRegister(); diff --git a/receiver/host/AcquisitionOnlineCounters.cpp b/receiver/host/AcquisitionOnlineCounters.cpp index 80864e3c..b1d682d2 100644 --- a/receiver/host/AcquisitionOnlineCounters.cpp +++ b/receiver/host/AcquisitionOnlineCounters.cpp @@ -33,6 +33,7 @@ void AcquisitionOnlineCounters::Reset(const DiffractionExperiment &experiment, u bunch_id = std::vector(expected_frames * nmodules); jf_info = std::vector(expected_frames * nmodules); timestamp = std::vector(expected_frames * nmodules); + exptime = std::vector(expected_frames * nmodules); } void AcquisitionOnlineCounters::UpdateCounters(const Completion *c) { @@ -60,6 +61,7 @@ void AcquisitionOnlineCounters::UpdateCounters(const Completion *c) { bunch_id.at(c->frame_number * nmodules + c->module) = c->bunchid; jf_info.at(c->frame_number * nmodules + c->module) = c->debug; timestamp.at(c->frame_number * nmodules + c->module) = c->timestamp; + exptime.at(c->frame_number * nmodules + c->module) = c->exptime; } data_updated.notify_all(); @@ -156,6 +158,18 @@ uint64_t AcquisitionOnlineCounters::GetBunchID(size_t frame, uint16_t module_num return bunch_id[frame * nmodules + module_number]; } +uint32_t AcquisitionOnlineCounters::GetExptime(size_t frame, uint16_t module_number) const { + if (frame >= expected_frames) + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetExptime Wrong frame number: " + std::to_string(frame)); + + if (module_number >= nmodules) + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetExptime Wrong module number: " + std::to_string(module_number) + + " for frame " + std::to_string(frame)); + + return exptime[frame * nmodules + module_number]; +} uint32_t AcquisitionOnlineCounters::GetJFInfo(size_t frame, uint16_t module_number) const { if (frame >= expected_frames) throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, diff --git a/receiver/host/AcquisitionOnlineCounters.h b/receiver/host/AcquisitionOnlineCounters.h index c47ca713..fd8ac11c 100644 --- a/receiver/host/AcquisitionOnlineCounters.h +++ b/receiver/host/AcquisitionOnlineCounters.h @@ -28,6 +28,7 @@ class AcquisitionOnlineCounters { std::vector bunch_id; std::vector jf_info; std::vector timestamp; + std::vector exptime; uint64_t slowest_head; std::vector head; @@ -55,6 +56,7 @@ public: uint64_t GetBunchID(size_t curr_frame, uint16_t module_number) const; uint32_t GetJFInfo(size_t curr_frame, uint16_t module_number) const; uint64_t GetTimestamp(size_t curr_frame, uint16_t module_number) const; + uint32_t GetExptime(size_t curr_frame, uint16_t module_number) const; }; diff --git a/receiver/host/Completion.cpp b/receiver/host/Completion.cpp index 01cf5e50..f64a0056 100644 --- a/receiver/host/Completion.cpp +++ b/receiver/host/Completion.cpp @@ -10,7 +10,7 @@ inline uint64_t bit_concat(uint32_t high, uint32_t low) { return (uint64_t(high) << 32) | low; } -Completion parse_hw_completion(uint32_t tmp[12]) { +Completion parse_hw_completion(uint32_t tmp[16]) { Completion c{}; c.handle = tmp[0]; @@ -37,12 +37,14 @@ Completion parse_hw_completion(uint32_t tmp[12]) { throw JFJochException(JFJochExceptionCategory::HardwareParityError, "Detector frame number cannot be zero"); else c.frame_number = detector_frame_number - 1; - c.debug = tmp[4]; - c.timestamp = tmp[5]; + c.timestamp = bit_concat(tmp[4], tmp[5]); c.bunchid = bit_concat(tmp[6], tmp[7]); - c.packet_mask[0] = bit_concat(tmp[10], tmp[11]); - c.packet_mask[1] = bit_concat(tmp[8], tmp[9]); + c.exptime = tmp[8]; + c.debug = tmp[9]; + + c.packet_mask[0] = bit_concat(tmp[14], tmp[15]); + c.packet_mask[1] = bit_concat(tmp[12], tmp[13]); } return c; diff --git a/receiver/host/Completion.h b/receiver/host/Completion.h index 168fcad4..af450947 100644 --- a/receiver/host/Completion.h +++ b/receiver/host/Completion.h @@ -17,13 +17,14 @@ struct Completion { uint64_t frame_number; uint64_t packet_mask[2]; uint64_t bunchid; + uint64_t timestamp; + uint32_t exptime; uint32_t debug; uint32_t handle; - uint32_t timestamp; uint16_t packet_count; uint8_t module; }; -Completion parse_hw_completion(uint32_t[12]); +Completion parse_hw_completion(uint32_t hw_input[16]); #endif //JUNGFRAUJOCH_COMPLETION_H diff --git a/receiver/host/FPGAAcquisitionDevice.h b/receiver/host/FPGAAcquisitionDevice.h index e754ed2b..4df98d2c 100644 --- a/receiver/host/FPGAAcquisitionDevice.h +++ b/receiver/host/FPGAAcquisitionDevice.h @@ -20,7 +20,7 @@ class FPGAAcquisitionDevice : public AcquisitionDevice { volatile bool stop_work_requests = false; void SendWorkRequestThread(); - virtual bool HW_ReadMailbox(uint32_t values[12]) = 0; + virtual bool HW_ReadMailbox(uint32_t values[16]) = 0; virtual bool HW_SendWorkRequest(uint32_t handle) = 0; protected: explicit FPGAAcquisitionDevice(uint16_t data_stream) : AcquisitionDevice(data_stream) {} diff --git a/receiver/host/HLSSimulatedDevice.cpp b/receiver/host/HLSSimulatedDevice.cpp index 68b39d29..fe7a50c0 100644 --- a/receiver/host/HLSSimulatedDevice.cpp +++ b/receiver/host/HLSSimulatedDevice.cpp @@ -155,11 +155,11 @@ HLSSimulatedDevice::~HLSSimulatedDevice() { action_thread.join(); } -bool HLSSimulatedDevice::HW_ReadMailbox(uint32_t values[12]) { - if (completion_stream.size() < 12) +bool HLSSimulatedDevice::HW_ReadMailbox(uint32_t values[16]) { + if (completion_stream.size() < 16) return false; - for (int i = 0; i < 12; i++) + for (int i = 0; i < 16; i++) values[i] = completion_stream.read(); return true; diff --git a/receiver/host/HLSSimulatedDevice.h b/receiver/host/HLSSimulatedDevice.h index 3bbe69b6..fd1fcf38 100644 --- a/receiver/host/HLSSimulatedDevice.h +++ b/receiver/host/HLSSimulatedDevice.h @@ -42,7 +42,7 @@ class HLSSimulatedDevice : public FPGAAcquisitionDevice { void FPGA_StartAction() override; void FPGA_EndAction() override; bool HW_IsIdle() const override; - bool HW_ReadMailbox(uint32_t values[12]); + bool HW_ReadMailbox(uint32_t values[16]); void HW_SetCancelDataCollectionBit() override; bool HW_SendWorkRequest(uint32_t handle) override; uint64_t HW_GetMACAddress() const override; @@ -54,7 +54,8 @@ public: ~HLSSimulatedDevice(); void SendPacket(char *buffer, int len, uint8_t user = 0); void CreatePacketJF(const DiffractionExperiment& experiment, uint64_t frame_number, uint32_t eth_packet, - uint32_t module_number, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, uint8_t user = 0); + uint32_t module_number, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, + uint8_t user = 0); void CreatePackets(const DiffractionExperiment& experiment, uint64_t frame_number_0, uint64_t frames, uint32_t module_number, const uint16_t *data, bool trigger, int8_t adjust_axis = 0, uint8_t user = 0); diff --git a/receiver/host/PCIExpressDevice.h b/receiver/host/PCIExpressDevice.h index 5a07de7e..993ba7c0 100644 --- a/receiver/host/PCIExpressDevice.h +++ b/receiver/host/PCIExpressDevice.h @@ -9,7 +9,7 @@ class PCIExpressDevice : public FPGAAcquisitionDevice { int fd; - bool HW_ReadMailbox(uint32_t values[12]); + bool HW_ReadMailbox(uint32_t values[16]); void HW_SetCancelDataCollectionBit() override; bool HW_SendWorkRequest(uint32_t handle) override; void FPGA_StartAction() override; diff --git a/receiver/pcie_driver/jfjoch_function.c b/receiver/pcie_driver/jfjoch_function.c index 04237fed..e546eeb0 100644 --- a/receiver/pcie_driver/jfjoch_function.c +++ b/receiver/pcie_driver/jfjoch_function.c @@ -99,7 +99,7 @@ int jfjoch_read_wc(struct jfjoch_drvdata *drvdata, u32 *output) { return -EAGAIN; } - for (i = 0; i < 12; i++) + for (i = 0; i < 16; i++) output[i] = ioread32(drvdata->bar0 + MAILBOX_OFFSET + ADDR_MAILBOX_RDDATA); mutex_unlock(&read_wc_mutex); diff --git a/receiver/pcie_driver/jfjoch_ioctl.c b/receiver/pcie_driver/jfjoch_ioctl.c index 334fbf75..ac899287 100644 --- a/receiver/pcie_driver/jfjoch_ioctl.c +++ b/receiver/pcie_driver/jfjoch_ioctl.c @@ -9,7 +9,7 @@ long jfjoch_cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct ActionStatus status; struct ActionConfig config; struct ActionEnvParams env_params; - u32 exchange[12]; + u32 exchange[16]; int err; switch (cmd) { @@ -50,7 +50,7 @@ long jfjoch_cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { err = jfjoch_read_wc(drvdata,exchange); if (err) return err; - if (copy_to_user((char *) arg, exchange, 12 * sizeof(u32)) != 0) + if (copy_to_user((char *) arg, exchange, 16 * sizeof(u32)) != 0) return -EFAULT; return 0; case IOCTL_JFJOCH_BUF_COUNT: diff --git a/tests/CBORTest.cpp b/tests/CBORTest.cpp index d3bac67e..e4017671 100644 --- a/tests/CBORTest.cpp +++ b/tests/CBORTest.cpp @@ -219,6 +219,7 @@ JFJochFrameSerializer serializer(buffer.data(), buffer.size()); .jf_info = UINT32_MAX, .timestamp = 1ul<<27 | 1ul <<35, .storage_cell = 0xF, + .exptime = 1000, .series_unique_id = "bla2", .series_id = 4567678 }; @@ -247,6 +248,7 @@ JFJochFrameSerializer serializer(buffer.data(), buffer.size()); REQUIRE(image_array.jf_info == message.jf_info); REQUIRE(image_array.timestamp == message.timestamp); REQUIRE(image_array.storage_cell == message.storage_cell); + REQUIRE(image_array.exptime == message.exptime); } TEST_CASE("CBORSerialize_Image_2", "[CBOR]") { diff --git a/tests/FPGAIntegrationTest.cpp b/tests/FPGAIntegrationTest.cpp index a8801803..1647bc37 100644 --- a/tests/FPGAIntegrationTest.cpp +++ b/tests/FPGAIntegrationTest.cpp @@ -67,6 +67,10 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_custom_frame", "[FPGA][Ful for (int image = 0; image < 4; image++) { for (int m = 0; m < nmodules; m++) { + REQUIRE(test.GetTimestamp(image, m) == 0xABCDEFABCDEF); + REQUIRE(test.GetBunchID(image,m) == 0xCACACACACA); + REQUIRE(test.GetExptime(image, m) == 10000); + auto imageBuf = (uint16_t *) test.GetFrameBuffer(image, m); for (int i = 0; i < RAW_MODULE_SIZE; i++) { if (imageBuf[i] != test_frame[i]) diff --git a/writer/HDF5DataFile.cpp b/writer/HDF5DataFile.cpp index f562d4ff..c82b8ec1 100644 --- a/writer/HDF5DataFile.cpp +++ b/writer/HDF5DataFile.cpp @@ -43,6 +43,8 @@ HDF5DataFile::~HDF5DataFile() { group_exp.SaveVector("info", jf_info); group_exp.SaveVector("timestamp", timestamp); group_exp.SaveVector("storage_cell", storage_cell); + group_exp.SaveVector("exptime", exptime); + } rad_int_group.reset(); result_group.reset(); @@ -81,6 +83,7 @@ void HDF5DataFile::CreateFile() { jf_info.resize(1); timestamp.resize(1); storage_cell.resize(1); + exptime.resize(1); } void HDF5DataFile::Write(const DataMessage &msg, uint64_t image_number) { @@ -100,6 +103,7 @@ void HDF5DataFile::Write(const DataMessage &msg, uint64_t image_number) { bunch_id.resize(max_image_number + 1); jf_info.resize(max_image_number + 1); timestamp.resize(max_image_number + 1); + exptime.resize(max_image_number + 1); storage_cell.resize(max_image_number + 1); } @@ -125,6 +129,7 @@ void HDF5DataFile::Write(const DataMessage &msg, uint64_t image_number) { jf_info[image_number] = msg.jf_info; timestamp[image_number] = msg.timestamp; storage_cell[image_number] = msg.storage_cell; + exptime[image_number] = msg.exptime; if (!msg.rad_int_profile.empty() && (msg.rad_int_profile.size() == rad_int_bin_to_q.size())) rad_int_group->SaveVector("img" + std::to_string(image_number), msg.rad_int_profile); diff --git a/writer/HDF5DataFile.h b/writer/HDF5DataFile.h index f84fdd61..6b1cd72c 100644 --- a/writer/HDF5DataFile.h +++ b/writer/HDF5DataFile.h @@ -43,6 +43,7 @@ class HDF5DataFile { std::vector jf_info; std::vector timestamp; std::vector storage_cell; + std::vector exptime; std::vector rad_int_bin_to_q; std::vector rad_int_file_avg;