FPGA: Fixes and simplifications to spot_finder core + SNR threshold test

This commit is contained in:
2023-10-20 12:23:50 +02:00
parent 4e4a232a6d
commit ad78fb0149
3 changed files with 69 additions and 12 deletions
+48
View File
@@ -1181,4 +1181,52 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_count_threshol
REQUIRE (spot_finder_result.strong_pixel[0] == (1<<0));
REQUIRE (spot_finder_result.strong_pixel[(123*1024 + 578) / 8] == (1<<2)); // 578 % 8 == 2
REQUIRE (spot_finder_result.strong_pixel[(121*1024 + 800) / 8] == (1<<0)); // 800 % 8 == 0
}
TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_snr_threshold", "[FPGA][Full]") {
const uint16_t nmodules = 4;
DiffractionExperiment x((DetectorGeometry(nmodules)));
x.Mode(DetectorMode::Raw);
x.UseInternalPacketGenerator(true).ImagesPerTrigger(1).PedestalG0Frames(0);
HLSSimulatedDevice test(0, 64);
std::vector<uint16_t> frame(RAW_MODULE_SIZE);
for (int i = 0; i < RAW_MODULE_SIZE; i++) {
frame[i] = ((i / RAW_MODULE_COLS) + (i % RAW_MODULE_COLS)) % 2;
}
// Mean = 0.5
// Std. dev. = 0.5
// Threshold = 10 * std. dev. - 6 is minimum count
frame [ 0] = 8;
frame [123*1024 + 578] = 5;
frame [121*1024 + 800] = 4;
frame [ 89*1024 + 300] = 7;
frame [300*1024 + 0] = 3;
test.SetInternalGeneratorFrame(frame);
test.SetSpotFinderParameters(0, 10);
REQUIRE_NOTHROW(test.StartAction(x));
REQUIRE_NOTHROW(test.WaitForActionComplete());
REQUIRE(test.OutputStream().size() == 1);
JFJochProtoBuf::AcquisitionDeviceStatistics device_statistics;
REQUIRE_NOTHROW(test.SaveStatistics(x, device_statistics));
REQUIRE(device_statistics.bytes_received() == 128 * nmodules * JUNGFRAU_PACKET_SIZE_BYTES);
auto imageBuf = test.GetDeviceOutput(0, 0)->pixels;
REQUIRE(memcmp(imageBuf, frame.data(), RAW_MODULE_SIZE * sizeof(uint16_t)) == 0);
auto spot_finder_result = test.GetDeviceOutput(0, 0)->spot_finding_result;
REQUIRE (spot_finder_result.strong_pixel_count == 2);
REQUIRE (spot_finder_result.snr_threshold == 10 * 4);
REQUIRE (spot_finder_result.count_threshold == 0);
REQUIRE (spot_finder_result.strong_pixel[0] == (1<<0));
REQUIRE (spot_finder_result.strong_pixel[(89*1024 + 300) / 8] == (1<<4)); // 300 % 8 == 4
}