81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include "hls_jfjoch.h"
|
|
|
|
int main() {
|
|
|
|
int ret = 0;
|
|
|
|
STREAM_512 input;
|
|
STREAM_512 output;
|
|
|
|
size_t nframes = 1;
|
|
|
|
std::vector<int16_t> input_frame(nframes * RAW_MODULE_SIZE), output_frame(nframes * 257 * 64 * 32);
|
|
for (int i = 0; i < nframes * RAW_MODULE_SIZE; i++) {
|
|
input_frame[i] = i % INT16_MAX;
|
|
}
|
|
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_ADD_MULTIPIXEL;
|
|
|
|
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 };
|
|
|
|
add_multipixel(input, output);
|
|
|
|
if (input.size() != 0)
|
|
ret = 1;
|
|
if (output.size() != nframes * (257 * 64) + 2)
|
|
ret = 1;
|
|
|
|
output.read();
|
|
for (int i = 0; i < nframes * 257 * 64 ; i++)
|
|
output_frame_512[i] = output.read().data;
|
|
output.read();
|
|
|
|
size_t diff = 0;
|
|
for (int line = 1; line < 511; line++) {
|
|
int new_line = line + (line / 256) * 2 - 1;
|
|
for (int col = 1; col < 1023; col++) {
|
|
int new_col = col + (col / 256) * 2 - 1;
|
|
if (output_frame[new_line * 1028 + new_col] != input_frame[line * 1024 + col])
|
|
diff++;
|
|
}
|
|
}
|
|
|
|
for (int col = 1; col < 1023; col++) {
|
|
int new_col = col + (col / 256) * 2 - 1;
|
|
if (output_frame[254 * 1028 + new_col] != input_frame[255 * 1024 + col])
|
|
diff++;
|
|
if (output_frame[255 * 1028 + new_col] != input_frame[255 * 1024 + col])
|
|
diff++;
|
|
}
|
|
|
|
|
|
for (int col = 1; col < 1023; col++) {
|
|
int new_col = col + (col / 256) * 2 - 1;
|
|
if (output_frame[256 * 1028 + new_col] != input_frame[256 * 1024 + col])
|
|
diff++;
|
|
if (output_frame[257 * 1028 + new_col] != input_frame[256 * 1024 + col])
|
|
diff++;
|
|
}
|
|
if (diff > 0) {
|
|
ret = 1;
|
|
std::cout << diff << std::endl;
|
|
}
|
|
if (ret != 0) {
|
|
printf("Test failed !!!\n");
|
|
ret = 1;
|
|
} else {
|
|
printf("Test passed !\n");
|
|
}
|
|
|
|
return ret;
|
|
}
|