// Copyright (2019-2023) Paul Scherrer Institute #include #include "hls_jfjoch.h" int main() { int ret = 0; STREAM_512 input; STREAM_512 output; for (size_t nframes = 1; nframes < 5; nframes++) { std::vector input_frame(nframes * RAW_MODULE_SIZE); std::vector input_frame_transformed(nframes * RAW_MODULE_SIZE); std::vector output_frame(nframes * RAW_MODULE_SIZE); std::mt19937 g1(1387); std::uniform_int_distribution dist(0, 65535); for (int n = 0; n < nframes; n++) { for (int line = 0; line < RAW_MODULE_LINES; line++) { size_t line_transformed = RAW_MODULE_LINES - 1 - line; for (int col = 0; col < RAW_MODULE_COLS; col++) { uint16_t tmp = dist(g1); input_frame[n * RAW_MODULE_SIZE + line * RAW_MODULE_COLS + col] = tmp; input_frame_transformed[n * RAW_MODULE_SIZE + line_transformed * RAW_MODULE_COLS + col] = tmp; } } } auto input_frame_512 = (ap_uint<512>*) input_frame.data(); auto output_frame_512 = (ap_uint<512>*) output_frame.data(); ap_uint<512> action_control = 0; ACT_REG_MODE(action_control) = MODE_MODULE_UPSIDE_DOWN; input << packet_512_t { .data = action_control, .user = 0 }; for (int i = 0; i < nframes * RAW_MODULE_SIZE * sizeof(uint16_t) / 64; i++) input << packet_512_t { .data = input_frame_512[i], .user = 0 }; input << packet_512_t { .user = 1 }; module_upside_down(input, output); if (input.size() != 0) ret = 1; if (output.size() != nframes * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 + 2) ret = 1; output.read(); for (int i = 0; i < nframes * RAW_MODULE_SIZE * sizeof(uint16_t) / 64 ; i++) output_frame_512[i] = output.read().data; output.read(); if (output_frame != input_frame_transformed) { std::cout << "Input and output don't match" << std::endl; ret = 1; } } if (ret != 0) { printf("Test failed !!!\n"); ret = 1; } else { printf("Test passed !\n"); } return ret; }